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