···208 # incapable of preventing system sleep, which is a small price to pay to
209 # guarantee that it will always run in any nix context.
210 #
0000211 # If you want to investigate the sandbox profile path,
212 # IORegisterForSystemPower can be allowed with
213 #
···224 ../trim-last-argument-to-gcc-if-empty.patch
225226 # XXX: This seems merged / not a real problem. See PR.
0227 # `java_proto_library` ignores `strict_proto_deps`
228 # https://github.com/bazelbuild/bazel/pull/16146
229 # ./strict_proto_deps.patch
···261 src = ../bazel_rc.patch;
262 bazelSystemBazelRCPath = bazelRC;
263 })
264- ] ++ lib.optional enableNixHacks ./nix-hacks.patch;
265-266-267- # Additional tests that check bazel’s functionality. Execute
268- #
269- # nix-build . -A bazel_7.tests
270- #
271- # in the nixpkgs checkout root to exercise them locally.
272- passthru.tests = callPackage ./tests.nix {
273- inherit Foundation bazel_self distDir repoCache runJdk;
274- };
275276- passthru.updater = throw "TODO";
277278 # Bazel starts a local server and needs to bind a local address.
279 __darwinAllowLocalNetworking = true;
280281 postPatch =
282 let
283-284 darwinPatches = ''
285 bazelLinkFlags () {
286 eval set -- "$NIX_LDFLAGS"
···376 -e 's!/bin/bash!${bash}/bin/bash!g' \
377 -e 's!shasum -a 256!sha256sum!g'
378379- ${bazelNixFlagsScript} > .bazelrc.nix
380- # export BAZELRC=$PWD/.bazelrc.nix
381- # export BAZEL_BOOTSTRAP_STARTUP_OPTIONS=""
382- # export DIST_BAZEL_ARGS=
383- #export EXTRA_BAZEL_ARGS="--rc_source=$PWD/.bazelrc.nix --announce_rc"
384-385 # Add compile options to command line.
386 # XXX: It would suit a bazelrc file better, but I found no way to pass it.
387 # It seems it is always ignored.
388 # Passing EXTRA_BAZEL_ARGS is tricky due to quoting.
389-390- #which javac
391- #printenv JAVA_HOME
392- #exit 0
393394 sedVerbose compile.sh \
395 -e "/bazel_build /a\ --copt=\"$(echo $NIX_CFLAGS_COMPILE | sed -e 's/ /" --copt=\"/g')\" \\\\" \
···409 -e "/bazel_build /a\ --extra_toolchains=@local_jdk//:all \\\\" \
410 -e "/bazel_build /a\ --toolchain_resolution_debug=@bazel_tools//tools/jdk:runtime_toolchain_type \\\\" \
411 -e "/bazel_build /a\ --sandbox_debug --verbose_failures \\\\" \
412- ${lib.optionalString isDarwin ''
413- -e "/bazel_build /a\ --cpu=${({aarch64-darwin = "darwin_arm64"; x86_64-darwin = "darwin_x86_64";}.${stdenv.hostPlatform.system})} \\\\" \''
414- }
415-416- #-e "/bazel_build /a\ --spawn_strategy=standalone \\\\" \
417-418419 # Also build parser_deploy.jar with bootstrap bazel
420 # TODO: Turn into a proper patch
···448 patchShebangs . >/dev/null
449 '';
450 in
451- lib.optionalString stdenv.hostPlatform.isDarwin darwinPatches
452- + genericPatches;
453454 buildInputs = [ buildJdk ] ++ defaultShellUtils;
455···528529 mkdir -p $out/bin
530531- # official wrapper scripts that searches for $WORKSPACE_ROOT/tools/bazel
532- # if it can’t find something in tools, it calls $out/bin/bazel-{version}-{os_arch}
533- # The binary _must_ exist with this naming if your project contains a .bazelversion
534- # file.
535 cp ./bazel_src/scripts/packages/bazel.sh $out/bin/bazel
536 wrapProgram $out/bin/bazel $wrapperfile --suffix PATH : ${defaultShellPath}
537 mv ./bazel_src/output/bazel $out/bin/bazel-${version}-${system}-${arch}
···616 dontStrip = true;
617 dontPatchELF = true;
618619- passthru.repoCache = repoCache;
620- passthru.distDir = distDir;
000000000000621}
···208 # incapable of preventing system sleep, which is a small price to pay to
209 # guarantee that it will always run in any nix context.
210 #
211+ # See also ./bazel_darwin_sandbox.patch in bazel_5. That patch uses
212+ # NIX_BUILD_TOP env var to conditionnally disable sleep features inside the
213+ # sandbox. Oddly, bazel_6 does not need that patch :-/.
214+ #
215 # If you want to investigate the sandbox profile path,
216 # IORegisterForSystemPower can be allowed with
217 #
···228 ../trim-last-argument-to-gcc-if-empty.patch
229230 # XXX: This seems merged / not a real problem. See PR.
231+ # TODO: Remove when protobuf tests confirm it is not needed.
232 # `java_proto_library` ignores `strict_proto_deps`
233 # https://github.com/bazelbuild/bazel/pull/16146
234 # ./strict_proto_deps.patch
···266 src = ../bazel_rc.patch;
267 bazelSystemBazelRCPath = bazelRC;
268 })
269+ ]
270+ # See enableNixHacks argument above.
271+ ++ lib.optional enableNixHacks ./nix-hacks.patch;
000000002720273274 # Bazel starts a local server and needs to bind a local address.
275 __darwinAllowLocalNetworking = true;
276277 postPatch =
278 let
0279 darwinPatches = ''
280 bazelLinkFlags () {
281 eval set -- "$NIX_LDFLAGS"
···371 -e 's!/bin/bash!${bash}/bin/bash!g' \
372 -e 's!shasum -a 256!sha256sum!g'
373000000374 # Add compile options to command line.
375 # XXX: It would suit a bazelrc file better, but I found no way to pass it.
376 # It seems it is always ignored.
377 # Passing EXTRA_BAZEL_ARGS is tricky due to quoting.
0000378379 sedVerbose compile.sh \
380 -e "/bazel_build /a\ --copt=\"$(echo $NIX_CFLAGS_COMPILE | sed -e 's/ /" --copt=\"/g')\" \\\\" \
···394 -e "/bazel_build /a\ --extra_toolchains=@local_jdk//:all \\\\" \
395 -e "/bazel_build /a\ --toolchain_resolution_debug=@bazel_tools//tools/jdk:runtime_toolchain_type \\\\" \
396 -e "/bazel_build /a\ --sandbox_debug --verbose_failures \\\\" \
000000397398 # Also build parser_deploy.jar with bootstrap bazel
399 # TODO: Turn into a proper patch
···427 patchShebangs . >/dev/null
428 '';
429 in
430+ lib.optionalString isDarwin darwinPatches + genericPatches;
0431432 buildInputs = [ buildJdk ] ++ defaultShellUtils;
433···506507 mkdir -p $out/bin
508509+ # official wrapper scripts that searches for $WORKSPACE_ROOT/tools/bazel if
510+ # it can’t find something in tools, it calls
511+ # $out/bin/bazel-{version}-{os_arch} The binary _must_ exist with this
512+ # naming if your project contains a .bazelversion file.
513 cp ./bazel_src/scripts/packages/bazel.sh $out/bin/bazel
514 wrapProgram $out/bin/bazel $wrapperfile --suffix PATH : ${defaultShellPath}
515 mv ./bazel_src/output/bazel $out/bin/bazel-${version}-${system}-${arch}
···594 dontStrip = true;
595 dontPatchELF = true;
596597+ passthru = {
598+ # Additional tests that check bazel’s functionality. Execute
599+ #
600+ # nix-build . -A bazel_7.tests
601+ #
602+ # in the nixpkgs checkout root to exercise them locally.
603+ tests = callPackage ./tests.nix {
604+ inherit Foundation bazel_self distDir repoCache runJdk;
605+ };
606+607+ updater = throw "TODO";
608+609+ inherit distDir repoCache;
610+ };
611}