Unverified Commit 8c47608e authored by Uri Baghin's avatar Uri Baghin Committed by GitHub
Browse files

Merge pull request #268614 from boltzmannrain/bazel_darwin_bash_binary

bazel_6: fix: make patched bash a native binary
parents f3770720 dd854492
Loading
Loading
Loading
Loading
+13 −1
Original line number Diff line number Diff line
@@ -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";