diff --git a/pkgs/development/tools/build-managers/bazel/bazel_4/default.nix b/pkgs/development/tools/build-managers/bazel/bazel_4/default.nix index 09d967a599ae..64200c58fd8d 100644 --- a/pkgs/development/tools/build-managers/bazel/bazel_4/default.nix +++ b/pkgs/development/tools/build-managers/bazel/bazel_4/default.nix @@ -363,32 +363,6 @@ stdenv.mkDerivation rec { # Bazel starts a local server and needs to bind a local address. __darwinAllowLocalNetworking = true; - # Bazel expects several utils to be available in Bash even without PATH. Hence this hack. - customBash = writeCBin "bash" '' - #include - #include - #include - #include - - extern char **environ; - - int main(int argc, char *argv[]) { - char *path = getenv("PATH"); - char *pathToAppend = "${defaultShellPath}"; - char *newPath; - if (path != NULL) { - int length = strlen(path) + 1 + strlen(pathToAppend) + 1; - newPath = malloc(length * sizeof(char)); - snprintf(newPath, length, "%s:%s", path, pathToAppend); - } else { - newPath = pathToAppend; - } - setenv("PATH", newPath, 1); - execve("${bash}/bin/bash", argv, environ); - return 0; - } - ''; - postPatch = let darwinPatches = '' @@ -461,8 +435,8 @@ stdenv.mkDerivation rec { # We default to python3 where possible. See also `postFixup` where # python3 is added to $out/nix-support substituteInPlace "$path" \ - --replace /bin/bash ${customBash}/bin/bash \ - --replace "/usr/bin/env bash" ${customBash}/bin/bash \ + --replace /bin/bash ${bash}/bin/bash \ + --replace "/usr/bin/env bash" ${bash}/bin/bash \ --replace "/usr/bin/env python" ${python3}/bin/python \ --replace /usr/bin/env ${coreutils}/bin/env \ --replace /bin/true ${coreutils}/bin/true @@ -470,17 +444,17 @@ stdenv.mkDerivation rec { # bazel test runner include references to /bin/bash substituteInPlace tools/build_rules/test_rules.bzl \ - --replace /bin/bash ${customBash}/bin/bash + --replace /bin/bash ${bash}/bin/bash for i in $(find tools/cpp/ -type f) do substituteInPlace $i \ - --replace /bin/bash ${customBash}/bin/bash + --replace /bin/bash ${bash}/bin/bash done # Fixup scripts that generate scripts. Not fixed up by patchShebangs below. substituteInPlace scripts/bootstrap/compile.sh \ - --replace /bin/bash ${customBash}/bin/bash + --replace /bin/bash ${bash}/bin/bash # add nix environment vars to .bazelrc cat >> .bazelrc <> $out/nix-support/depends + echo "${defaultShellPath}" >> $out/nix-support/depends # The templates get tar’d up into a .jar, # so nix can’t detect python is needed in the runtime closure # Some of the scripts explicitly depend on Python 2.7. Otherwise, we