Skip to content

Commit

Permalink
Merge pull request #268614 from boltzmannrain/bazel_darwin_bash_binary
Browse files Browse the repository at this point in the history
bazel_6: fix: make patched bash a native binary
  • Loading branch information
uri-canva authored Nov 22, 2023
2 parents f377072 + dd85449 commit 8c47608
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion pkgs/development/tools/build-managers/bazel/bazel_6/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
, substituteAll
, writeTextFile
, writeShellApplication
, makeBinaryWrapper
}:

let
Expand Down Expand Up @@ -129,7 +130,7 @@ let

defaultShellPath = lib.makeBinPath defaultShellUtils;

bashWithDefaultShellUtils = writeShellApplication {
bashWithDefaultShellUtilsSh = writeShellApplication {
name = "bash";
runtimeInputs = defaultShellUtils;
text = ''
Expand All @@ -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";
Expand Down

0 comments on commit 8c47608

Please sign in to comment.