refactor flake

This commit is contained in:
cy 2025-04-26 14:21:18 -04:00
parent b8877f33a3
commit fc304df35e
Signed by: cy
SSH key fingerprint: SHA256:o/geVWV4om1QhUSkKvDQeW/eAihwnjyXkqMwrVdbuts

View file

@ -23,6 +23,11 @@
toolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml; toolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
craneLib = (crane.mkLib pkgs).overrideToolchain(_: toolchain); craneLib = (crane.mkLib pkgs).overrideToolchain(_: toolchain);
lib = pkgs.lib; lib = pkgs.lib;
src = craneLib.cleanCargoSource ./.;
commonArgs = {
inherit src;
strictDeps = true;
nativeBuildInputs = with pkgs; [ nativeBuildInputs = with pkgs; [
pkg-config pkg-config
]; ];
@ -32,32 +37,31 @@
nix nix
boost boost
]; ];
env = {
# for cpp bindings to work # for cpp bindings to work
NIX_INCLUDE_PATH = "${lib.getDev pkgs.nix}/include"; NIX_INCLUDE_PATH = "${lib.getDev pkgs.nix}/include";
}; };
cargoArtifacts = craneLib.buildDepsOnly commonArgs;
nixcp = craneLib.buildPackage (commonArgs // {
inherit cargoArtifacts;
});
in in
{ {
devShells.default = pkgs.mkShell { devShells.default = craneLib.devShell {
inherit buildInputs; inputsFrom = [ nixcp ];
inherit nativeBuildInputs;
RUST_LOG = "nixcp=debug";
RUST_BACKGRACE = 1;
# for cpp bindings to work
NIX_INCLUDE_PATH = "${lib.getDev pkgs.nix}/include";
packages = with pkgs; [ packages = with pkgs; [
tokio-console tokio-console
cargo-udeps cargo-udeps
]; ];
env = env // {
RUST_LOG = "nixcp=debug";
RUST_BACKGRACE = 1;
};
}; };
packages.default = craneLib.buildPackage { packages.default = nixcp;
inherit nativeBuildInputs;
inherit buildInputs;
inherit env;
src = craneLib.cleanCargoSource ./.;
strictDeps = true;
};
} }
); );
} }