diff --git a/pkgs/build-support/rust/hooks/cargo-build-hook.sh b/pkgs/build-support/rust/hooks/cargo-build-hook.sh index 54f4512d67ca..6760277c2941 100644 --- a/pkgs/build-support/rust/hooks/cargo-build-hook.sh +++ b/pkgs/build-support/rust/hooks/cargo-build-hook.sh @@ -9,6 +9,10 @@ cargoBuildHook() { pushd "${buildAndTestSubdir}" fi + if [ "${cargoBuildType}" != "debug" ]; then + cargoBuildProfileFlag="--${cargoBuildType}" + fi + ( set -x env \ @@ -19,7 +23,7 @@ cargoBuildHook() { cargo build -j $NIX_BUILD_CORES \ --target @rustTargetPlatformSpec@ \ --frozen \ - --${cargoBuildType} \ + ${cargoBuildProfileFlag} \ ${cargoBuildFlags} ) diff --git a/pkgs/build-support/rust/hooks/cargo-check-hook.sh b/pkgs/build-support/rust/hooks/cargo-check-hook.sh index bc913c6ab074..e4c906f873c4 100644 --- a/pkgs/build-support/rust/hooks/cargo-check-hook.sh +++ b/pkgs/build-support/rust/hooks/cargo-check-hook.sh @@ -16,7 +16,11 @@ cargoCheckHook() { threads=1 fi - argstr="--${cargoCheckType} --target @rustTargetPlatformSpec@ --frozen ${cargoTestFlags}"; + if [ "${cargoBuildType}" != "debug" ]; then + cargoBuildProfileFlag="--${cargoBuildType}" + fi + + argstr="${cargoBuildProfileFlag} --target @rustTargetPlatformSpec@ --frozen ${cargoTestFlags}"; ( set -x