Add configureCargoCommonVarsHook

This commit is contained in:
Ivan Petkov 2021-12-26 17:10:04 -08:00
parent e1b7cea23c
commit c2d7d083d5
No known key found for this signature in database
GPG Key ID: BB6F9EFC065832B6
3 changed files with 22 additions and 0 deletions

View File

@ -1,4 +1,5 @@
{ cargo
, configureCargoCommonVarsHook
, configureCargoVendoredDepsHook
, lib
, stdenv
@ -8,6 +9,7 @@ args@{ nativeBuildInputs ? [ ], ... }:
stdenv.mkDerivation (args // {
nativeBuildInputs = nativeBuildInputs ++ [
cargo
configureCargoCommonVarsHook
configureCargoVendoredDepsHook
];

View File

@ -0,0 +1,15 @@
configureCargoCommonVars() {
echo "Executing configureCargoCommonVars"
export CARGO_BUILD_JOBS=${CARGO_BUILD_JOBS:-$NIX_BUILD_CORES}
export RUST_TEST_THREADS=${RUST_TEST_THREADS:-$NIX_BUILD_CORES}
# Disable incremental builds by default since we don't get a ton of benefit
# while building with nix. Allow a declared-but-empty variable which will tell
# cargo to honor the definition used in the build profile
export CARGO_BUILD_INCREMENTAL=${CARGO_BUILD_INCREMENTAL-false}
echo "Finished configureCargoCommonVars"
}
preConfigureHooks+=(configureCargoCommonVars)

View File

@ -1,6 +1,11 @@
{ makeSetupHook }:
{
configureCargoCommonVarsHook = makeSetupHook
{
name = "configureCargoCommonVarsHook";
} ./configureCargoCommonVarsHook.sh;
configureCargoVendoredDepsHook = makeSetupHook
{
name = "configureCargoVendoredDepsHook";