Refactor dependency handling

Also fix openssl and pkg-config not being included in the deps for the project
This commit is contained in:
Nathan McCarty 2023-05-15 16:47:00 -04:00
parent 4ba7f0e5ec
commit 9c6ccfcbc1
Signed by: thatonelutenist
SSH Key Fingerprint: SHA256:hwQEcmak9E6sdU9bXc98RHw/Xd1AhpB5HZT7ZSVJkRM
1 changed files with 21 additions and 20 deletions

View File

@ -69,13 +69,13 @@
rustc = rust; rustc = rust;
cargo = rust; cargo = rust;
}; };
buildInputs = (sharedDeps system) ++ (with pkgs; [ openssl ]);
nativeBuildInputs = (sharedNativeDeps system)
++ (with pkgs; [ pkg-config cmake ]);
devBase = with pkgs; devBase = with pkgs;
[ [
# Build tools # Build tools
openssl
pkg-config
rust-analyzer rust-analyzer
cmake
gnuplot gnuplot
# git tooling # git tooling
gitFull gitFull
@ -85,28 +85,29 @@
# Formatters # Formatters
nixfmt nixfmt
python311Packages.mdformat python311Packages.mdformat
] ++ map (x: self.packages.${system}.${x}) rustPackageNames; ] ++ buildInputs ++ nativeBuildInputs
++ map (x: self.packages.${system}.${x}) rustPackageNames;
in rec { in rec {
# Main binary # Main binary
packages.${crateName} = naersk-lib.buildPackage { packages.${crateName} = naersk-lib.buildPackage {
pname = "${crateName}"; pname = "${crateName}";
buildInputs = sharedDeps system; inherit buildInputs;
nativeBuildInputs = sharedNativeDeps system; inherit nativeBuildInputs;
root = src; root = src;
}; };
# binary + tests # binary + tests
packages.tests.${crateName} = naersk-lib.buildPackage { packages.tests.${crateName} = naersk-lib.buildPackage {
pname = "${crateName}"; pname = "${crateName}";
buildInputs = sharedDeps system; inherit buildInputs;
nativeBuildInputs = sharedNativeDeps system; inherit nativeBuildInputs;
root = src; root = src;
doCheck = true; doCheck = true;
}; };
# Docs # Docs
packages.docs.${crateName} = naersk-lib.buildPackage { packages.docs.${crateName} = naersk-lib.buildPackage {
pname = "${crateName}"; pname = "${crateName}";
buildInputs = sharedDeps system; inherit buildInputs;
nativeBuildInputs = sharedNativeDeps system; inherit nativeBuildInputs;
root = src; root = src;
dontBuild = true; dontBuild = true;
doDoc = true; doDoc = true;
@ -123,10 +124,10 @@
stdenv.mkDerivation { stdenv.mkDerivation {
name = "format lint"; name = "format lint";
src = src; src = src;
inherit buildInputs;
nativeBuildInputs = with pkgs; nativeBuildInputs = with pkgs;
[ rust-bin.stable.latest.default ] [ rust-bin.stable.latest.default ] ++ nativeBuildInputs;
++ (sharedNativeDeps system); dontConfigure = true;
buildInputs = sharedDeps system;
buildPhase = "cargo fmt -- --check"; buildPhase = "cargo fmt -- --check";
installPhase = "mkdir -p $out; echo 'done'"; installPhase = "mkdir -p $out; echo 'done'";
}; };
@ -135,10 +136,10 @@
stdenv.mkDerivation { stdenv.mkDerivation {
name = "audit lint"; name = "audit lint";
src = src; src = src;
inherit buildInputs;
nativeBuildInputs = with pkgs; nativeBuildInputs = with pkgs;
[ rust-bin.stable.latest.default cargo-audit ] [ rust-bin.stable.latest.default ] ++ nativeBuildInputs;
++ (sharedNativeDeps system); dontConfigure = true;
buildInputs = sharedDeps system;
buildPhase = '' buildPhase = ''
export HOME=$TMP export HOME=$TMP
mkdir -p ~/.cargo mkdir -p ~/.cargo
@ -151,8 +152,8 @@
clippy.${crateName} = naersk-lib.buildPackage { clippy.${crateName} = naersk-lib.buildPackage {
pname = "${crateName}"; pname = "${crateName}";
root = src; root = src;
buildInputs = sharedDeps system; inherit buildInputs;
nativeBuildInputs = sharedNativeDeps system; inherit nativeBuildInputs;
cargoTestCommands = (old: [ "cargo $cargo_options clippy" ]); cargoTestCommands = (old: [ "cargo $cargo_options clippy" ]);
doCheck = true; doCheck = true;
dontBuild = true; dontBuild = true;
@ -162,8 +163,8 @@
# Development environments # Development environments
devShell = pkgs.mkShell { devShell = pkgs.mkShell {
inputsFrom = builtins.attrValues packages; inputsFrom = builtins.attrValues packages;
buildInputs = [ rust ] ++ devBase ++ (sharedDeps system) buildInputs = [ rust ] ++ devBase ++ buildInputs
++ (sharedNativeDeps system); ++ nativeBuildInputs;
}; };
}); });