update nix tooling

This commit is contained in:
LordGrimmauld 2024-03-29 14:55:47 +01:00
parent b6ce0ccb52
commit 179418dece
3 changed files with 72 additions and 4 deletions

View File

@ -17,12 +17,51 @@
in { in {
devShells = forAllSystems (system: let devShells = forAllSystems (system: let
pkgs = nixpkgs.legacyPackages.${system}; pkgs = nixpkgs.legacyPackages.${system};
overrides = (builtins.fromTOML (builtins.readFile ./rust-toolchain.toml));
libPath = with pkgs; lib.makeLibraryPath [
# load external libraries that you need in your rust project here
glib
gtk3
libsoup_3
networkmanager
webkitgtk_4_1
];
in { in {
default = pkgs.mkShell { default = pkgs.mkShell {
buildInputs = with pkgs; [
llvmPackages.bintools
rustup
];
RUSTC_VERSION = overrides.toolchain.channel;
# https://github.com/rust-lang/rust-bindgen#environment-variables
LIBCLANG_PATH = pkgs.lib.makeLibraryPath [ pkgs.llvmPackages_latest.libclang.lib ];
shellHook = ''
export PATH=$PATH:''${CARGO_HOME:-~/.cargo}/bin
export PATH=$PATH:''${RUSTUP_HOME:-~/.rustup}/toolchains/$RUSTC_VERSION-x86_64-unknown-linux-gnu/bin/
'';
# Add precompiled library to rustc search path
RUSTFLAGS = (builtins.map (a: ''-L ${a}/lib'') [
# add libraries here (e.g. pkgs.libvmi)
]);
LD_LIBRARY_PATH = libPath;
# Add glibc, clang, glib, and other headers to bindgen search path
BINDGEN_EXTRA_CLANG_ARGS =
# Includes normal include path
(builtins.map (a: ''-I"${a}/include"'') [
# add dev libraries here (e.g. pkgs.libvmi.dev)
pkgs.glibc.dev
])
# Includes with special directory paths
++ [
''-I"${pkgs.llvmPackages_latest.libclang.lib}/lib/clang/${pkgs.llvmPackages_latest.libclang.version}/include"''
''-I"${pkgs.glib.dev}/include/glib-2.0"''
''-I${pkgs.glib.out}/lib/glib-2.0/include/''
];
packages = with pkgs; [ packages = with pkgs; [
# base toolchain # base toolchain
pkg-config pkg-config
cargo rustup
# runtime deps # runtime deps
glib glib
@ -48,6 +87,13 @@
rmenu = rmenu-pkg; rmenu = rmenu-pkg;
default = rmenu-pkg; default = rmenu-pkg;
}); });
nixosModules = let
rmenu-module = (import ./nix/rmenu.nix);
in {
rmenu = rmenu-module;
default = rmenu-module;
};
}; };
} }

View File

@ -1,6 +1,7 @@
{ cargo { cargo
, fetchFromGitHub , fetchFromGitHub
, glib , glib
, gnused
, gtk3 , gtk3
, lib , lib
, libsoup_3 , libsoup_3
@ -47,21 +48,34 @@ rustPlatform.buildRustPackage rec {
libsoup_3 libsoup_3
networkmanager networkmanager
webkitgtk_4_1 webkitgtk_4_1
gnused
]; ];
postInstall = '' postInstall = ''
# copy themes and plugins
mkdir $out/themes mkdir $out/themes
mkdir $out/plugins mkdir $out/plugins
cp -vfr $src/themes/* $out/themes/. cp -vfr $src/themes/* $out/themes/.
cp -vfr $src/other-plugins/* $out/plugins/. cp -vfr $src/other-plugins/* $out/plugins/.
mv $out/bin/* $out/plugins # everything is a plugin by default mv $out/bin/* $out/plugins # everything is a plugin by default
# rmenu and rmenu-build are actual binaries
mv $out/plugins/rmenu $out/bin/rmenu mv $out/plugins/rmenu $out/bin/rmenu
mv $out/plugins/rmenu-build $out/bin/rmenu-build mv $out/plugins/rmenu-build $out/bin/rmenu-build
mkdir -p $out/etc/rmenu # fix plugin names
cp -vf $src/rmenu/public/config.yaml $out/etc/rmenu/config.yaml # desktop network pactl-audio.sh powermenu.sh run window
ln -sf $out/themes/dark.css $out/etc/rmenu/style.css mv $out/plugins/run $out/plugins/rmenu-run
mv $out/plugins/desktop $out/plugins/rmenu-desktop
mv $out/plugins/network $out/plugins/rmenu-network
mv $out/plugins/window $out/plugins/rmenu-window
# fix config and theme
mkdir -p $out/etc/xdg/rmenu
cp -vf $src/rmenu/public/config.yaml $out/etc/xdg/rmenu/config.yaml
sed -i "s@~\/\.config\/rmenu\/themes@$out\/themes@g" $out/etc/xdg/rmenu/config.yaml
sed -i "s@~\/\.config\/rmenu@$out\/plugins@g" $out/etc/xdg/rmenu/config.yaml
ln -sf $out/themes/dark.css $out/etc/xdg/rmenu/style.css
''; '';
doCheck = true; doCheck = true;

8
nix/rmenu.nix Normal file
View File

@ -0,0 +1,8 @@
{ lib, pkgs, ... }:
let
rmenu-pkg = pkgs.callPackage ./package.nix {};
in {
config.environment.systemPackages = [ rmenu-pkg ];
meta.maintainers = with lib.maintainers; [ grimmauld ];
}