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;
|
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;
|
||||||
};
|
};
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue