bazel_8: init at 8.4.1

The setup is based on bazel 5,6,7 in nixpkgs but is significantly
different codeline-wise. There's a bit less patching, all patches
are via patch files and other small tweaks.

## Bazel 8 build
With 8.4.1 bazel dist archive is enough for air-gapped build removing
the need for FODs or `src-deps.json`, and in turn we no longer need
existing `bazel` binary to bootstrap the build.

`enableNixHacks` patch is removed, `bazel-examples` repo is used
as `passthru.tests` (cpp, java, rust) via new `bazel_8/build-support`
helpers.

`sed` patches are converted to patch files, overall amount of patching
is reduced, if there'd be need for more it can be added with links
to upstream issues or patches, ideally with a regression `passthru.tests`
item.

Amount of patching may potentially be reduced further, this needs
more feedback using this.

Overall using Bazel on NixOS remains tricky, for non-packaged repos
it may still be most practical to use FHS + extra hacks and patches,
maybe even straight up using Bazelisk and upstream pre-built binaries
in FHS.

## buildBazelPackage support
`pkgs/build-support/build-bazel-package/default.nix` is fairly big
with a set of tweaks that may not be necessary with recent Bazel
or may have better alternatives. More work is needed to figure
out compatibility with `bazel_8` or other things to unify with `bazel_8`
helpers.

## bazel_8/build-support
Here are fairly minimalistic helpers to aid building Bazel packages
using Bazel 8 features. For now only testes on `bazel-examples` repo.

`patching.nix`: just a helper to inject patches into Bazel external
dependencies

`bazelDerivation`: helps to compose Bazel commandline and consume
`repository_cache`, `vendor_dir`, `registry` all related to external
dependencies management

`bazelPackage`: two-stage derivation similar to `buildBazelPackage`,
having options for `repository_cache` (pure fetches) or `vendor_dir`
(unpacked fetches, further patchable)

+1145
+3
pkgs/by-name/ba/bazel_8/bazel-execlog.sh
··· 1 + #!@runtimeShell@ 2 + 3 + exec @binJava@ -jar @out@/share/parser_deploy.jar "$@"
+74
pkgs/by-name/ba/bazel_8/build-support/bazelDerivation.nix
··· 1 + { 2 + stdenv, 3 + lndir, 4 + lib, 5 + }: 6 + 7 + args@{ 8 + bazel, 9 + registry ? null, 10 + bazelRepoCache ? null, 11 + bazelVendorDeps ? null, 12 + startupArgs ? [ ], 13 + commandArgs ? [ ], 14 + bazelPreBuild ? "", 15 + bazelPostBuild ? "", 16 + serverJavabase ? null, 17 + targets, 18 + command, 19 + ... 20 + }: 21 + 22 + stdenv.mkDerivation ( 23 + { 24 + preBuildPhases = [ "preBuildPhase" ]; 25 + preBuildPhase = 26 + (lib.optionalString (bazelRepoCache != null) '' 27 + # repo_cache needs to be writeable even in air-gapped builds 28 + mkdir repo_cache 29 + ${lndir}/bin/lndir -silent ${bazelRepoCache}/repo_cache repo_cache 30 + '') 31 + 32 + + (lib.optionalString (bazelVendorDeps != null) '' 33 + mkdir vendor_dir 34 + ${lndir}/bin/lndir -silent ${bazelVendorDeps}/vendor_dir vendor_dir 35 + 36 + # pin all deps to avoid re-fetch attempts by Bazel 37 + rm vendor_dir/VENDOR.bazel 38 + find vendor_dir -mindepth 1 -maxdepth 1 -type d -printf "pin(\"@@%P\")\n" > vendor_dir/VENDOR.bazel 39 + '') 40 + # keep preBuildPhase always defined as it is listed in preBuildPhases 41 + + '' 42 + true 43 + ''; 44 + buildPhase = '' 45 + runHook preBuild 46 + 47 + export HOME=$(mktemp -d) 48 + 49 + ${bazelPreBuild} 50 + 51 + ${bazel}/bin/bazel ${ 52 + lib.escapeShellArgs ( 53 + lib.optional (serverJavabase != null) "--server_javabase=${serverJavabase}" 54 + ++ [ "--batch" ] 55 + ++ startupArgs 56 + ) 57 + } ${command} ${ 58 + lib.escapeShellArgs ( 59 + lib.optional (registry != null) "--registry=file://${registry}" 60 + ++ lib.optional (bazelRepoCache != null) "--repository_cache=repo_cache" 61 + ++ lib.optional (bazelVendorDeps != null) "--vendor_dir=vendor_dir" 62 + ++ commandArgs 63 + ++ targets 64 + ) 65 + } 66 + 67 + ${bazelPostBuild} 68 + 69 + runHook postBuild 70 + ''; 71 + 72 + } 73 + // args 74 + )
+164
pkgs/by-name/ba/bazel_8/build-support/bazelPackage.nix
··· 1 + { 2 + callPackage, 3 + gnugrep, 4 + lib, 5 + autoPatchelfHook, 6 + stdenv, 7 + }: 8 + 9 + { 10 + name, 11 + src, 12 + sourceRoot ? null, 13 + version ? null, 14 + targets, 15 + bazel, 16 + startupArgs ? [ ], 17 + commandArgs ? [ ], 18 + env ? { }, 19 + serverJavabase ? null, 20 + registry ? null, 21 + bazelRepoCacheFOD ? { 22 + outputHash = null; 23 + outputHashAlgo = "sha256"; 24 + }, 25 + bazelVendorDepsFOD ? { 26 + outputHash = null; 27 + outputHashAlgo = "sha256"; 28 + }, 29 + installPhase, 30 + buildInputs ? [ ], 31 + nativeBuildInputs ? [ ], 32 + autoPatchelfIgnoreMissingDeps ? null, 33 + }: 34 + let 35 + # FOD produced by `bazel fetch` 36 + # Repo cache contains content-addressed external Bazel dependencies without any patching 37 + # Potentially this can be nixified via --experimental_repository_resolved_file 38 + # (Note: file itself isn't reproducible because it has lots of extra info and order 39 + # isn't stable too. Parsing it into nix fetch* commands isn't trivial but might be possible) 40 + bazelRepoCache = 41 + if bazelRepoCacheFOD.outputHash == null then 42 + null 43 + else 44 + (callPackage ./bazelDerivation.nix { } { 45 + name = "bazelRepoCache"; 46 + inherit (bazelRepoCacheFOD) outputHash outputHashAlgo; 47 + inherit 48 + src 49 + version 50 + sourceRoot 51 + env 52 + buildInputs 53 + nativeBuildInputs 54 + ; 55 + inherit registry; 56 + inherit 57 + bazel 58 + targets 59 + startupArgs 60 + serverJavabase 61 + ; 62 + command = "fetch"; 63 + outputHashMode = "recursive"; 64 + commandArgs = [ "--repository_cache=repo_cache" ] ++ commandArgs; 65 + bazelPreBuild = '' 66 + mkdir repo_cache 67 + ''; 68 + installPhase = '' 69 + mkdir -p $out/repo_cache 70 + cp -r --reflink=auto repo_cache/* $out/repo_cache 71 + ''; 72 + }); 73 + # Stage1: FOD produced by `bazel vendor`, Stage2: eventual patchelf or other tuning 74 + # Vendor deps contains unpacked&patches external dependencies, this may need Nix-specific 75 + # patching to address things like 76 + # - broken symlinks 77 + # - symlinks or other references to absolute nix store paths which isn't allowed for FOD 78 + # - autoPatchelf for externally-fetched binaries 79 + # 80 + # Either repo cache or vendor deps should be enough to build a given package 81 + bazelVendorDeps = 82 + if bazelVendorDepsFOD.outputHash == null then 83 + null 84 + else 85 + ( 86 + let 87 + stage1 = callPackage ./bazelDerivation.nix { } { 88 + name = "bazelVendorDepsStage1"; 89 + inherit (bazelVendorDepsFOD) outputHash outputHashAlgo; 90 + inherit 91 + src 92 + version 93 + sourceRoot 94 + env 95 + buildInputs 96 + nativeBuildInputs 97 + ; 98 + inherit registry; 99 + inherit 100 + bazel 101 + targets 102 + startupArgs 103 + serverJavabase 104 + ; 105 + dontFixup = true; 106 + command = "vendor"; 107 + outputHashMode = "recursive"; 108 + commandArgs = [ "--vendor_dir=vendor_dir" ] ++ commandArgs; 109 + bazelPreBuild = '' 110 + mkdir vendor_dir 111 + ''; 112 + bazelPostBuild = '' 113 + # remove symlinks that point to locations under bazel_src/ 114 + find vendor_dir -type l -lname "$HOME/*" -exec rm '{}' \; 115 + # remove symlinks to temp build directory on darwin 116 + find vendor_dir -type l -lname "/private/var/tmp/*" -exec rm '{}' \; 117 + # remove broken symlinks 118 + find vendor_dir -xtype l -exec rm '{}' \; 119 + 120 + # remove .marker files referencing NIX_STORE as those references aren't allowed in FOD 121 + (${gnugrep}/bin/grep -rI "$NIX_STORE/" vendor_dir --files-with-matches --include="*.marker" --null || true) \ 122 + | xargs -0 --no-run-if-empty rm 123 + ''; 124 + installPhase = '' 125 + mkdir -p $out/vendor_dir 126 + cp -r --reflink=auto vendor_dir/* $out/vendor_dir 127 + ''; 128 + 129 + }; 130 + in 131 + stdenv.mkDerivation { 132 + name = "bazelVendorDeps"; 133 + buildInputs = lib.optional (!stdenv.hostPlatform.isDarwin) autoPatchelfHook ++ buildInputs; 134 + inherit autoPatchelfIgnoreMissingDeps; 135 + src = stage1; 136 + installPhase = '' 137 + cp -r . $out 138 + ''; 139 + } 140 + ); 141 + 142 + package = callPackage ./bazelDerivation.nix { } { 143 + inherit 144 + name 145 + src 146 + version 147 + sourceRoot 148 + env 149 + buildInputs 150 + nativeBuildInputs 151 + ; 152 + inherit registry bazelRepoCache bazelVendorDeps; 153 + inherit 154 + bazel 155 + targets 156 + startupArgs 157 + serverJavabase 158 + commandArgs 159 + ; 160 + inherit installPhase; 161 + command = "build"; 162 + }; 163 + in 164 + package // { passthru = { inherit bazelRepoCache bazelVendorDeps; }; }
+24
pkgs/by-name/ba/bazel_8/build-support/patching.nix
··· 1 + { 2 + stdenv, 3 + }: 4 + { 5 + # If there's a need to patch external dependencies managed by Bazel 6 + # one option is to configure patches on Bazel level. Bazel doesn't 7 + # allow patches to be in absolute paths so this helper will produce 8 + # sources patch that adds given file to given location 9 + addFilePatch = 10 + { 11 + path, 12 + file, 13 + }: 14 + stdenv.mkDerivation { 15 + name = "add_file.patch"; 16 + dontUnpack = true; 17 + buildPhase = '' 18 + mkdir -p $(dirname "${path}") 19 + cp ${file} "${path}" 20 + diff -u /dev/null "${path}" >result.patch || true # diff exit code is non-zero if there's a diff 21 + ''; 22 + installPhase = ''cp result.patch $out''; 23 + }; 24 + }
+41
pkgs/by-name/ba/bazel_8/defaultShell.nix
··· 1 + { 2 + lib, 3 + makeBinaryWrapper, 4 + writeShellApplication, 5 + bash, 6 + stdenv, 7 + }: 8 + { defaultShellUtils }: 9 + let 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 + 28 + in 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 + }
+120
pkgs/by-name/ba/bazel_8/examples.nix
··· 1 + { 2 + fetchFromGitHub, 3 + lib, 4 + bazel_8, 5 + libgcc, 6 + cctools, 7 + stdenv, 8 + jdk_headless, 9 + callPackage, 10 + zlib, 11 + }: 12 + let 13 + bazelPackage = callPackage ./build-support/bazelPackage.nix { }; 14 + registry = fetchFromGitHub { 15 + owner = "bazelbuild"; 16 + repo = "bazel-central-registry"; 17 + rev = "722299976c97e5191045c8016b7c8532189fc3f6"; 18 + sha256 = "sha256-hi5BKI94am2LCXD93GBeT0gsODxGeSsd0OrhTwpNAgM="; 19 + }; 20 + src = fetchFromGitHub { 21 + owner = "bazelbuild"; 22 + repo = "examples"; 23 + rev = "9d6a2e67d29b8b6208d22d70cb22880345bb6803"; 24 + sha256 = "sha256-NQqXsmX7hyTqLINkz1rnavx15jQTdIKpotw42rGc5mc="; 25 + }; 26 + in 27 + { 28 + java = bazelPackage { 29 + inherit src registry; 30 + sourceRoot = "source/java-tutorial"; 31 + name = "java-tutorial"; 32 + targets = [ "//:ProjectRunner" ]; 33 + bazel = bazel_8; 34 + commandArgs = [ 35 + "--extra_toolchains=@@rules_java++toolchains+local_jdk//:all" 36 + "--tool_java_runtime_version=local_jdk_21" 37 + ]; 38 + env = { 39 + JAVA_HOME = jdk_headless.home; 40 + USE_BAZEL_VERSION = bazel_8.version; 41 + }; 42 + installPhase = '' 43 + mkdir $out 44 + cp bazel-bin/ProjectRunner.jar $out/ 45 + ''; 46 + nativeBuildInputs = lib.optional (stdenv.hostPlatform.isDarwin) cctools; 47 + bazelRepoCacheFOD = { 48 + outputHash = 49 + { 50 + aarch64-darwin = "sha256-FwHsg9P65Eu/n8PV7UW90bvBNG+U67zizRy6Krk32Yg="; 51 + aarch64-linux = "sha256-W8h2tCIauGnEvPpXje19bZUE/izHaCQ0Wj4nMaP3nkc="; 52 + x86_64-darwin = "sha256-XIrGRmYDDRN3Kkt1dFWex1bPRMeIHAR+XWLqB/PpOAM="; 53 + x86_64-linux = "sha256-VBckTQAK5qeyi2ublk+Dcga5O5XZg3bfHR6Yaw6vSp0="; 54 + } 55 + .${stdenv.hostPlatform.system}; 56 + outputHashAlgo = "sha256"; 57 + }; 58 + }; 59 + cpp = bazelPackage { 60 + inherit src registry; 61 + sourceRoot = "source/cpp-tutorial/stage3"; 62 + name = "cpp-tutorial"; 63 + targets = [ "//main:hello-world" ]; 64 + bazel = bazel_8; 65 + installPhase = '' 66 + mkdir $out 67 + cp bazel-bin/main/hello-world $out/ 68 + ''; 69 + nativeBuildInputs = lib.optional (stdenv.hostPlatform.isDarwin) cctools; 70 + commandArgs = lib.optionals (stdenv.hostPlatform.isDarwin) [ 71 + "--host_cxxopt=-xc++" 72 + "--cxxopt=-xc++" 73 + ]; 74 + env = { 75 + USE_BAZEL_VERSION = bazel_8.version; 76 + }; 77 + bazelRepoCacheFOD = { 78 + outputHash = 79 + { 80 + aarch64-darwin = "sha256-l6qJU0zGIKl12TYYsG5b+upswUA0hGE+VtQ9QnKpBh8="; 81 + aarch64-linux = "sha256-l6qJU0zGIKl12TYYsG5b+upswUA0hGE+VtQ9QnKpBh8="; 82 + x86_64-darwin = "sha256-l6qJU0zGIKl12TYYsG5b+upswUA0hGE+VtQ9QnKpBh8="; 83 + x86_64-linux = "sha256-l6qJU0zGIKl12TYYsG5b+upswUA0hGE+VtQ9QnKpBh8="; 84 + } 85 + .${stdenv.hostPlatform.system}; 86 + outputHashAlgo = "sha256"; 87 + }; 88 + }; 89 + rust = bazelPackage { 90 + inherit src registry; 91 + sourceRoot = "source/rust-examples/01-hello-world"; 92 + name = "rust-examples-01-hello-world"; 93 + targets = [ "//:bin" ]; 94 + bazel = bazel_8; 95 + env = { 96 + USE_BAZEL_VERSION = bazel_8.version; 97 + }; 98 + installPhase = '' 99 + mkdir $out 100 + cp bazel-bin/bin $out/hello-world 101 + ''; 102 + buildInputs = [ 103 + zlib 104 + libgcc 105 + ]; 106 + nativeBuildInputs = lib.optional (stdenv.hostPlatform.isDarwin) cctools; 107 + autoPatchelfIgnoreMissingDeps = [ "librustc_driver-*.so" ]; 108 + bazelVendorDepsFOD = { 109 + outputHash = 110 + { 111 + aarch64-darwin = "sha256-D5bwW35QuLLhVE22FDyV9Nl8N7ULx71wCHbzB81+Xx0="; 112 + aarch64-linux = "sha256-F5X/cwtHR6sVFe1DzNDaEnGMIPR0SnXq2iIxhQeqIV8="; 113 + x86_64-darwin = "sha256-DXuPy68m3p6hlgEid7tpY8fGgvJWQTXth6h2kMSNFCc="; 114 + x86_64-linux = "sha256-oNLDccQ/XPg1Nl/9V14NdgiQsRoTvpaA6hyynMb414A="; 115 + } 116 + .${stdenv.hostPlatform.system}; 117 + outputHashAlgo = "sha256"; 118 + }; 119 + }; 120 + }
+345
pkgs/by-name/ba/bazel_8/package.nix
··· 1 + { 2 + stdenv, 3 + callPackage, 4 + # nix tooling and utilities 5 + darwin, 6 + lib, 7 + fetchzip, 8 + fetchpatch, 9 + makeWrapper, 10 + writeTextFile, 11 + replaceVars, 12 + # native build inputs 13 + runtimeShell, 14 + zip, 15 + unzip, 16 + bash, 17 + coreutils, 18 + which, 19 + gawk, 20 + gnused, 21 + gnutar, 22 + gnugrep, 23 + gzip, 24 + findutils, 25 + diffutils, 26 + gnupatch, 27 + file, 28 + installShellFiles, 29 + python3, 30 + # Apple dependencies 31 + cctools, 32 + # Allow to independently override the jdks used to build and run respectively 33 + jdk_headless, 34 + version ? "8.4.1", 35 + }: 36 + 37 + let 38 + inherit (callPackage ./build-support/patching.nix { }) addFilePatch; 39 + inherit (stdenv.hostPlatform) isDarwin isAarch64; 40 + 41 + bazelSystem = if isDarwin then "darwin" else "linux"; 42 + 43 + # on aarch64 Darwin, `uname -m` returns "arm64" 44 + bazelArch = if isDarwin && isAarch64 then "arm64" else stdenv.hostPlatform.parsed.cpu.name; 45 + 46 + src = fetchzip { 47 + url = "https://github.com/bazelbuild/bazel/releases/download/${version}/bazel-${version}-dist.zip"; 48 + hash = "sha256-DqJqW7C1QODOS+vJrs/+ixsP3coZh80VdpPM4g0vxFI="; 49 + stripRoot = false; 50 + }; 51 + 52 + defaultShellUtils = 53 + # Keep this list conservative. For more exotic tools, prefer to use 54 + # @rules_nixpkgs to pull in tools from the nix repository. Example: 55 + # 56 + # WORKSPACE: 57 + # 58 + # nixpkgs_git_repository( 59 + # name = "nixpkgs", 60 + # revision = "def5124ec8367efdba95a99523dd06d918cb0ae8", 61 + # ) 62 + # 63 + # # This defines an external Bazel workspace. 64 + # nixpkgs_package( 65 + # name = "bison", 66 + # repositories = { "nixpkgs": "@nixpkgs//:default.nix" }, 67 + # ) 68 + # 69 + # some/BUILD.bazel: 70 + # 71 + # genrule( 72 + # ... 73 + # cmd = "$(location @bison//:bin/bison) -other -args", 74 + # tools = [ 75 + # ... 76 + # "@bison//:bin/bison", 77 + # ], 78 + # ) 79 + [ 80 + coreutils 81 + diffutils 82 + file 83 + findutils 84 + gawk 85 + gnugrep 86 + gnupatch 87 + gnused 88 + gnutar 89 + gzip 90 + unzip 91 + which 92 + zip 93 + ]; 94 + defaultShell = callPackage ./defaultShell.nix { } { inherit defaultShellUtils; }; 95 + 96 + commandArgs = [ 97 + "--nobuild_python_zip" 98 + "--features=-module_maps" 99 + "--host_features=-module_maps" 100 + "--announce_rc" 101 + "--verbose_failures" 102 + "--curses=no" 103 + ] 104 + ++ lib.optionals (isDarwin) [ 105 + "--macos_sdk_version=${stdenv.hostPlatform.darwinMinVersion}" 106 + "--cxxopt=-isystem" 107 + "--cxxopt=${lib.getDev stdenv.cc.libcxx}/include/c++/v1" 108 + "--host_cxxopt=-isystem" 109 + "--host_cxxopt=${lib.getDev stdenv.cc.libcxx}/include/c++/v1" 110 + "--copt=-isystem" 111 + "--copt=${lib.getDev darwin.libresolv}/include" 112 + "--host_copt=-isystem" 113 + "--host_copt=${lib.getDev darwin.libresolv}/include" 114 + ]; 115 + 116 + in 117 + stdenv.mkDerivation rec { 118 + pname = "bazel"; 119 + inherit version src; 120 + 121 + darwinPatches = [ 122 + # Bazel integrates with apple IOKit to inhibit and track system sleep. 123 + # Inside the darwin sandbox, these API calls are blocked, and bazel 124 + # crashes. It seems possible to allow these APIs inside the sandbox, but it 125 + # feels simpler to patch bazel not to use it at all. So our bazel is 126 + # incapable of preventing system sleep, which is a small price to pay to 127 + # guarantee that it will always run in any nix context. 128 + # 129 + # See also ./bazel_darwin_sandbox.patch in bazel_5. That patch uses 130 + # NIX_BUILD_TOP env var to conditionnally disable sleep features inside the 131 + # sandbox. 132 + # 133 + # If you want to investigate the sandbox profile path, 134 + # IORegisterForSystemPower can be allowed with 135 + # 136 + # propagatedSandboxProfile = '' 137 + # (allow iokit-open (iokit-user-client-class "RootDomainUserClient")) 138 + # ''; 139 + # 140 + # I do not know yet how to allow IOPMAssertion{CreateWithName,Release} 141 + ./patches/darwin_sleep.patch 142 + 143 + # Fix DARWIN_XCODE_LOCATOR_COMPILE_COMMAND by removing multi-arch support. 144 + # Nixpkgs toolcahins do not support that (yet?) and get confused. 145 + # Also add an explicit /usr/bin prefix that will be patched below. 146 + (replaceVars ./patches/xcode.patch { 147 + usrBinEnv = "${coreutils}/bin/env"; 148 + clangDarwin = "${stdenv.cc}/bin/clang"; 149 + codesign = "${darwin.sigtool}/bin/codesign"; 150 + }) 151 + 152 + # Revert preference for apple_support over rules_cc toolchain for now 153 + # will need to figure out how to build with apple_support toolchain later 154 + ./patches/apple_cc_toolchain.patch 155 + 156 + # On Darwin, the last argument to gcc is coming up as an empty string. i.e: '' 157 + # This is breaking the build of any C target. This patch removes the last 158 + # argument if it's found to be an empty string. 159 + ./patches/trim-last-argument-to-gcc-if-empty.patch 160 + ]; 161 + 162 + patches = lib.optionals isDarwin darwinPatches ++ [ 163 + # patch that propagates rules_* patches below 164 + # patches need to be within source root and can't be absolute paths in Nix store 165 + # so rules_* patches are injected via addFilePatch 166 + ./patches/deps_patches.patch 167 + (addFilePatch { 168 + path = "b/third_party/rules_python.patch"; 169 + file = replaceVars ./patches/rules_python.patch { 170 + usrBinEnv = "${coreutils}/bin/env"; 171 + }; 172 + }) 173 + (addFilePatch { 174 + path = "b/third_party/rules_java.patch"; 175 + file = replaceVars ./patches/rules_java.patch { 176 + defaultBash = "${defaultShell.bashWithDefaultShellUtils}/bin/bash"; 177 + }; 178 + }) 179 + # Suggested for upstream in https://github.com/bazelbuild/bazel/pull/25936 180 + ./patches/build_execlog_parser.patch 181 + # Part of suggestion for upstream in https://github.com/bazelbuild/bazel/pull/25934 182 + ./patches/env_bash.patch 183 + # Suggested for upstream in https://github.com/bazelbuild/bazel/pull/25935 184 + ./patches/gen_completion.patch 185 + 186 + # --experimental_strict_action_env (which may one day become the default 187 + # see bazelbuild/bazel#2574) hardcodes the default 188 + # action environment to a non hermetic value (e.g. "/usr/local/bin"). 189 + # This is non hermetic on non-nixos systems. On NixOS, bazel cannot find the required binaries. 190 + # So we are replacing this bazel paths by defaultShellPath, 191 + # improving hermeticity and making it work in nixos. 192 + (replaceVars ./patches/strict_action_env.patch { 193 + strictActionEnvPatch = defaultShell.defaultShellPath; 194 + }) 195 + 196 + (replaceVars ./patches/default_bash.patch { 197 + defaultBash = "${defaultShell.bashWithDefaultShellUtils}/bin/bash"; 198 + }) 199 + 200 + (replaceVars ./patches/md5sum.patch { 201 + md5sum = "${coreutils}/bin/md5sum"; 202 + }) 203 + 204 + # Nix build sandbox can configure custom PATH but doesn't have 205 + # /usr/bin/env which is unfortunate https://github.com/NixOS/nixpkgs/issues/6227 206 + # and we need to do a silly patch 207 + (replaceVars ./patches/usr_bin_env.patch { 208 + usrBinEnv = "${coreutils}/bin/env"; 209 + }) 210 + 211 + # Provide default JRE for Bazel process by setting --server_javabase= 212 + # in a new default system bazelrc file 213 + (replaceVars ./patches/bazel_rc.patch { 214 + bazelSystemBazelRCPath = replaceVars ./system.bazelrc { 215 + serverJavabase = jdk_headless; 216 + }; 217 + }) 218 + ]; 219 + 220 + meta = with lib; { 221 + homepage = "https://github.com/bazelbuild/bazel/"; 222 + description = "Build tool that builds code quickly and reliably"; 223 + sourceProvenance = with sourceTypes; [ 224 + fromSource 225 + binaryBytecode # source bundles dependencies as jars 226 + ]; 227 + license = licenses.asl20; 228 + teams = [ lib.teams.bazel ]; 229 + mainProgram = "bazel"; 230 + platforms = lib.platforms.linux ++ lib.platforms.darwin; 231 + }; 232 + 233 + nativeBuildInputs = [ 234 + makeWrapper 235 + jdk_headless 236 + python3 237 + unzip 238 + which 239 + 240 + # Shell completion 241 + installShellFiles 242 + python3.pkgs.absl-py # Needed to build fish completion 243 + ] 244 + # Needed for execlog 245 + ++ lib.optional (!stdenv.hostPlatform.isDarwin) stdenv.cc 246 + ++ lib.optional (stdenv.hostPlatform.isDarwin) cctools.libtool; 247 + 248 + buildPhase = '' 249 + runHook preBuild 250 + export HOME=$(mktemp -d) 251 + 252 + # If EMBED_LABEL isn't set, it'd be auto-detected from CHANGELOG.md 253 + # and `git rev-parse --short HEAD` which would result in 254 + # "3.7.0- (@non-git)" due to non-git build and incomplete changelog. 255 + # Actual bazel releases use scripts/release/common.sh which is based 256 + # on branch/tag information which we don't have with tarball releases. 257 + # Note that .bazelversion is always correct and is based on bazel-* 258 + # executable name, version checks should work fine 259 + export EMBED_LABEL="${version}- (@non-git)" 260 + 261 + echo "Stage 1 - Running bazel bootstrap script" 262 + # Note: can't use lib.escapeShellArgs here because it will escape arguments 263 + # with = using single quotes. This is fine for command invocations, 264 + # but for string variable they become literal single quote chars, 265 + # compile.sh will not unquote them either and command will be invalid. 266 + export EXTRA_BAZEL_ARGS="${lib.strings.concatStringsSep " " commandArgs}" 267 + 268 + ${bash}/bin/bash ./compile.sh 269 + 270 + # XXX: get rid of this, or move it to another stage. 271 + # It is plain annoying when builds fail. 272 + echo "Stage 2 - Generate bazel completions" 273 + ${bash}/bin/bash ./scripts/generate_bash_completion.sh \ 274 + --bazel=./output/bazel \ 275 + --output=./output/bazel-complete.bash \ 276 + --prepend=./scripts/bazel-complete-header.bash \ 277 + --prepend=./scripts/bazel-complete-template.bash 278 + ${python3}/bin/python3 ./scripts/generate_fish_completion.py \ 279 + --bazel=./output/bazel \ 280 + --output=./output/bazel-complete.fish 281 + 282 + runHook postBuild 283 + ''; 284 + 285 + installPhase = '' 286 + runHook preInstall 287 + 288 + # Bazel binary contains zip archive, which contains text files and a jar 289 + # both of which can have store references that might be obscured to Nix 290 + # builder in packaged form, so we unpack and extract those references 291 + 292 + # Note: grep isn't necessarily 100% accurate, other approaches could be 293 + # to disassemble Jar (slow) or hardcode known references 294 + mkdir -p $out/nix-support 295 + INSTALL_BASE=$(./output/bazel --batch info install_base) 296 + find "$INSTALL_BASE" -type f -exec \ 297 + ${gnugrep}/bin/grep --text --only-matching --no-filename "$NIX_STORE/[^/]*" '{}' \; \ 298 + | sort -u >> $out/nix-support/depends 299 + 300 + mkdir -p $out/bin 301 + 302 + # official wrapper scripts that searches for $WORKSPACE_ROOT/tools/bazel if 303 + # it can’t find something in tools, it calls 304 + # $out/bin/bazel-{version}-{os_arch} The binary _must_ exist with this 305 + # naming if your project contains a .bazelversion file. 306 + cp ./scripts/packages/bazel.sh $out/bin/bazel 307 + versioned_bazel="$out/bin/bazel-${version}-${bazelSystem}-${bazelArch}" 308 + mv ./output/bazel "$versioned_bazel" 309 + wrapProgram "$versioned_bazel" --suffix PATH : ${defaultShell.defaultShellPath} 310 + 311 + mkdir $out/share 312 + cp ./output/parser_deploy.jar $out/share/parser_deploy.jar 313 + substitute ${./bazel-execlog.sh} $out/bin/bazel-execlog \ 314 + --subst-var out \ 315 + --subst-var-by runtimeShell ${runtimeShell} \ 316 + --subst-var-by binJava ${jdk_headless}/bin/java 317 + chmod +x $out/bin/bazel-execlog 318 + 319 + # shell completion files 320 + installShellCompletion --bash \ 321 + --name bazel.bash \ 322 + ./output/bazel-complete.bash 323 + installShellCompletion --zsh \ 324 + --name _bazel \ 325 + ./scripts/zsh_completion/_bazel 326 + installShellCompletion --fish \ 327 + --name bazel.fish \ 328 + ./output/bazel-complete.fish 329 + ''; 330 + 331 + postFixup = 332 + # verify that bazel binary still works post-fixup 333 + '' 334 + USE_BAZEL_VERSION=${version} $out/bin/bazel --batch info release 335 + ''; 336 + 337 + # Bazel binary includes zip archive at the end that `strip` would end up discarding 338 + stripExclude = [ "bin/.bazel-${version}-*-wrapped" ]; 339 + 340 + passthru = { 341 + tests = { 342 + inherit (callPackage ./examples.nix { }) cpp java rust; 343 + }; 344 + }; 345 + }
+18
pkgs/by-name/ba/bazel_8/patches/apple_cc_toolchain.patch
··· 1 + diff --git a/MODULE.bazel b/MODULE.bazel 2 + index b3dde1c838..a54bf8141d 100644 3 + --- a/MODULE.bazel 4 + +++ b/MODULE.bazel 5 + @@ -36,10 +36,10 @@ bazel_dep(name = "abseil-cpp", version = "20240722.0.bcr.2") 6 + bazel_dep(name = "rules_shell", version = "0.2.0") 7 + bazel_dep(name = "chicory", version = "1.1.0") 8 + 9 + -# Depend on apple_support first and then rules_cc so that the Xcode toolchain 10 + -# from apple_support wins over the generic Unix toolchain from rules_cc. 11 + -bazel_dep(name = "apple_support", version = "1.18.1") 12 + +# Not Depend on apple_support first and then rules_cc so that the Xcode toolchain 13 + +# from apple_support not wins over the generic Unix toolchain from rules_cc. 14 + bazel_dep(name = "rules_cc", version = "0.1.1") 15 + +bazel_dep(name = "apple_support", version = "1.18.1") 16 + 17 + # repo_name needs to be used, until WORKSPACE mode is to be supported in bazel_tools 18 + bazel_dep(name = "protobuf", version = "29.0", repo_name = "com_google_protobuf")
+13
pkgs/by-name/ba/bazel_8/patches/bazel_rc.patch
··· 1 + diff --git a/src/main/cpp/option_processor.cc b/src/main/cpp/option_processor.cc 2 + index 8f8f15685f..a7ae52d1e4 100644 3 + --- a/src/main/cpp/option_processor.cc 4 + +++ b/src/main/cpp/option_processor.cc 5 + @@ -56,7 +56,7 @@ OptionProcessor::OptionProcessor( 6 + : workspace_layout_(workspace_layout), 7 + startup_options_(std::move(default_startup_options)), 8 + parse_options_called_(false), 9 + - system_bazelrc_path_(BAZEL_SYSTEM_BAZELRC_PATH) {} 10 + + system_bazelrc_path_("@bazelSystemBazelRCPath@") {} 11 + 12 + OptionProcessor::OptionProcessor( 13 + const WorkspaceLayout* workspace_layout,
+28
pkgs/by-name/ba/bazel_8/patches/build_execlog_parser.patch
··· 1 + diff --git a/compile.sh b/compile.sh 2 + index 4712355d48..feec286704 100755 3 + --- a/compile.sh 4 + +++ b/compile.sh 5 + @@ -76,6 +76,13 @@ bazel_build "src:bazel_nojdk${EXE_EXT}" \ 6 + --host_platform=@platforms//host \ 7 + --platforms=@platforms//host \ 8 + || fail "Could not build Bazel" 9 + + 10 + +bazel_build src/tools/execlog:parser_deploy.jar \ 11 + + --action_env=PATH \ 12 + + --host_platform=@platforms//host \ 13 + + --platforms=@platforms//host \ 14 + + || fail "Could not build parser_deploy.jar" 15 + + 16 + bazel_bin_path="$(get_bazel_bin_path)/src/bazel_nojdk${EXE_EXT}" 17 + [ -e "$bazel_bin_path" ] \ 18 + || fail "Could not find freshly built Bazel binary at '$bazel_bin_path'" 19 + @@ -84,5 +91,8 @@ cp -f "$bazel_bin_path" "output/bazel${EXE_EXT}" \ 20 + chmod 0755 "output/bazel${EXE_EXT}" 21 + BAZEL="$(pwd)/output/bazel${EXE_EXT}" 22 + 23 + +cp "$(get_bazel_bin_path)/src/tools/execlog/parser_deploy.jar" output/ \ 24 + + || fail "Could not copy 'parser_deploy.jar' to 'output/" 25 + + 26 + clear_log 27 + display "Build successful! Binary is here: ${BAZEL}" 28 +
+56
pkgs/by-name/ba/bazel_8/patches/darwin_sleep.patch
··· 1 + diff --git a/src/main/native/darwin/sleep_prevention_jni.cc b/src/main/native/darwin/sleep_prevention_jni.cc 2 + index 67c35b201e..e50a58320e 100644 3 + --- a/src/main/native/darwin/sleep_prevention_jni.cc 4 + +++ b/src/main/native/darwin/sleep_prevention_jni.cc 5 + @@ -33,31 +33,13 @@ static int g_sleep_state_stack = 0; 6 + static IOPMAssertionID g_sleep_state_assertion = kIOPMNullAssertionID; 7 + 8 + int portable_push_disable_sleep() { 9 + - std::lock_guard<std::mutex> lock(g_sleep_state_mutex); 10 + - BAZEL_CHECK_GE(g_sleep_state_stack, 0); 11 + - if (g_sleep_state_stack == 0) { 12 + - BAZEL_CHECK_EQ(g_sleep_state_assertion, kIOPMNullAssertionID); 13 + - CFStringRef reasonForActivity = CFSTR("build.bazel"); 14 + - IOReturn success = IOPMAssertionCreateWithName( 15 + - kIOPMAssertionTypeNoIdleSleep, kIOPMAssertionLevelOn, reasonForActivity, 16 + - &g_sleep_state_assertion); 17 + - BAZEL_CHECK_EQ(success, kIOReturnSuccess); 18 + - } 19 + - g_sleep_state_stack += 1; 20 + - return 0; 21 + + // Unreliable, disable for now 22 + + return -1; 23 + } 24 + 25 + int portable_pop_disable_sleep() { 26 + - std::lock_guard<std::mutex> lock(g_sleep_state_mutex); 27 + - BAZEL_CHECK_GT(g_sleep_state_stack, 0); 28 + - g_sleep_state_stack -= 1; 29 + - if (g_sleep_state_stack == 0) { 30 + - BAZEL_CHECK_NE(g_sleep_state_assertion, kIOPMNullAssertionID); 31 + - IOReturn success = IOPMAssertionRelease(g_sleep_state_assertion); 32 + - BAZEL_CHECK_EQ(success, kIOReturnSuccess); 33 + - g_sleep_state_assertion = kIOPMNullAssertionID; 34 + - } 35 + - return 0; 36 + + // Unreliable, disable for now 37 + + return -1; 38 + } 39 + 40 + } // namespace blaze_jni 41 + diff --git a/src/main/native/darwin/system_suspension_monitor_jni.cc b/src/main/native/darwin/system_suspension_monitor_jni.cc 42 + index 3483aa7935..51782986ec 100644 43 + --- a/src/main/native/darwin/system_suspension_monitor_jni.cc 44 + +++ b/src/main/native/darwin/system_suspension_monitor_jni.cc 45 + @@ -83,10 +83,7 @@ void portable_start_suspend_monitoring() { 46 + // Register to receive system sleep notifications. 47 + // Testing needs to be done manually. Use the logging to verify 48 + // that sleeps are being caught here. 49 + - suspend_state.connect_port = IORegisterForSystemPower( 50 + - &suspend_state, &notifyPortRef, SleepCallBack, &notifierObject); 51 + - BAZEL_CHECK_NE(suspend_state.connect_port, MACH_PORT_NULL); 52 + - IONotificationPortSetDispatchQueue(notifyPortRef, queue); 53 + + // XXX: Unreliable, disable for now 54 + 55 + // Register to deal with SIGCONT. 56 + // We register for SIGCONT because we can't catch SIGSTOP.
+22
pkgs/by-name/ba/bazel_8/patches/default_bash.patch
··· 1 + diff --git a/src/main/java/com/google/devtools/build/lib/bazel/rules/BazelRuleClassProvider.java b/src/main/java/com/google/devtools/build/lib/bazel/rules/BazelRuleClassProvider.java 2 + index a982b782e1..d49b047074 100644 3 + --- a/src/main/java/com/google/devtools/build/lib/bazel/rules/BazelRuleClassProvider.java 4 + +++ b/src/main/java/com/google/devtools/build/lib/bazel/rules/BazelRuleClassProvider.java 5 + @@ -89,13 +89,13 @@ public class BazelRuleClassProvider { 6 + public boolean useStrictActionEnv; 7 + } 8 + 9 + - private static final PathFragment FALLBACK_SHELL = PathFragment.create("/bin/bash"); 10 + + private static final PathFragment FALLBACK_SHELL = PathFragment.create("@defaultBash@"); 11 + 12 + public static final ImmutableMap<OS, PathFragment> SHELL_EXECUTABLE = 13 + ImmutableMap.<OS, PathFragment>builder() 14 + .put(OS.WINDOWS, PathFragment.create("c:/msys64/usr/bin/bash.exe")) 15 + - .put(OS.FREEBSD, PathFragment.create("/usr/local/bin/bash")) 16 + - .put(OS.OPENBSD, PathFragment.create("/usr/local/bin/bash")) 17 + + .put(OS.FREEBSD, PathFragment.create("@defaultBash@")) 18 + + .put(OS.OPENBSD, PathFragment.create("@defaultBash@")) 19 + .put(OS.UNKNOWN, FALLBACK_SHELL) 20 + .buildOrThrow(); 21 + 22 +
+24
pkgs/by-name/ba/bazel_8/patches/deps_patches.patch
··· 1 + diff --git a/MODULE.bazel b/MODULE.bazel 2 + index b3dde1c838..b28efa6dba 100644 3 + --- a/MODULE.bazel 4 + +++ b/MODULE.bazel 5 + @@ -25,10 +25,18 @@ bazel_dep(name = "zstd-jni", version = "1.5.6-9") 6 + bazel_dep(name = "blake3", version = "1.5.1.bcr.1") 7 + bazel_dep(name = "zlib", version = "1.3.1.bcr.5") 8 + bazel_dep(name = "rules_java", version = "8.14.0") 9 + +single_version_override( 10 + + module_name = "rules_java", 11 + + patches = ["//third_party:rules_java.patch"], 12 + +) 13 + bazel_dep(name = "rules_graalvm", version = "0.11.1") 14 + bazel_dep(name = "rules_proto", version = "7.0.2") 15 + bazel_dep(name = "rules_jvm_external", version = "6.0") 16 + bazel_dep(name = "rules_python", version = "0.40.0") 17 + +single_version_override( 18 + + module_name = "rules_python", 19 + + patches = ["//third_party:rules_python.patch"], 20 + +) 21 + bazel_dep(name = "rules_testing", version = "0.6.0") 22 + bazel_dep(name = "googletest", version = "1.15.2", repo_name = "com_google_googletest") 23 + bazel_dep(name = "with_cfg.bzl", version = "0.6.0") 24 +
+22
pkgs/by-name/ba/bazel_8/patches/env_bash.patch
··· 1 + diff --git a/src/zip_files.sh b/src/zip_files.sh 2 + index 1422a6c659..920c1019d2 100755 3 + --- a/src/zip_files.sh 4 + +++ b/src/zip_files.sh 5 + @@ -1,4 +1,4 @@ 6 + -#!/bin/bash 7 + +#!/usr/bin/env bash 8 + 9 + # Copyright 2019 The Bazel Authors. All rights reserved. 10 + # 11 + 12 + diff --git a/src/package-bazel.sh b/src/package-bazel.sh 13 + index 56e94db400..2c614af6c2 100755 14 + --- a/src/package-bazel.sh 15 + +++ b/src/package-bazel.sh 16 + @@ -1,4 +1,4 @@ 17 + -#!/bin/bash 18 + +#!/usr/bin/env bash 19 + # 20 + # Copyright 2015 The Bazel Authors. All rights reserved. 21 + # 22 +
+26
pkgs/by-name/ba/bazel_8/patches/gen_completion.patch
··· 1 + diff --git a/scripts/generate_bash_completion.sh b/scripts/generate_bash_completion.sh 2 + index 778810570c..84d2d49a0d 100755 3 + --- a/scripts/generate_bash_completion.sh 4 + +++ b/scripts/generate_bash_completion.sh 5 + @@ -68,7 +68,7 @@ mkdir "${tempdir}/root" 6 + 7 + server_javabase_flag= 8 + [ -z "${javabase}" ] || server_javabase_flag="--server_javabase=${javabase}" 9 + -"${bazel}" --output_user_root="${tempdir}/root" ${server_javabase_flag} \ 10 + +"${bazel}" --batch --output_user_root="${tempdir}/root" ${server_javabase_flag} \ 11 + help completion >>"${tempdir}/output" 12 + 13 + [ -z "${append}" ] || cat ${append} >>"${tempdir}/output" 14 + diff --git a/scripts/generate_fish_completion.py b/scripts/generate_fish_completion.py 15 + index bafe28979f..a941d8f7f9 100644 16 + --- a/scripts/generate_fish_completion.py 17 + +++ b/scripts/generate_fish_completion.py 18 + @@ -102,7 +102,7 @@ class BazelCompletionWriter(object): 19 + 20 + def _get_bazel_output(self, args): 21 + return subprocess.check_output( 22 + - (self._bazel, '--output_user_root={}'.format(self._output_user_root)) + 23 + + (self._bazel, '--batch', '--output_user_root={}'.format(self._output_user_root)) + 24 + tuple(args), 25 + universal_newlines=True) 26 +
+22
pkgs/by-name/ba/bazel_8/patches/md5sum.patch
··· 1 + diff --git a/src/BUILD b/src/BUILD 2 + index f61b90738a..2c3a54d36c 100644 3 + --- a/src/BUILD 4 + +++ b/src/BUILD 5 + @@ -38,12 +38,12 @@ md5_cmd = "set -e -o pipefail && %s $(SRCS) | %s | %s > $@" 6 + }) + embedded_tools_target, 7 + outs = ["install_base_key" + suffix], 8 + cmd = select({ 9 + - "//src/conditions:darwin": md5_cmd % ("/sbin/md5", "/sbin/md5", "head -c 32"), 10 + - "//src/conditions:freebsd": md5_cmd % ("/sbin/md5", "/sbin/md5", "head -c 32"), 11 + + "//src/conditions:darwin": md5_cmd % ("@md5sum@", "@md5sum@", "head -c 32"), 12 + + "//src/conditions:freebsd": md5_cmd % ("@md5sum@", "@md5sum@", "head -c 32"), 13 + # We avoid using the `head` tool's `-c` option, since it does not exist 14 + # on OpenBSD. 15 + - "//src/conditions:openbsd": md5_cmd % ("/bin/md5", "/bin/md5", "dd bs=32 count=1"), 16 + - "//conditions:default": md5_cmd % ("md5sum", "md5sum", "head -c 32"), 17 + + "//src/conditions:openbsd": md5_cmd % ("@md5sum@", "@md5sum@", "dd bs=32 count=1"), 18 + + "//conditions:default": md5_cmd % ("@md5sum@", "@md5sum@", "head -c 32"), 19 + }), 20 + ) for suffix, embedded_tools_target in { 21 + "_jdk_allmodules": [":embedded_tools_jdk_allmodules"], 22 +
+11
pkgs/by-name/ba/bazel_8/patches/rules_java.patch
··· 1 + diff --git java/bazel/rules/java_stub_template.txt java/bazel/rules/java_stub_template.txt 2 + index 115b46e..56d2ff7 100644 3 + --- java/bazel/rules/java_stub_template.txt 4 + +++ java/bazel/rules/java_stub_template.txt 5 + @@ -1,4 +1,4 @@ 6 + -#!/usr/bin/env bash 7 + +#!@defaultBash@ 8 + # Copyright 2014 The Bazel Authors. All rights reserved. 9 + # 10 + # Licensed under the Apache License, Version 2.0 (the "License"); 11 +
+14
pkgs/by-name/ba/bazel_8/patches/rules_python.patch
··· 1 + diff --git python/private/runtime_env_toolchain.bzl python/private/runtime_env_toolchain.bzl 2 + --- python/private/runtime_env_toolchain.bzl 3 + +++ python/private/runtime_env_toolchain.bzl 4 + @@ -42,7 +42,7 @@ 5 + name = "_runtime_env_py3_runtime", 6 + interpreter = "//python/private:runtime_env_toolchain_interpreter.sh", 7 + python_version = "PY3", 8 + - stub_shebang = "#!/usr/bin/env python3", 9 + + stub_shebang = "#!@usrBinEnv@ python3", 10 + visibility = ["//visibility:private"], 11 + tags = ["manual"], 12 + ) 13 + 14 +
+13
pkgs/by-name/ba/bazel_8/patches/strict_action_env.patch
··· 1 + diff --git a/src/main/java/com/google/devtools/build/lib/bazel/rules/BazelRuleClassProvider.java b/src/main/java/com/google/devtools/build/lib/bazel/rules/BazelRuleClassProvider.java 2 + index a70b5559bc..10bdffe961 100644 3 + --- a/src/main/java/com/google/devtools/build/lib/bazel/rules/BazelRuleClassProvider.java 4 + +++ b/src/main/java/com/google/devtools/build/lib/bazel/rules/BazelRuleClassProvider.java 5 + @@ -466,7 +466,7 @@ public class BazelRuleClassProvider { 6 + // Note that --action_env does not propagate to the host config, so it is not a viable 7 + // workaround when a genrule is itself built in the host config (e.g. nested genrules). See 8 + // #8536. 9 + - return "/bin:/usr/bin:/usr/local/bin"; 10 + + return "@strictActionEnvPatch@"; 11 + } 12 + 13 + String newPath = "";
+37
pkgs/by-name/ba/bazel_8/patches/trim-last-argument-to-gcc-if-empty.patch
··· 1 + From 177b4720d6fbaa7fdd17e5e11b2c79ac8f246786 Mon Sep 17 00:00:00 2001 2 + From: "Wael M. Nasreddine" <wael.nasreddine@gmail.com> 3 + Date: Thu, 27 Jun 2019 21:08:51 -0700 4 + Subject: [PATCH] Trim last argument to gcc if empty, on Darwin 5 + 6 + On Darwin, the last argument to GCC is coming up as an empty string. 7 + This is breaking the build of proto_library targets. However, I was not 8 + able to reproduce with the example cpp project[0]. 9 + 10 + This commit removes the last argument if it's an empty string. This is 11 + not a problem on Linux. 12 + 13 + [0]: https://github.com/bazelbuild/examples/tree/master/cpp-tutorial/stage3 14 + --- 15 + tools/cpp/osx_cc_wrapper.sh.tpl | 6 +++++- 16 + 1 file changed, 5 insertions(+), 1 deletion(-) 17 + 18 + diff --git a/tools/cpp/osx_cc_wrapper.sh.tpl b/tools/cpp/osx_cc_wrapper.sh.tpl 19 + index 4c85cd9b6b..6c611e3d25 100644 20 + --- a/tools/cpp/osx_cc_wrapper.sh.tpl 21 + +++ b/tools/cpp/osx_cc_wrapper.sh.tpl 22 + @@ -53,7 +53,11 @@ done 23 + %{env} 24 + 25 + # Call the C++ compiler 26 + -%{cc} "$@" 27 + +if [[ ${*: -1} = "" ]]; then 28 + + %{cc} "${@:0:$#}" 29 + +else 30 + + %{cc} "$@" 31 + +fi 32 + 33 + function get_library_path() { 34 + for libdir in ${LIB_DIRS}; do 35 + -- 36 + 2.19.2 37 +
+33
pkgs/by-name/ba/bazel_8/patches/usr_bin_env.patch
··· 1 + diff --git a/src/zip_builtins.sh b/src/zip_builtins.sh 2 + index d78ca5526a..c7d8f251cc 100755 3 + --- a/src/zip_builtins.sh 4 + +++ b/src/zip_builtins.sh 5 + @@ -1,4 +1,4 @@ 6 + -#!/usr/bin/env bash 7 + +#!@usrBinEnv@ bash 8 + 9 + # Copyright 2020 The Bazel Authors. All rights reserved. 10 + # 11 + 12 + diff --git a/src/zip_files.sh b/src/zip_files.sh 13 + index 1422a6c659..4b1c221784 100755 14 + --- a/src/zip_files.sh 15 + +++ b/src/zip_files.sh 16 + @@ -1,4 +1,4 @@ 17 + -#!/usr/bin/env bash 18 + +#!@usrBinEnv@ bash 19 + 20 + # Copyright 2019 The Bazel Authors. All rights reserved. 21 + # 22 + 23 + diff --git a/src/package-bazel.sh b/src/package-bazel.sh 24 + index 56e94db400..65fef20988 100755 25 + --- a/src/package-bazel.sh 26 + +++ b/src/package-bazel.sh 27 + @@ -1,4 +1,4 @@ 28 + -#!/usr/bin/env bash 29 + +#!@usrBinEnv@ bash 30 + # 31 + # Copyright 2015 The Bazel Authors. All rights reserved. 32 + # 33 +
+31
pkgs/by-name/ba/bazel_8/patches/xcode.patch
··· 1 + diff --git a/scripts/bootstrap/compile.sh b/scripts/bootstrap/compile.sh 2 + index 1bad14cba7..d312fe08bb 100755 3 + --- a/scripts/bootstrap/compile.sh 4 + +++ b/scripts/bootstrap/compile.sh 5 + @@ -402,7 +402,7 @@ cp $OUTPUT_DIR/libblaze.jar ${ARCHIVE_DIR} 6 + # TODO(b/28965185): Remove when xcode-locator is no longer required in embedded_binaries. 7 + log "Compiling xcode-locator..." 8 + if [[ $PLATFORM == "darwin" ]]; then 9 + - run /usr/bin/xcrun --sdk macosx clang -mmacosx-version-min=10.13 -fobjc-arc -framework CoreServices -framework Foundation -o ${ARCHIVE_DIR}/xcode-locator tools/osx/xcode_locator.m 10 + + run @clangDarwin@ -mmacosx-version-min=10.13 -fobjc-arc -framework CoreServices -framework Foundation -o ${ARCHIVE_DIR}/xcode-locator tools/osx/xcode_locator.m 11 + else 12 + cp tools/osx/xcode_locator_stub.sh ${ARCHIVE_DIR}/xcode-locator 13 + fi 14 + diff --git a/tools/osx/BUILD b/tools/osx/BUILD 15 + index 0358fb0ffe..1e6eae1f33 100644 16 + --- a/tools/osx/BUILD 17 + +++ b/tools/osx/BUILD 18 + @@ -27,9 +27,9 @@ exports_files([ 19 + ]) 20 + 21 + DARWIN_XCODE_LOCATOR_COMPILE_COMMAND = """ 22 + - /usr/bin/xcrun --sdk macosx clang -mmacosx-version-min=10.13 -fobjc-arc -framework CoreServices \ 23 + - -framework Foundation -arch arm64 -arch x86_64 -Wl,-no_adhoc_codesign -Wl,-no_uuid -o $@ $< && \ 24 + - env -i codesign --identifier $@ --force --sign - $@ 25 + + @clangDarwin@ -mmacosx-version-min=10.13 -fobjc-arc -framework CoreServices \ 26 + + -framework Foundation -Wl,-no_adhoc_codesign -Wl,-no_uuid -o $@ $< && \ 27 + + @usrBinEnv@ @codesign@ --identifier $@ --force --sign - $@ 28 + """ 29 + 30 + genrule( 31 +
+4
pkgs/by-name/ba/bazel_8/system.bazelrc
··· 1 + startup --server_javabase=@serverJavabase@ 2 + 3 + # load default location for the system wide configuration 4 + try-import /etc/bazel.bazelrc