From 84e37a10ec32b70c0e1a74fb3e5a837f6e7d74ab Mon Sep 17 00:00:00 2001 From: Artturin Date: Sat, 31 Dec 2022 15:25:54 +0200 Subject: [PATCH] stdenv: allow propagating propagated dependencies separately from the fixup phase for makeSetupHook --- pkgs/stdenv/generic/setup.sh | 65 +++++++++++++++++++----------------- 1 file changed, 35 insertions(+), 30 deletions(-) diff --git a/pkgs/stdenv/generic/setup.sh b/pkgs/stdenv/generic/setup.sh index 6ea44a641cef..1a637bf13fdd 100644 --- a/pkgs/stdenv/generic/setup.sh +++ b/pkgs/stdenv/generic/setup.sh @@ -995,6 +995,39 @@ stripHash() { } +recordPropagatedDependencies() { + # Propagate dependencies into the development output. + declare -ra flatVars=( + # Build + depsBuildBuildPropagated + propagatedNativeBuildInputs + depsBuildTargetPropagated + # Host + depsHostHostPropagated + propagatedBuildInputs + # Target + depsTargetTargetPropagated + ) + declare -ra flatFiles=( + "${propagatedBuildDepFiles[@]}" + "${propagatedHostDepFiles[@]}" + "${propagatedTargetDepFiles[@]}" + ) + + local propagatedInputsIndex + for propagatedInputsIndex in "${!flatVars[@]}"; do + local propagatedInputsSlice="${flatVars[$propagatedInputsIndex]}[@]" + local propagatedInputsFile="${flatFiles[$propagatedInputsIndex]}" + + [[ "${!propagatedInputsSlice}" ]] || continue + + mkdir -p "${!outputDev}/nix-support" + # shellcheck disable=SC2086 + printWords ${!propagatedInputsSlice} > "${!outputDev}/nix-support/$propagatedInputsFile" + done +} + + unpackCmdHooks+=(_defaultUnpack) _defaultUnpack() { local fn="$1" @@ -1379,36 +1412,8 @@ fixupPhase() { done - # Propagate dependencies & setup hook into the development output. - declare -ra flatVars=( - # Build - depsBuildBuildPropagated - propagatedNativeBuildInputs - depsBuildTargetPropagated - # Host - depsHostHostPropagated - propagatedBuildInputs - # Target - depsTargetTargetPropagated - ) - declare -ra flatFiles=( - "${propagatedBuildDepFiles[@]}" - "${propagatedHostDepFiles[@]}" - "${propagatedTargetDepFiles[@]}" - ) - - local propagatedInputsIndex - for propagatedInputsIndex in "${!flatVars[@]}"; do - local propagatedInputsSlice="${flatVars[$propagatedInputsIndex]}[@]" - local propagatedInputsFile="${flatFiles[$propagatedInputsIndex]}" - - [[ "${!propagatedInputsSlice}" ]] || continue - - mkdir -p "${!outputDev}/nix-support" - # shellcheck disable=SC2086 - printWords ${!propagatedInputsSlice} > "${!outputDev}/nix-support/$propagatedInputsFile" - done - + # record propagated dependencies & setup hook into the development output. + recordPropagatedDependencies if [ -n "${setupHook:-}" ]; then mkdir -p "${!outputDev}/nix-support"