diff --git a/pkgs/build-support/setup-hooks/patch-shebangs.sh b/pkgs/build-support/setup-hooks/patch-shebangs.sh index b35c3c876253..441f230869b2 100644 --- a/pkgs/build-support/setup-hooks/patch-shebangs.sh +++ b/pkgs/build-support/setup-hooks/patch-shebangs.sh @@ -102,12 +102,10 @@ patchShebangs() { patchShebangsAuto () { if [ -z "$dontPatchShebangs" -a -e "$prefix" ]; then - if [ -z "${strictDeps-}"]; then - patchShebangs --build "$prefix" # Dev output will end up being run on the build platform. An # example case of this is sdl2-config. Otherwise, we can just # use the runtime path (--host). - elif [ "$output" != out ] && [ "$output" = "${!outputDev}" ]; then + if [ "$output" != out ] && [ "$output" = "${!outputDev}" ]; then patchShebangs --build "$prefix" else patchShebangs --host "$prefix" diff --git a/pkgs/stdenv/generic/setup.sh b/pkgs/stdenv/generic/setup.sh index 336e229c6a32..be96d018612c 100644 --- a/pkgs/stdenv/generic/setup.sh +++ b/pkgs/stdenv/generic/setup.sh @@ -257,9 +257,17 @@ shopt -s nullglob # Set up the initial path. PATH= +HOST_PATH= for i in $initialPath; do if [ "$i" = / ]; then i=; fi addToSearchPath PATH "$i/bin" + + # For backward compatibility, we add initial path to HOST_PATH so + # it can be used in auto patch-shebangs. Unfortunately this will + # not work with cross compilation. + if [ -z "${strictDeps-}" ]; then + addToSearchPath HOST_PATH "$i/bin" + fi done if (( "${NIX_DEBUG:-0}" >= 1 )); then