···1-{ stdenv
02 # nix tooling and utilities
3-, callPackage
4-, lib
5-, fetchurl
6-, makeWrapper
7-, writeTextFile
8-, substituteAll
9-, writeShellApplication
10-, makeBinaryWrapper
011 # this package (through the fixpoint glass)
12-, bazel_self
013 # native build inputs
14-, runtimeShell
15-, zip
16-, unzip
17-, bash
18-, coreutils
19-, which
20-, gawk
21-, gnused
22-, gnutar
23-, gnugrep
24-, gzip
25-, findutils
26-, diffutils
27-, gnupatch
28-, file
29-, installShellFiles
30-, lndir
31-, python3
32 # Apple dependencies
33-, cctools
34-, libcxx
35-, sigtool
36-, CoreFoundation
37-, CoreServices
38-, Foundation
39-, IOKit
40 # Allow to independently override the jdks used to build and run respectively
41-, buildJdk
42-, runJdk
43 # Always assume all markers valid (this is needed because we remove markers; they are non-deterministic).
44 # Also, don't clean up environment variables (so that NIX_ environment variables are passed to compilers).
45-, enableNixHacks ? false
46-, version ? "7.1.2"
47}:
4849let
···5152 src = fetchurl {
53 url = "https://github.com/bazelbuild/bazel/releases/download/${version}/bazel-${version}-dist.zip";
54- hash = "sha256-nPbtIxnIFpGdlwFe720MWULNGu1I4DxzuggV2VPtYas=";
55- };
56-57- # Use builtins.fetchurl to avoid IFD, in particular on hydra
58- #lockfile = builtins.fetchurl {
59- # url = "https://raw.githubusercontent.com/bazelbuild/bazel/release-${version}/MODULE.bazel.lock";
60- # sha256 = "sha256-5xPpCeWVKVp1s4RVce/GoW2+fH8vniz5G1MNI4uezpc=";
61- #};
62- # Use a local copy of the above lockfile to make ofborg happy.
63- lockfile = ./MODULE.bazel.lock;
64-65- # Two-in-one format
66- distDir = repoCache;
67- repoCache = callPackage ./bazel-repository-cache.nix {
68- inherit lockfile;
69-70- # We use the release tarball that already has everything bundled so we
71- # should not need any extra external deps. But our nonprebuilt java
72- # toolchains hack needs just one non bundled dep.
73- requiredDepNamePredicate = name:
74- null != builtins.match "rules_java~.*~toolchains~remote_java_tools" name;
75 };
7677 defaultShellUtils =
···117 unzip
118 which
119 zip
0000000000000000120 ];
121000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000122 defaultShellPath = lib.makeBinPath defaultShellUtils;
123124 bashWithDefaultShellUtilsSh = writeShellApplication {
···174 inherit version src;
175 inherit sourceRoot;
176177- patches = [
178- # Remote java toolchains do not work on NixOS because they download binaries,
179- # so we need to use the @local_jdk//:jdk
180- # It could in theory be done by registering @local_jdk//:all toolchains,
181- # but these java toolchains still bundle binaries for ijar and stuff. So we
182- # need a nonprebult java toolchain (where ijar and stuff is built from
183- # sources).
184- # There is no such java toolchain, so we introduce one here.
185- # By providing no version information, the toolchain will set itself to the
186- # version of $JAVA_HOME/bin/java, just like the local_jdk does.
187- # To ensure this toolchain gets used, we can set
188- # --{,tool_}java_runtime_version=local_jdk and rely on the fact no java
189- # toolchain registered by default uses the local_jdk, making the selection
190- # unambiguous.
191- # This toolchain has the advantage that it can use any ambiant java jdk,
192- # not only a given, fixed version. It allows bazel to work correctly in any
193- # environment where JAVA_HOME is set to the right java version, like inside
194- # nix derivations.
195- # However, this patch breaks bazel hermeticity, by picking the ambiant java
196- # version instead of the more hermetic remote_jdk prebuilt binaries that
197- # rules_java provide by default. It also requires the user to have a
198- # JAVA_HOME set to the exact version required by the project.
199- # With more code, we could define java toolchains for all the java versions
200- # supported by the jdk as in rules_java's
201- # toolchains/local_java_repository.bzl, but this is not implemented here.
202- # To recover vanilla behavior, non NixOS users can set
203- # --{,tool_}java_runtime_version=remote_jdk, effectively reverting the
204- # effect of this patch and the fake system bazelrc.
205- ./java_toolchain.patch
0206207- # Bazel integrates with apple IOKit to inhibit and track system sleep.
208- # Inside the darwin sandbox, these API calls are blocked, and bazel
209- # crashes. It seems possible to allow these APIs inside the sandbox, but it
210- # feels simpler to patch bazel not to use it at all. So our bazel is
211- # incapable of preventing system sleep, which is a small price to pay to
212- # guarantee that it will always run in any nix context.
213- #
214- # See also ./bazel_darwin_sandbox.patch in bazel_5. That patch uses
215- # NIX_BUILD_TOP env var to conditionnally disable sleep features inside the
216- # sandbox.
217- #
218- # If you want to investigate the sandbox profile path,
219- # IORegisterForSystemPower can be allowed with
220- #
221- # propagatedSandboxProfile = ''
222- # (allow iokit-open (iokit-user-client-class "RootDomainUserClient"))
223- # '';
224- #
225- # I do not know yet how to allow IOPMAssertion{CreateWithName,Release}
226- ./darwin_sleep.patch
227228- # Fix DARWIN_XCODE_LOCATOR_COMPILE_COMMAND by removing multi-arch support.
229- # Nixpkgs toolcahins do not support that (yet?) and get confused.
230- # Also add an explicit /usr/bin prefix that will be patched below.
231- ./xcode_locator.patch
232233- # On Darwin, the last argument to gcc is coming up as an empty string. i.e: ''
234- # This is breaking the build of any C target. This patch removes the last
235- # argument if it's found to be an empty string.
236- ../trim-last-argument-to-gcc-if-empty.patch
237238- # --experimental_strict_action_env (which may one day become the default
239- # see bazelbuild/bazel#2574) hardcodes the default
240- # action environment to a non hermetic value (e.g. "/usr/local/bin").
241- # This is non hermetic on non-nixos systems. On NixOS, bazel cannot find the required binaries.
242- # So we are replacing this bazel paths by defaultShellPath,
243- # improving hermeticity and making it work in nixos.
244- (substituteAll {
245- src = ../strict_action_env.patch;
246- strictActionEnvPatch = defaultShellPath;
247- })
248249- # bazel reads its system bazelrc in /etc
250- # override this path to a builtin one
251- (substituteAll {
252- src = ../bazel_rc.patch;
253- bazelSystemBazelRCPath = bazelRC;
254- })
255- ]
256- # See enableNixHacks argument above.
257- ++ lib.optional enableNixHacks ./nix-hacks.patch;
258259 postPatch =
260 let
···339 -e 's!/bin/bash!${bashWithDefaultShellUtils}/bin/bash!g' \
340 -e 's!shasum -a 256!sha256sum!g'
341342- # Augment bundled repository_cache with our extra paths
343- ${lndir}/bin/lndir ${repoCache}/content_addressable \
344- $PWD/derived/repository_cache/content_addressable
345-346 # Add required flags to bazel command line.
347 # XXX: It would suit a bazelrc file better, but I found no way to pass it.
348 # It seems that bazel bootstrapping ignores it.
···350 sedVerbose compile.sh \
351 -e "/bazel_build /a\ --verbose_failures \\\\" \
352 -e "/bazel_build /a\ --curses=no \\\\" \
353- -e "/bazel_build /a\ --features=-layering_check \\\\" \
354- -e "/bazel_build /a\ --experimental_strict_java_deps=off \\\\" \
355- -e "/bazel_build /a\ --strict_proto_deps=off \\\\" \
356 -e "/bazel_build /a\ --toolchain_resolution_debug='@bazel_tools//tools/jdk:(runtime_)?toolchain_type' \\\\" \
357- -e "/bazel_build /a\ --tool_java_runtime_version=local_jdk_17 \\\\" \
358- -e "/bazel_build /a\ --java_runtime_version=local_jdk_17 \\\\" \
359- -e "/bazel_build /a\ --tool_java_language_version=17 \\\\" \
360- -e "/bazel_build /a\ --java_language_version=17 \\\\" \
361 -e "/bazel_build /a\ --extra_toolchains=@bazel_tools//tools/jdk:all \\\\" \
0000362363 # Also build parser_deploy.jar with bootstrap bazel
364 # TODO: Turn into a proper patch
···407 # Bazel starts a local server and needs to bind a local address.
408 __darwinAllowLocalNetworking = true;
409410- buildInputs = [ buildJdk bashWithDefaultShellUtils ] ++ defaultShellUtils;
000411412 # when a command can’t be found in a bazel build, you might also
413 # need to add it to `defaultShellPath`.
414- nativeBuildInputs = [
415- installShellFiles
416- makeWrapper
417- python3
418- unzip
419- which
420- zip
421- python3.pkgs.absl-py # Needed to build fish completion
422- ] ++ lib.optionals (stdenv.hostPlatform.isDarwin) [
423- cctools
424- libcxx
425- Foundation
426- CoreFoundation
427- CoreServices
428- ];
00429430 # Bazel makes extensive use of symlinks in the WORKSPACE.
431 # This causes problems with infinite symlinks if the build output is in the same location as the
···437 mkdir bazel_src
438 shopt -s dotglob extglob
439 mv !(bazel_src) bazel_src
00000440 '';
441 buildPhase = ''
442 runHook preBuild
443-444- # Increasing memory during compilation might be necessary.
445- # export BAZEL_JAVAC_OPTS="-J-Xmx2g -J-Xms200m"
446447 # If EMBED_LABEL isn't set, it'd be auto-detected from CHANGELOG.md
448 # and `git rev-parse --short HEAD` which would result in
···452 # Note that .bazelversion is always correct and is based on bazel-*
453 # executable name, version checks should work fine
454 export EMBED_LABEL="${version}- (@non-git)"
0455 echo "Stage 1 - Running bazel bootstrap script"
456 ${bash}/bin/bash ./bazel_src/compile.sh
457···554555 # Save paths to hardcoded dependencies so Nix can detect them.
556 # This is needed because the templates get tar’d up into a .jar.
557- postFixup = ''
558- mkdir -p $out/nix-support
559- echo "${defaultShellPath}" >> $out/nix-support/depends
560- # The string literal specifying the path to the bazel-rc file is sometimes
561- # stored non-contiguously in the binary due to gcc optimisations, which leads
562- # Nix to miss the hash when scanning for dependencies
563- echo "${bazelRC}" >> $out/nix-support/depends
564- '' + lib.optionalString stdenv.hostPlatform.isDarwin ''
565- echo "${cctools}" >> $out/nix-support/depends
566- '';
00567568 dontStrip = true;
569 dontPatchELF = true;
···571 passthru = {
572 # Additional tests that check bazel’s functionality. Execute
573 #
574- # nix-build . -A bazel_7.tests
575 #
576 # in the nixpkgs checkout root to exercise them locally.
577- tests = callPackage ./tests.nix {
578- inherit Foundation bazel_self lockfile repoCache;
579- };
00580581 # For ease of debugging
582- inherit distDir repoCache lockfile;
583 };
584}
···1+{
2+ stdenv,
3 # nix tooling and utilities
4+ lib,
5+ fetchurl,
6+ makeWrapper,
7+ writeTextFile,
8+ substituteAll,
9+ writeShellApplication,
10+ makeBinaryWrapper,
11+ autoPatchelfHook,
12+ buildFHSEnv,
13 # this package (through the fixpoint glass)
14+ # TODO probably still need for tests at some point
15+ bazel_self,
16 # native build inputs
17+ runtimeShell,
18+ zip,
19+ unzip,
20+ bash,
21+ coreutils,
22+ which,
23+ gawk,
24+ gnused,
25+ gnutar,
26+ gnugrep,
27+ gzip,
28+ findutils,
29+ diffutils,
30+ gnupatch,
31+ file,
32+ installShellFiles,
33+ lndir,
34+ python3,
35 # Apple dependencies
36+ cctools,
37+ libcxx,
38+ sigtool,
39+ CoreFoundation,
40+ CoreServices,
41+ Foundation,
42+ IOKit,
43 # Allow to independently override the jdks used to build and run respectively
44+ buildJdk,
45+ runJdk,
46 # Always assume all markers valid (this is needed because we remove markers; they are non-deterministic).
47 # Also, don't clean up environment variables (so that NIX_ environment variables are passed to compilers).
48+ enableNixHacks ? false,
49+ version ? "7.3.1",
50}:
5152let
···5455 src = fetchurl {
56 url = "https://github.com/bazelbuild/bazel/releases/download/${version}/bazel-${version}-dist.zip";
57+ hash = "sha256-8FAfkMn8dM1pM9vcWeF7jWJy1sCfi448QomFxYlxR8c=";
0000000000000000000058 };
5960 defaultShellUtils =
···100 unzip
101 which
102 zip
103+ runJdk
104+ makeWrapper
105+ ];
106+107+ # Bootstrap an existing Bazel so we can vendor deps with vendor mode
108+ bazel_bootstrap = stdenv.mkDerivation rec {
109+ name = "bazel_bootstrap";
110+ src = fetchurl {
111+ url = "https://github.com/bazelbuild/bazel/releases/download/${version}/bazel_nojdk-${version}-linux-x86_64";
112+ hash = "sha256-05fHtz47OilpOVYawB17VRVEDpycfYTIHBmwYCOyPjI=";
113+ };
114+115+ nativeBuildInputs = defaultShellUtils;
116+ buildInputs = [
117+ stdenv.cc.cc
118+ autoPatchelfHook
119 ];
120121+ dontUnpack = true;
122+ dontPatch = true;
123+ dontBuild = true;
124+ dontStrip = true;
125+ installPhase = ''
126+ runHook preInstall
127+128+ mkdir -p $out/bin
129+ install -Dm755 $src $out/bin/bazel
130+131+ runHook postInstall
132+ '';
133+134+ postFixup = ''
135+ wrapProgram $out/bin/bazel \
136+ --prefix PATH : ${lib.makeBinPath nativeBuildInputs}
137+ '';
138+ };
139+140+ # The bootstrapped Bazel did not work on its own for vendoring, but a wrapped FHS did
141+ bazel_fhs = buildFHSEnv {
142+ name = "bazel";
143+ targetPkgs = _: [ bazel_bootstrap ];
144+ runScript = "bazel";
145+ };
146+147+ # A FOD that vendors the Bazel dependencies using Bazel's new vendor mode.
148+ # See https://bazel.build/versions/7.3.0/external/vendor for details.
149+ # Note that it may be possible to vendor less than the full set of deps in
150+ # the future, as this is approximately 16GB.
151+ bazel_deps = stdenv.mkDerivation {
152+ name = "bazel_deps";
153+ src = fetchurl {
154+ url = "https://github.com/bazelbuild/bazel/releases/download/${version}/bazel-${version}-dist.zip";
155+ hash = "sha256-8FAfkMn8dM1pM9vcWeF7jWJy1sCfi448QomFxYlxR8c=";
156+ };
157+ inherit version;
158+ sourceRoot = ".";
159+ patches = [
160+ # The repo rule that creates a manifest of the bazel source for testing
161+ # the cli is not reproducible. This patch ensures that it is by sorting
162+ # the results in the repo rule rather than the downstream genrule.
163+ ./test_source_sort.patch
164+ ];
165+ patchFlags = [
166+ "--no-backup-if-mismatch"
167+ "-p1"
168+ ];
169+ nativeBuildInputs = [
170+ unzip
171+ bazel_fhs
172+ ];
173+ configurePhase = ''
174+ runHook preConfigure
175+176+ mkdir bazel_src
177+ shopt -s dotglob extglob
178+ mv !(bazel_src) bazel_src
179+ mkdir vendor_dir
180+181+ runHook postConfigure
182+ '';
183+ dontFixup = true;
184+ buildPhase = ''
185+ runHook preBuild
186+ export HOME=$TMP
187+ (cd bazel_src; ${bazel_fhs}/bin/bazel --server_javabase=${runJdk} mod deps --curses=no;
188+ ${bazel_fhs}/bin/bazel --server_javabase=${runJdk} vendor \
189+ --curses=no \
190+ --vendor_dir ../vendor_dir \
191+ --verbose_failures \
192+ --experimental_strict_java_deps=off \
193+ --strict_proto_deps=off \
194+ --tool_java_runtime_version=local_jdk_21 \
195+ --java_runtime_version=local_jdk_21 \
196+ --tool_java_language_version=21 \
197+ --java_language_version=21)
198+199+ # Some post-fetch fixup is necessary, because the deps come with some
200+ # baggage that is not reproducible. Luckily, this baggage does not factor
201+ # into the final product, so removing it is enough.
202+203+ # the GOCACHE is poisonous!
204+ rm -rf vendor_dir/gazelle~~non_module_deps~bazel_gazelle_go_repository_cache/gocache
205+206+ # so are .pyc files apparently
207+ find vendor_dir -name "*.pyc" -type f -delete
208+209+ runHook postBuild
210+ '';
211+212+ installPhase = ''
213+ mkdir -p $out/vendor_dir
214+ cp -r --reflink=auto vendor_dir/* $out/vendor_dir
215+ '';
216+217+ outputHashMode = "recursive";
218+ outputHash = "sha256-xW+KZIsOGrDV7WIcg/elHpFEmfs1TfFky3bVqCdWr9k=";
219+ outputHashAlgo = "sha256";
220+221+ };
222+223 defaultShellPath = lib.makeBinPath defaultShellUtils;
224225 bashWithDefaultShellUtilsSh = writeShellApplication {
···275 inherit version src;
276 inherit sourceRoot;
277278+ patches =
279+ [
280+ # Remote java toolchains do not work on NixOS because they download binaries,
281+ # so we need to use the @local_jdk//:jdk
282+ # It could in theory be done by registering @local_jdk//:all toolchains,
283+ # but these java toolchains still bundle binaries for ijar and stuff. So we
284+ # need a nonprebult java toolchain (where ijar and stuff is built from
285+ # sources).
286+ # There is no such java toolchain, so we introduce one here.
287+ # By providing no version information, the toolchain will set itself to the
288+ # version of $JAVA_HOME/bin/java, just like the local_jdk does.
289+ # To ensure this toolchain gets used, we can set
290+ # --{,tool_}java_runtime_version=local_jdk and rely on the fact no java
291+ # toolchain registered by default uses the local_jdk, making the selection
292+ # unambiguous.
293+ # This toolchain has the advantage that it can use any ambiant java jdk,
294+ # not only a given, fixed version. It allows bazel to work correctly in any
295+ # environment where JAVA_HOME is set to the right java version, like inside
296+ # nix derivations.
297+ # However, this patch breaks bazel hermeticity, by picking the ambiant java
298+ # version instead of the more hermetic remote_jdk prebuilt binaries that
299+ # rules_java provide by default. It also requires the user to have a
300+ # JAVA_HOME set to the exact version required by the project.
301+ # With more code, we could define java toolchains for all the java versions
302+ # supported by the jdk as in rules_java's
303+ # toolchains/local_java_repository.bzl, but this is not implemented here.
304+ # To recover vanilla behavior, non NixOS users can set
305+ # --{,tool_}java_runtime_version=remote_jdk, effectively reverting the
306+ # effect of this patch and the fake system bazelrc.
307+ ./java_toolchain.patch
308309+ # Bazel integrates with apple IOKit to inhibit and track system sleep.
310+ # Inside the darwin sandbox, these API calls are blocked, and bazel
311+ # crashes. It seems possible to allow these APIs inside the sandbox, but it
312+ # feels simpler to patch bazel not to use it at all. So our bazel is
313+ # incapable of preventing system sleep, which is a small price to pay to
314+ # guarantee that it will always run in any nix context.
315+ #
316+ # See also ./bazel_darwin_sandbox.patch in bazel_5. That patch uses
317+ # NIX_BUILD_TOP env var to conditionnally disable sleep features inside the
318+ # sandbox.
319+ #
320+ # If you want to investigate the sandbox profile path,
321+ # IORegisterForSystemPower can be allowed with
322+ #
323+ # propagatedSandboxProfile = ''
324+ # (allow iokit-open (iokit-user-client-class "RootDomainUserClient"))
325+ # '';
326+ #
327+ # I do not know yet how to allow IOPMAssertion{CreateWithName,Release}
328+ ./darwin_sleep.patch
329330+ # Fix DARWIN_XCODE_LOCATOR_COMPILE_COMMAND by removing multi-arch support.
331+ # Nixpkgs toolcahins do not support that (yet?) and get confused.
332+ # Also add an explicit /usr/bin prefix that will be patched below.
333+ ./xcode_locator.patch
334335+ # On Darwin, the last argument to gcc is coming up as an empty string. i.e: ''
336+ # This is breaking the build of any C target. This patch removes the last
337+ # argument if it's found to be an empty string.
338+ ../trim-last-argument-to-gcc-if-empty.patch
339340+ # --experimental_strict_action_env (which may one day become the default
341+ # see bazelbuild/bazel#2574) hardcodes the default
342+ # action environment to a non hermetic value (e.g. "/usr/local/bin").
343+ # This is non hermetic on non-nixos systems. On NixOS, bazel cannot find the required binaries.
344+ # So we are replacing this bazel paths by defaultShellPath,
345+ # improving hermeticity and making it work in nixos.
346+ (substituteAll {
347+ src = ../strict_action_env.patch;
348+ strictActionEnvPatch = defaultShellPath;
349+ })
350351+ # bazel reads its system bazelrc in /etc
352+ # override this path to a builtin one
353+ (substituteAll {
354+ src = ../bazel_rc.patch;
355+ bazelSystemBazelRCPath = bazelRC;
356+ })
357+ ]
358+ # See enableNixHacks argument above.
359+ ++ lib.optional enableNixHacks ./nix-hacks.patch;
360361 postPatch =
362 let
···441 -e 's!/bin/bash!${bashWithDefaultShellUtils}/bin/bash!g' \
442 -e 's!shasum -a 256!sha256sum!g'
4430000444 # Add required flags to bazel command line.
445 # XXX: It would suit a bazelrc file better, but I found no way to pass it.
446 # It seems that bazel bootstrapping ignores it.
···448 sedVerbose compile.sh \
449 -e "/bazel_build /a\ --verbose_failures \\\\" \
450 -e "/bazel_build /a\ --curses=no \\\\" \
000451 -e "/bazel_build /a\ --toolchain_resolution_debug='@bazel_tools//tools/jdk:(runtime_)?toolchain_type' \\\\" \
452+ -e "/bazel_build /a\ --tool_java_runtime_version=local_jdk_21 \\\\" \
453+ -e "/bazel_build /a\ --java_runtime_version=local_jdk_21 \\\\" \
454+ -e "/bazel_build /a\ --tool_java_language_version=21 \\\\" \
455+ -e "/bazel_build /a\ --java_language_version=21 \\\\" \
456 -e "/bazel_build /a\ --extra_toolchains=@bazel_tools//tools/jdk:all \\\\" \
457+ -e "/bazel_build /a\ --vendor_dir=../vendor_dir \\\\" \
458+ -e "/bazel_build /a\ --repository_disable_download \\\\" \
459+ -e "/bazel_build /a\ --announce_rc \\\\" \
460+ -e "/bazel_build /a\ --nobuild_python_zip \\\\" \
461462 # Also build parser_deploy.jar with bootstrap bazel
463 # TODO: Turn into a proper patch
···506 # Bazel starts a local server and needs to bind a local address.
507 __darwinAllowLocalNetworking = true;
508509+ buildInputs = [
510+ buildJdk
511+ bashWithDefaultShellUtils
512+ ] ++ defaultShellUtils;
513514 # when a command can’t be found in a bazel build, you might also
515 # need to add it to `defaultShellPath`.
516+ nativeBuildInputs =
517+ [
518+ installShellFiles
519+ makeWrapper
520+ python3
521+ unzip
522+ which
523+ zip
524+ python3.pkgs.absl-py # Needed to build fish completion
525+ ]
526+ ++ lib.optionals (stdenv.hostPlatform.isDarwin) [
527+ cctools
528+ libcxx
529+ Foundation
530+ CoreFoundation
531+ CoreServices
532+ ];
533534 # Bazel makes extensive use of symlinks in the WORKSPACE.
535 # This causes problems with infinite symlinks if the build output is in the same location as the
···541 mkdir bazel_src
542 shopt -s dotglob extglob
543 mv !(bazel_src) bazel_src
544+ # Augment bundled repository_cache with our extra paths
545+ mkdir vendor_dir
546+ ${lndir}/bin/lndir ${bazel_deps}/vendor_dir vendor_dir
547+ rm vendor_dir/VENDOR.bazel
548+ find vendor_dir -maxdepth 1 -type d -printf "pin(\"@@%P\")\n" > vendor_dir/VENDOR.bazel
549 '';
550 buildPhase = ''
551 runHook preBuild
552+ export HOME=$(mktemp -d)
00553554 # If EMBED_LABEL isn't set, it'd be auto-detected from CHANGELOG.md
555 # and `git rev-parse --short HEAD` which would result in
···559 # Note that .bazelversion is always correct and is based on bazel-*
560 # executable name, version checks should work fine
561 export EMBED_LABEL="${version}- (@non-git)"
562+563 echo "Stage 1 - Running bazel bootstrap script"
564 ${bash}/bin/bash ./bazel_src/compile.sh
565···662663 # Save paths to hardcoded dependencies so Nix can detect them.
664 # This is needed because the templates get tar’d up into a .jar.
665+ postFixup =
666+ ''
667+ mkdir -p $out/nix-support
668+ echo "${defaultShellPath}" >> $out/nix-support/depends
669+ # The string literal specifying the path to the bazel-rc file is sometimes
670+ # stored non-contiguously in the binary due to gcc optimisations, which leads
671+ # Nix to miss the hash when scanning for dependencies
672+ echo "${bazelRC}" >> $out/nix-support/depends
673+ ''
674+ + lib.optionalString stdenv.hostPlatform.isDarwin ''
675+ echo "${cctools}" >> $out/nix-support/depends
676+ '';
677678 dontStrip = true;
679 dontPatchELF = true;
···681 passthru = {
682 # Additional tests that check bazel’s functionality. Execute
683 #
684+ # nix-build . -A bazel_73.tests
685 #
686 # in the nixpkgs checkout root to exercise them locally.
687+ # tests = callPackage ./tests.nix {
688+ # inherit Foundation bazel_self lockfile repoCache;
689+ # };
690+ # TODO tests have not been updated yet and will likely need a rewrite
691+ # tests = callPackage ./tests.nix { inherit Foundation bazel_deps bazel_self; };
692693 # For ease of debugging
694+ inherit bazel_deps bazel_fhs;
695 };
696}