2024-06-30 08:12:46 +00:00
|
|
|
{
|
|
|
|
buildPackages,
|
|
|
|
callPackage,
|
|
|
|
cargo,
|
|
|
|
cargo-nextest,
|
|
|
|
clang,
|
|
|
|
lib,
|
|
|
|
makeSetupHook,
|
|
|
|
maturin,
|
|
|
|
rust,
|
|
|
|
rustc,
|
|
|
|
stdenv,
|
2024-05-02 00:46:19 +00:00
|
|
|
|
2024-06-30 08:12:46 +00:00
|
|
|
# This confusingly-named parameter indicates the *subdirectory of
|
|
|
|
# `target/` from which to copy the build artifacts. It is derived
|
|
|
|
# from a stdenv platform (or a JSON file).
|
|
|
|
target ? stdenv.hostPlatform.rust.cargoShortTarget,
|
2024-05-02 00:46:19 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
{
|
2024-06-30 08:12:46 +00:00
|
|
|
cargoBuildHook = callPackage (
|
|
|
|
{ }:
|
2024-05-02 00:46:19 +00:00
|
|
|
makeSetupHook {
|
|
|
|
name = "cargo-build-hook.sh";
|
|
|
|
propagatedBuildInputs = [ cargo ];
|
|
|
|
substitutions = {
|
|
|
|
inherit (rust.envVars) rustHostPlatformSpec setEnv;
|
|
|
|
};
|
2024-06-30 08:12:46 +00:00
|
|
|
} ./cargo-build-hook.sh
|
|
|
|
) { };
|
2024-05-02 00:46:19 +00:00
|
|
|
|
2024-06-30 08:12:46 +00:00
|
|
|
cargoCheckHook = callPackage (
|
|
|
|
{ }:
|
2024-05-02 00:46:19 +00:00
|
|
|
makeSetupHook {
|
|
|
|
name = "cargo-check-hook.sh";
|
|
|
|
propagatedBuildInputs = [ cargo ];
|
|
|
|
substitutions = {
|
|
|
|
inherit (rust.envVars) rustHostPlatformSpec;
|
|
|
|
};
|
2024-06-30 08:12:46 +00:00
|
|
|
} ./cargo-check-hook.sh
|
|
|
|
) { };
|
2024-05-02 00:46:19 +00:00
|
|
|
|
2024-06-30 08:12:46 +00:00
|
|
|
cargoInstallHook = callPackage (
|
|
|
|
{ }:
|
2024-05-02 00:46:19 +00:00
|
|
|
makeSetupHook {
|
|
|
|
name = "cargo-install-hook.sh";
|
|
|
|
propagatedBuildInputs = [ ];
|
|
|
|
substitutions = {
|
|
|
|
targetSubdirectory = target;
|
|
|
|
};
|
2024-06-30 08:12:46 +00:00
|
|
|
} ./cargo-install-hook.sh
|
|
|
|
) { };
|
2024-05-02 00:46:19 +00:00
|
|
|
|
2024-06-30 08:12:46 +00:00
|
|
|
cargoNextestHook = callPackage (
|
|
|
|
{ }:
|
2024-05-02 00:46:19 +00:00
|
|
|
makeSetupHook {
|
|
|
|
name = "cargo-nextest-hook.sh";
|
2024-06-30 08:12:46 +00:00
|
|
|
propagatedBuildInputs = [
|
|
|
|
cargo
|
|
|
|
cargo-nextest
|
|
|
|
];
|
2024-05-02 00:46:19 +00:00
|
|
|
substitutions = {
|
|
|
|
inherit (rust.envVars) rustHostPlatformSpec;
|
|
|
|
};
|
2024-06-30 08:12:46 +00:00
|
|
|
} ./cargo-nextest-hook.sh
|
|
|
|
) { };
|
2024-05-02 00:46:19 +00:00
|
|
|
|
2024-06-30 08:12:46 +00:00
|
|
|
cargoSetupHook = callPackage (
|
|
|
|
{ }:
|
2024-05-02 00:46:19 +00:00
|
|
|
makeSetupHook {
|
|
|
|
name = "cargo-setup-hook.sh";
|
|
|
|
propagatedBuildInputs = [ ];
|
|
|
|
substitutions = {
|
|
|
|
defaultConfig = ../fetchcargo-default-config.toml;
|
|
|
|
|
|
|
|
# Specify the stdenv's `diff` by abspath to ensure that the user's build
|
|
|
|
# inputs do not cause us to find the wrong `diff`.
|
|
|
|
diff = "${lib.getBin buildPackages.diffutils}/bin/diff";
|
|
|
|
|
|
|
|
cargoConfig = ''
|
|
|
|
[target."${stdenv.buildPlatform.rust.rustcTarget}"]
|
|
|
|
"linker" = "${rust.envVars.linkerForBuild}"
|
|
|
|
${lib.optionalString (stdenv.buildPlatform.config != stdenv.hostPlatform.config) ''
|
|
|
|
[target."${stdenv.hostPlatform.rust.rustcTarget}"]
|
|
|
|
"linker" = "${rust.envVars.linkerForHost}"
|
|
|
|
''}
|
2024-06-30 08:12:46 +00:00
|
|
|
"rustflags" = [ "-C", "target-feature=${
|
|
|
|
if stdenv.hostPlatform.isStatic then "+" else "-"
|
|
|
|
}crt-static" ]
|
2024-05-02 00:46:19 +00:00
|
|
|
'';
|
|
|
|
};
|
2024-06-30 08:12:46 +00:00
|
|
|
} ./cargo-setup-hook.sh
|
|
|
|
) { };
|
2024-05-02 00:46:19 +00:00
|
|
|
|
2024-06-30 08:12:46 +00:00
|
|
|
maturinBuildHook = callPackage (
|
|
|
|
{ pkgsHostTarget }:
|
2024-05-02 00:46:19 +00:00
|
|
|
makeSetupHook {
|
|
|
|
name = "maturin-build-hook.sh";
|
|
|
|
propagatedBuildInputs = [
|
|
|
|
pkgsHostTarget.maturin
|
|
|
|
pkgsHostTarget.cargo
|
|
|
|
pkgsHostTarget.rustc
|
|
|
|
];
|
|
|
|
substitutions = {
|
|
|
|
inherit (rust.envVars) rustTargetPlatformSpec setEnv;
|
|
|
|
};
|
2024-06-30 08:12:46 +00:00
|
|
|
} ./maturin-build-hook.sh
|
|
|
|
) { };
|
2024-05-02 00:46:19 +00:00
|
|
|
|
2024-06-30 08:12:46 +00:00
|
|
|
bindgenHook = callPackage (
|
|
|
|
{ }:
|
|
|
|
makeSetupHook {
|
2024-05-02 00:46:19 +00:00
|
|
|
name = "rust-bindgen-hook";
|
|
|
|
substitutions = {
|
|
|
|
libclang = clang.cc.lib;
|
|
|
|
inherit clang;
|
|
|
|
};
|
2024-06-30 08:12:46 +00:00
|
|
|
} ./rust-bindgen-hook.sh
|
|
|
|
) { };
|
2024-05-02 00:46:19 +00:00
|
|
|
}
|