bazel_7: address most review comments

+10 -48
+2 -5
pkgs/development/tools/build-managers/bazel/bazel_7/bazel-repository-cache.nix
··· 6 6 , lockfile 7 7 # A predicate used to select only some dependencies based on their name 8 8 , requiredDepNamePredicate ? _: true 9 - # Extra deps in the form of derivations producing a "single file" output path 10 - , extraDeps ? [ ] 11 9 , canonicalIds ? true 12 10 }: 13 11 let ··· 92 90 mkdir -p $out/content_addressable/sha256 93 91 cd $out 94 92 '' + lib.concatMapStrings 95 - # TODO: Do not re-hash. Use nix-hash to convert hashes 96 93 (drv: '' 97 94 filename=$(basename "${lib.head drv.urls}") 98 95 echo Bundling $filename ${lib.optionalString (drv?source_name) "from ${drv.source_name}"} 99 96 100 97 # 1. --repository_cache format: 101 - # 1.a. A file unde a content-hash directory 98 + # 1.a. A file under a content-hash directory 102 99 hash=$(${rnix-hashes}/bin/rnix-hashes --encoding BASE16 ${drv.sha256} | cut -f 2) 103 100 mkdir -p content_addressable/sha256/$hash 104 101 ln -sfn ${drv} content_addressable/sha256/$hash/file ··· 115 112 # This is brittle because of expected file name conflicts 116 113 ln -sn ${drv} $filename || true 117 114 '') 118 - (builtins.attrValues requiredDeps ++ extraDeps) 115 + (builtins.attrValues requiredDeps) 119 116 ; 120 117 121 118 repository_cache = runCommand "bazel-repository-cache" { } command;
+5 -40
pkgs/development/tools/build-managers/bazel/bazel_7/default.nix
··· 140 140 # on aarch64 Darwin, `uname -m` returns "arm64" 141 141 arch = with stdenv.hostPlatform; if isDarwin && isAarch64 then "arm64" else parsed.cpu.name; 142 142 143 - #build --extra_toolchains=@local_jdk//:all 144 - #build --tool_java_runtime_version=local_jdk 145 - #build --java_runtime_version=local_jdk 146 - #build --repo_env=JAVA_HOME=${buildJdk}${if isDarwin then "/zulu-11.jdk/Contents/Home" else "/lib/openjdk"} 147 - 148 143 bazelRC = writeTextFile { 149 144 name = "bazel-rc"; 150 145 text = '' ··· 223 218 # argument if it's found to be an empty string. 224 219 ../trim-last-argument-to-gcc-if-empty.patch 225 220 226 - # XXX: This seems merged / not a real problem. See PR. 227 - # TODO: Remove when protobuf tests confirm it is not needed. 228 - # `java_proto_library` ignores `strict_proto_deps` 229 - # https://github.com/bazelbuild/bazel/pull/16146 230 - # ./strict_proto_deps.patch 231 - 232 - # On Darwin, using clang 6 to build fails because of a linker error (see #105573), 233 - # but using clang 7 fails because libarclite_macosx.a cannot be found when linking 234 - # the xcode_locator tool. 235 - # This patch removes using the -fobjc-arc compiler option and makes the code 236 - # compile without automatic reference counting. Caveat: this leaks memory, but 237 - # we accept this fact because xcode_locator is only a short-lived process used during the build. 238 - ./no-arc.patch 239 - 240 221 # --experimental_strict_action_env (which may one day become the default 241 222 # see bazelbuild/bazel#2574) hardcodes the default 242 223 # action environment to a non hermetic value (e.g. "/usr/local/bin"). ··· 303 284 # nixpkgs's libSystem cannot use pthread headers directly, must import GCD headers instead 304 285 sed -i -e "/#include <pthread\/spawn.h>/i #include <dispatch/dispatch.h>" src/main/cpp/blaze_util_darwin.cc 305 286 306 - # clang installed from Xcode has a compatibility wrapper that forwards 307 - # invocations of gcc to clang, but vanilla clang doesn't 308 - sed -i -e 's;_find_generic(repository_ctx, "gcc", "CC", overriden_tools);_find_generic(repository_ctx, "clang", "CC", overriden_tools);g' tools/cpp/unix_cc_configure.bzl 309 - 310 - # This is necessary to avoid: 311 - # "error: no visible @interface for 'NSDictionary' declares the selector 312 - # 'initWithContentsOfURL:error:'" 313 - # This can be removed when the apple_sdk is upgraded beyond 10.13+ 314 - sedVerbose tools/osx/xcode_locator.m \ 315 - -e '/initWithContentsOfURL:versionPlistUrl/ { 316 - N 317 - s/error:nil\];/\];/ 318 - }' 319 - 287 + # XXX: What do these do ? 320 288 sed -i -e 's;"/usr/bin/libtool";_find_generic(repository_ctx, "libtool", "LIBTOOL", overriden_tools);g' tools/cpp/unix_cc_configure.bzl 321 289 wrappers=( tools/cpp/osx_cc_wrapper.sh.tpl ) 322 290 for wrapper in "''${wrappers[@]}"; do ··· 502 470 # $out/bin/bazel-{version}-{os_arch} The binary _must_ exist with this 503 471 # naming if your project contains a .bazelversion file. 504 472 cp ./bazel_src/scripts/packages/bazel.sh $out/bin/bazel 505 - wrapProgram $out/bin/bazel $wrapperfile --suffix PATH : ${defaultShellPath} 506 - mv ./bazel_src/output/bazel $out/bin/bazel-${version}-${system}-${arch} 473 + versionned_bazel="$out/bin/bazel-${version}-${system}-${arch}" 474 + mv ./bazel_src/output/bazel "$versionned_bazel" 475 + wrapProgram "$versionned_bazel" --suffix PATH : ${defaultShellPath} 507 476 508 477 mkdir $out/share 509 478 cp ./bazel_src/output/parser_deploy.jar $out/share/parser_deploy.jar ··· 525 494 ./bazel_src/output/bazel-complete.fish 526 495 ''; 527 496 528 - # Install check fails on `aarch64-darwin` 529 - # https://github.com/NixOS/nixpkgs/issues/145587 530 - doInstallCheck = false; #stdenv.hostPlatform.system != "aarch64-darwin"; 531 497 installCheckPhase = '' 532 498 export TEST_TMPDIR=$(pwd) 533 499 ··· 595 561 inherit Foundation bazel_self lockfile repoCache; 596 562 }; 597 563 598 - updater = throw "TODO"; 599 - 564 + # For ease of debugging 600 565 inherit distDir repoCache; 601 566 }; 602 567 }
+3 -3
pkgs/development/tools/build-managers/bazel/bazel_7/tests.nix
··· 158 158 vanilla = callBazelTests { }; 159 159 withNixHacks = callBazelTests { bazel = bazelWithNixHacks; }; 160 160 161 - # downstream packages using buildBazelPackage 162 - # fixed-output hashes of the fetch phase need to be spot-checked manually 161 + # add some downstream packages using buildBazelPackage 163 162 downstream = recurseIntoAttrs ({ 164 - inherit bazel-watcher; 163 + # TODO: fix bazel-watcher build with bazel 7, or find other packages 164 + #inherit bazel-watcher; 165 165 }); 166 166 } 167 167