Refactor dependency handling
Also fix openssl and pkg-config not being included in the deps for the project
This commit is contained in:
parent
4ba7f0e5ec
commit
9c6ccfcbc1
41
flake.nix
41
flake.nix
|
@ -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;
|
||||
};
|
||||
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue