diff --git a/pkgs/build-support/rust/default.nix b/pkgs/build-support/rust/default.nix index ad8488494e4c..028390640d10 100644 --- a/pkgs/build-support/rust/default.nix +++ b/pkgs/build-support/rust/default.nix @@ -13,11 +13,13 @@ , cargoUpdateHook ? "" , cargoDepsHook ? "" , cargoBuildFlags ? [] +, buildType ? "release" , cargoVendorDir ? null , ... } @ args: assert cargoVendorDir == null -> cargoSha256 != "unset"; +assert buildType == "release" || buildType == "debug"; let cargoDeps = if cargoVendorDir == null @@ -42,7 +44,7 @@ let cxxForBuild="${buildPackages.stdenv.cc}/bin/${buildPackages.stdenv.cc.targetPrefix}c++"; ccForHost="${stdenv.cc}/bin/${stdenv.cc.targetPrefix}cc"; cxxForHost="${stdenv.cc}/bin/${stdenv.cc.targetPrefix}c++"; - releaseDir = "target/${stdenv.hostPlatform.config}/release"; + releaseDir = "target/${stdenv.hostPlatform.config}/${buildType}"; in stdenv.mkDerivation (args // { inherit cargoDeps; @@ -98,7 +100,7 @@ in stdenv.mkDerivation (args // { "CC_${stdenv.hostPlatform.config}"="${ccForHost}" \ "CXX_${stdenv.hostPlatform.config}"="${cxxForHost}" \ cargo build \ - --release \ + --${buildType} \ --target ${stdenv.hostPlatform.config} \ --frozen ${concatStringsSep " " cargoBuildFlags} ) @@ -106,7 +108,7 @@ in stdenv.mkDerivation (args // { # rename the output dir to a architecture independent one mapfile -t targets < <(find "$NIX_BUILD_TOP" -type d | grep '${releaseDir}$') for target in "''${targets[@]}"; do - rm -rf "$target/../../release" + rm -rf "$target/../../${buildType}" ln -srf "$target" "$target/../../" done