fixing the patchShebangs script to respect cross compilation is incredibly important for reducing image size and build contamination. the script works by searching the build source for #! /path/to/binary in executable files and then replacing that binary with one from $PATH (which is populated with binaries from the nix store).
in this PR NixOS/nixpkgs#43833 (that was reverted) patchShebangs works by populating $PATH with binaries from buildInputs (to get host binaries and not build-time binaries). this works exactly the same except in the case of bash, which is never listed in buildInputs and is always implicitly in $PATH during non-cross builds (because of stdenv).
therefore we need to add the runtimeShell package as a buildInput to every derivation so patchShebangs can pick up on that package when doing its magic. this most likely means editing stdenv to include that package in its default list of buildInputs.
fixing the
patchShebangsscript to respect cross compilation is incredibly important for reducing image size and build contamination. the script works by searching the build source for#! /path/to/binaryin executable files and then replacing that binary with one from$PATH(which is populated with binaries from the nix store).in this PR NixOS/nixpkgs#43833 (that was reverted)
patchShebangsworks by populating$PATHwith binaries frombuildInputs(to get host binaries and not build-time binaries). this works exactly the same except in the case ofbash, which is never listed inbuildInputsand is always implicitly in$PATHduring non-cross builds (because ofstdenv).therefore we need to add the
runtimeShellpackage as abuildInputto every derivation sopatchShebangscan pick up on that package when doing its magic. this most likely means editingstdenvto include that package in its default list ofbuildInputs.