13 # This confusingly-named parameter indicates the *subdirectory of
14 # `target/` from which to copy the build artifacts. It is derived
15 # from a stdenv platform (or a JSON file).
16 , target ? stdenv.hostPlatform.rust.cargoShortTarget
20 cargoBuildHook = callPackage ({ }:
22 name = "cargo-build-hook.sh";
23 propagatedBuildInputs = [ cargo ];
25 inherit (rust.envVars) rustHostPlatformSpec setEnv;
27 } ./cargo-build-hook.sh) {};
29 cargoCheckHook = callPackage ({ }:
31 name = "cargo-check-hook.sh";
32 propagatedBuildInputs = [ cargo ];
34 inherit (rust.envVars) rustHostPlatformSpec setEnv;
36 } ./cargo-check-hook.sh) {};
38 cargoInstallHook = callPackage ({ }:
40 name = "cargo-install-hook.sh";
41 propagatedBuildInputs = [ ];
43 targetSubdirectory = target;
45 } ./cargo-install-hook.sh) {};
47 cargoNextestHook = callPackage ({ }:
49 name = "cargo-nextest-hook.sh";
50 propagatedBuildInputs = [ cargo cargo-nextest ];
52 inherit (rust.envVars) rustHostPlatformSpec;
54 } ./cargo-nextest-hook.sh) {};
56 cargoSetupHook = callPackage ({ }:
58 name = "cargo-setup-hook.sh";
59 propagatedBuildInputs = [ ];
61 defaultConfig = ../fetchcargo-default-config.toml;
63 # Specify the stdenv's `diff` by abspath to ensure that the user's build
64 # inputs do not cause us to find the wrong `diff`.
65 diff = "${lib.getBin buildPackages.diffutils}/bin/diff";
68 [target."${stdenv.buildPlatform.rust.rustcTarget}"]
69 "linker" = "${rust.envVars.ccForBuild}"
70 ${lib.optionalString (stdenv.buildPlatform.config != stdenv.hostPlatform.config) ''
71 [target."${stdenv.hostPlatform.rust.rustcTarget}"]
72 "linker" = "${rust.envVars.ccForHost}"
74 "rustflags" = [ "-C", "target-feature=${if stdenv.hostPlatform.isStatic then "+" else "-"}crt-static" ]
77 } ./cargo-setup-hook.sh) {};
79 maturinBuildHook = callPackage ({ pkgsHostTarget }:
81 name = "maturin-build-hook.sh";
82 propagatedBuildInputs = [
83 pkgsHostTarget.maturin
88 inherit (rust.envVars) rustTargetPlatformSpec setEnv;
90 } ./maturin-build-hook.sh) {};
92 bindgenHook = callPackage ({}: makeSetupHook {
93 name = "rust-bindgen-hook";
95 libclang = clang.cc.lib;
99 ./rust-bindgen-hook.sh) {};