Files
nixpkgs/pkgs/build-support/rust/hooks/cargo-build-hook.sh
Dark Steveneq 646b892680
Some checks failed
Periodic Merges (6h) / master → staging-nixos (push) Failing after 12m50s
Periodic Merges (6h) / master → staging-next (push) Failing after 12m54s
Periodic Merges (24h) / merge-base(master,staging) → haskell-updates (push) Failing after 11m54s
Periodic Merges (6h) / staging-next → staging (push) Failing after 12m13s
Periodic Merges (24h) / staging-next-25.05 → staging-25.05 (push) Failing after 13m24s
Periodic Merges (24h) / release-25.05 → staging-next-25.05 (push) Failing after 14m28s
push sheeet
2025-10-09 14:15:47 +02:00

55 lines
1.3 KiB
Bash

# shellcheck shell=bash disable=SC2154,SC2164
cargoBuildHook() {
echo "Executing cargoBuildHook"
runHook preBuild
# Let stdenv handle stripping, for consistency and to not break
# separateDebugInfo.
export "CARGO_PROFILE_${cargoBuildType@U}_STRIP"=false
if [ -n "${buildAndTestSubdir-}" ]; then
# ensure the output doesn't end up in the subdirectory
CARGO_TARGET_DIR="$(pwd)/target"
export CARGO_TARGET_DIR
pushd "${buildAndTestSubdir}"
fi
local flagsArray=(
"-j" "$NIX_BUILD_CORES"
"--target" "@rustcTargetSpec@"
"--offline"
)
if [ "${cargoBuildType}" != "debug" ]; then
flagsArray+=("--profile" "${cargoBuildType}")
fi
if [ -n "${cargoBuildNoDefaultFeatures-}" ]; then
flagsArray+=("--no-default-features")
fi
if [ -n "${cargoBuildFeatures-}" ]; then
flagsArray+=("--features=$(concatStringsSep "," cargoBuildFeatures)")
fi
concatTo flagsArray cargoBuildFlags
echoCmd 'cargoBuildHook flags' "${flagsArray[@]}"
@setEnv@ cargo build "${flagsArray[@]}"
if [ -n "${buildAndTestSubdir-}" ]; then
popd
fi
runHook postBuild
echo "Finished cargoBuildHook"
}
if [ -z "${dontCargoBuild-}" ] && [ -z "${buildPhase-}" ]; then
buildPhase=cargoBuildHook
fi