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,41 +23,45 @@
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;
nativeBuildInputs = with pkgs; [ src = craneLib.cleanCargoSource ./.;
pkg-config
]; commonArgs = {
buildInputs = with pkgs; [ inherit src;
toolchain strictDeps = true;
openssl nativeBuildInputs = with pkgs; [
nix pkg-config
boost ];
]; buildInputs = with pkgs; [
env = { toolchain
openssl
nix
boost
];
# 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;
};
} }
); );
} }