diff --git a/pkgs/development/tools/build-managers/bazel/bazel_7/bazel-repository-cache.nix b/pkgs/development/tools/build-managers/bazel/bazel_7/bazel-repository-cache.nix index 74aa49fae73f..8bb68e18c6ad 100644 --- a/pkgs/development/tools/build-managers/bazel/bazel_7/bazel-repository-cache.nix +++ b/pkgs/development/tools/build-managers/bazel/bazel_7/bazel-repository-cache.nix @@ -52,24 +52,26 @@ let # } let attrs = value.attributes; - entry = hash: urls: { + entry = hash: urls: name: { ${hash} = fetchurl { name = "source"; # just like fetch*, to get some deduplication inherit urls; sha256 = hash; passthru.sha256 = hash; + passthru.source_name = name; }; }; - insert = acc: hash: urls: - acc // entry (sanitize hash) (map sanitize urls); + insert = acc: hash: urls: name: + acc // entry (sanitize hash) (map sanitize urls) (sanitize name); accWithRemotePatches = lib.foldlAttrs - (acc: url: hash: insert acc hash [ url ]) + (acc: url: hash: insert acc hash [ url ] attrs.name) acc (attrs.remote_patches or { }); accWithNewSource = insert accWithRemotePatches (attrs.integrity or attrs.sha256) - (attrs.urls or [ attrs.url ]); + (attrs.urls or [ attrs.url ]) + attrs.name; in if builtins.isAttrs value && value ? attributes && (attrs ? sha256 || attrs ? integrity) @@ -86,7 +88,7 @@ let # TODO: Do not re-hash. Use nix-hash to convert hashes (drv: '' filename=$(basename "${lib.head drv.urls}") - echo Bundling $filename + echo Bundling $filename ${lib.optionalString (drv?source_name) "from ${drv.source_name}"} hash=$(${rnix-hashes}/bin/rnix-hashes --encoding BASE16 ${drv.sha256} | cut -f 2) mkdir -p content_addressable/sha256/$hash ln -sfn ${drv} content_addressable/sha256/$hash/file diff --git a/pkgs/development/tools/build-managers/bazel/bazel_7/default.nix b/pkgs/development/tools/build-managers/bazel/bazel_7/default.nix index bc857986b44d..97fee3a5e329 100644 --- a/pkgs/development/tools/build-managers/bazel/bazel_7/default.nix +++ b/pkgs/development/tools/build-managers/bazel/bazel_7/default.nix @@ -82,6 +82,15 @@ let null != builtins.match "rules_java~.*~toolchains~remote_java_tools" name; }; + # Two-in-one format + testRepoCache = callPackage ./bazel-repository-cache.nix { + inherit lockfile; + # We use the release tarball that already has everything bundled, + # But we need one extra dep required by our nonprebuilt java toolchains. + requiredDepNamePredicate = name: + null == builtins.match ".*(macos|osx|linux|win|apple|android).*" name; + }; + defaultShellUtils = # Keep this list conservative. For more exotic tools, prefer to use # @rules_nixpkgs to pull in tools from the nix repository. Example: @@ -331,7 +340,6 @@ stdenv.mkDerivation rec { done ''; - # -e "s,%{cc},${stdenv.cc}/bin/clang,g" \ genericPatches = '' # unzip builtins_bzl.zip so the contents get patched builtins_bzl=src/main/java/com/google/devtools/build/lib/bazel/rules/builtins_bzl @@ -611,11 +619,13 @@ stdenv.mkDerivation rec { # # in the nixpkgs checkout root to exercise them locally. tests = callPackage ./tests.nix { - inherit Foundation bazel_self distDir repoCache runJdk; + inherit Foundation bazel_self runJdk; + distDir = testRepoCache; + repoCache = testRepoCache; }; updater = throw "TODO"; - inherit distDir repoCache; + inherit distDir repoCache testRepoCache; }; }