Migrate to Bzlmod and add tool_target parameter for CLI tools#20
Merged
Migrate to Bzlmod and add tool_target parameter for CLI tools#20
Conversation
Move all repository rule invocations from WORKSPACE to MODULE.bazel using use_repo_rule (bzlmod-native). Remove --enable_workspace from .bazelrc since Bazel 8 defaults to bzlmod. Add optional tool_target attribute to all cloud rules (s3, gs, minio, b2) so users can point to a Bazel-managed CLI binary (e.g. @my_awscli//:aws) instead of requiring tools on $PATH. When unset, the existing $PATH lookup via repo_ctx.which() is preserved. Add .bcr/ templates (metadata, presubmit, source) for future Bazel Central Registry submission. Partially addresses PR #11. https://claude.ai/code/session_01AxVsJ3PcLBCmcUXAaLKZQk
Replace the per-rule-only tool_target approach with a module extension
(cloud_archive.configure) that lets consumers register CLI tool labels
once in their MODULE.bazel. All cloud_archive rules then automatically
use the configured binaries.
Resolution order: per-rule tool_target > module extension config > $PATH.
Example consumer usage:
cloud_archive = use_extension("@cloud_archive//:extensions.bzl", "cloud_archive")
cloud_archive.configure(s3 = "@my_awscli//:aws")
use_repo(cloud_archive, "cloud_archive_tools")
https://claude.ai/code/session_01AxVsJ3PcLBCmcUXAaLKZQk
Covers module extension setup, repository rule declaration, BUILD file consumption, attribute reference, and tool resolution. https://claude.ai/code/session_01AxVsJ3PcLBCmcUXAaLKZQk
Under bzlmod, repos registered via use_repo_rule get canonical names like _main~_repo_rules~<name> in the runfiles tree. Add an _rlocation helper that checks both the bare name and the bzlmod canonical name, as well as the runfiles manifest when available. https://claude.ai/code/session_01AxVsJ3PcLBCmcUXAaLKZQk
Replace the hand-rolled _rlocation helper with Bazel's official runfiles.bash library, which reads the _repo_mapping file and correctly translates apparent repo names to canonical names under bzlmod. Add the @bazel_tools//tools/bash/runfiles dep to the test. https://claude.ai/code/session_01AxVsJ3PcLBCmcUXAaLKZQk
This was referenced Apr 1, 2026
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR migrates the cloud_archive project from WORKSPACE-based dependency management to Bzlmod (MODULE.bazel), and adds support for specifying custom CLI tool binaries via a new
tool_targetparameter across all repository rules.Key Changes
Bzlmod Migration: Moved all repository rule definitions from
WORKSPACEtoMODULE.bazel, enabling the project to work with Bazel's modern module system--enable_workspaceflag from.bazelrcas it's no longer neededWORKSPACEfile minimal with just the workspace name declarationTool Target Parameter: Added optional
tool_targetattribute to all cloud provider rules (s3_archive,s3_file,gs_archive,gs_file,minio_archive,minio_file,b2_archive,b2_file)@my_awscli//:aws) instead of relying on tools in$PATH$PATHlookup if not specifiedRefactored Tool Resolution: Extracted tool resolution logic into
_resolve_tool()helper functionBCR Configuration: Added Bazel Central Registry metadata files for publishing
.bcr/metadata.template.json: Module metadata with homepage and maintainer info.bcr/presubmit.yml: CI configuration for verifying builds on Ubuntu and macOS.bcr/source.template.json: Source distribution configurationBuild Configuration: Updated
.gitignoreto trackMODULE.bazel.lockImplementation Details
The
_resolve_tool()function provides a unified interface for tool resolution:tool_targetis provided, it resolves the label to a path (triggering repository fetch)_PROVIDER_TOOL_NAMESmapping and searches$PATHAll cloud download functions now accept and pass through the
tool_targetparameter to enable this functionality.