dotfiles/nix/rust.nix
2023-10-12 01:29:01 +03:00

22 lines
562 B
Nix

{ pkgs
, crane
, buildTarget ? "x86_64-unknown-linux-musl"
}:
let
craneLib = (crane.mkLib pkgs).overrideToolchain pkgs.rustToolchain;
buildInputs = [ pkgs.protobuf ];
doCheck = false;
src = pkgs.lib.cleanSourceWith {
src = craneLib.path ../.;
filter = path: type:
(craneLib.filterCargoSources path type) ||
(builtins.match ".*proto$" path != null);
};
in
craneLib.buildPackage {
inherit src doCheck buildInputs;
CARGO_BUILD_RUSTFLAGS = "-C target-feature=+crt-static -C linker=rust-lld";
CARGO_BUILD_TARGET = buildTarget;
}