Skip to content

Commit

Permalink
bazel_7: Separate test deps (without binaries)
Browse files Browse the repository at this point in the history
  • Loading branch information
layus committed Dec 13, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent b09a742 commit 7051773
Showing 2 changed files with 21 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -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
16 changes: 13 additions & 3 deletions pkgs/development/tools/build-managers/bazel/bazel_7/default.nix
Original file line number Diff line number Diff line change
@@ -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;
};
}

0 comments on commit 7051773

Please sign in to comment.