at master 41 lines 1.2 kB view raw
1{ 2 lib, 3 makeBinaryWrapper, 4 writeShellApplication, 5 bash, 6 stdenv, 7}: 8{ defaultShellUtils }: 9let 10 defaultShellPath = lib.makeBinPath defaultShellUtils; 11 12 bashWithDefaultShellUtilsSh = writeShellApplication { 13 name = "bash"; 14 runtimeInputs = defaultShellUtils; 15 # Empty PATH in Nixpkgs Bash is translated to /no-such-path 16 # On other distros empty PATH search fallback is looking in standard 17 # locations like /bin,/usr/bin 18 # For Bazel many rules rely on such search finding some common utils, 19 # so we provide them in case rules or arguments didn't specify a precise PATH 20 text = '' 21 if [[ "$PATH" == "/no-such-path" ]]; then 22 export PATH=${defaultShellPath} 23 fi 24 exec ${bash}/bin/bash "$@" 25 ''; 26 }; 27 28in 29{ 30 inherit defaultShellUtils defaultShellPath; 31 # Script-based interpreters in shebangs aren't guaranteed to work, 32 # especially on MacOS. So let's produce a binary 33 bashWithDefaultShellUtils = stdenv.mkDerivation { 34 name = "bash"; 35 src = bashWithDefaultShellUtilsSh; 36 nativeBuildInputs = [ makeBinaryWrapper ]; 37 buildPhase = '' 38 makeWrapper ${bashWithDefaultShellUtilsSh}/bin/bash $out/bin/bash 39 ''; 40 }; 41}