Merge pull request #268614 from boltzmannrain/bazel_darwin_bash_binary

bazel_6: fix: make patched bash a native binary
This commit is contained in:
Uri Baghin
2023-11-22 14:51:39 +08:00
committed by GitHub
@@ -23,6 +23,7 @@
, substituteAll
, writeTextFile
, writeShellApplication
, makeBinaryWrapper
}:
let
@@ -129,7 +130,7 @@ let
defaultShellPath = lib.makeBinPath defaultShellUtils;
bashWithDefaultShellUtils = writeShellApplication {
bashWithDefaultShellUtilsSh = writeShellApplication {
name = "bash";
runtimeInputs = defaultShellUtils;
text = ''
@@ -140,6 +141,17 @@ let
'';
};
# Script-based interpreters in shebangs aren't guaranteed to work,
# especially on MacOS. So let's produce a binary
bashWithDefaultShellUtils = stdenv.mkDerivation {
name = "bash";
src = bashWithDefaultShellUtilsSh;
nativeBuildInputs = [ makeBinaryWrapper ];
buildPhase = ''
makeWrapper ${bashWithDefaultShellUtilsSh}/bin/bash $out/bin/bash
'';
};
platforms = lib.platforms.linux ++ lib.platforms.darwin;
system = if stdenv.hostPlatform.isDarwin then "darwin" else "linux";