Change:
uses to determine the substitute for the shebang path. This selects the wrong path during cross-builds and results in x8664 binaries getting pulled in as dependencies to cross-built binaries that can't possibly use them at runtime. I don't know if we can reliably pick the correct /bin/sh without it being in the PATH envvar. I presume patchShebangs works fine for binaries that don't overlap with stdenv's and are included in buildInputs. If you cross-build some packages to ARM platforms, patchShebangs runs in the fixup phase and run , you'll see it points to the native /bin/sh rather than the cross one. I was considering a PR to just add to the cross build of glibc, but figured it'd be better if the root issue were fixed instead. System: "16.03pre75806." Nix version: nix-env (Nix) 1.12pre1234abcdef Nixpkgs version: (Gorilla)
/participate. (I've stumbled across this too.)
Is it safe to assume are the only paths that will ever realistically have this problem? If so, how and where would we pull in as a buildInput without it clobbering the native /bin/sh used by stdenv to run the builder? Once we're already executing , it's too late to find any s. This problem overlaps with another, , which is that crossDrvs clobber stdenv's binaries in the PATH. The best solution I can come up with is to manually include in of e.g. glibc, add logic in to not add to the PATH when crossbuilding, based on some new derivation attr like , then search during , independently of what's set in the PATH. Or we could just make smarter about importing /bin/ PATHs that contain elements of the stdenv, namely: .
is essential to fix this without greatly complicating bootstrapping.
don't forget to close. :)
Addressed in

Discussion:
# rewritten to /nix/store/<hash>/bin/python.  Interpreters that are # already in the store are left untouched. <del> fixupOutputHooks+=('if [ -z "$dontPatchShebangs" -a -e "$prefix" ]; then patchShebangs "$prefix"; fi') </del> <ins> fixupOutputHooks+=(patchShebangsAuto) # Run patch shebangs on a directory. # patchShebangs [--build | --host] directory # Flags: # --build : Lookup commands available at build-time # --host  : Lookup commands available at runtime # Example use cases, # $ patchShebangs --host /nix/store/...-hello-1.0/bin # $ patchShebangs --build configure </ins> patchShebangs() { <ins> local pathName if [ "$1" = "--host" ]; then pathName=HOST_PATH shift elif [ "$1" = "--build" ]; then pathName=PATH shift fi </ins> local dir="$1" header "patching script interpreter paths in $dir" local f local oldPath

oldInterpreterLine=$(head -1 "$f" | tail -c+3) read -r oldPath arg0 args <<< "$oldInterpreterLine" <ins> if [ -z "$pathName" ]; then if [ -n "$strictDeps" ] && [[ "$f" = "$NIX_STORE"* ]]; then pathName=HOST_PATH else pathName=PATH fi fi </ins> if $(echo "$oldPath" | grep -q "/bin/env$"); then # Check for unsupported 'env' functionality: # - options: something starting with a '-'

echo "unsupported interpreter directive "$oldInterpreterLine" (set dontPatchShebangs=1 and handle shebang patching yourself)" exit 1 fi <del> newPath="$(command -v "$arg0" || true)" </del> <ins> newPath="$(PATH="${!pathName}" command -v "$arg0" || true)" </ins> else if [ "$oldPath" = "" ]; then # If no interpreter is specified linux will use /bin/sh. Set # oldpath="/bin/sh" so that we get /nix/store/.../sh. oldPath="/bin/sh" fi <del> newPath="$(command -v "$(basename "$oldPath")" || true)" </del> <ins> newPath="$(PATH="${!pathName}" command -v "$(basename "$oldPath")" || true)" </ins> args="$arg0 $args" fi

stopNest } <ins> patchShebangsAuto () { if [ -z "$dontPatchShebangs" -a -e "$prefix" ]; then # 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). if [ "$output" != out ] && [ "$output" = "${!outputDev}" ]; then patchShebangs --build "$prefix" else patchShebangs --host "$prefix" fi fi } </ins>