Skip to content

Configuration Overview

bz supports two types of configuration:

  1. TOML files - For persistent settings like network mode, cache directory, and registry URL
  2. Starlark files - For registry sync workflows (advanced feature)

Quick Start

Most users only need TOML configuration for basic settings:

~/.config/bz/config.toml
[network]
mode = "prefer-offline" # Use cache when available
[cache]
dir = "~/.cache/bz"

For registry sync workflows, use Starlark configuration in bz.star.

Configuration Types

TOML Configuration

Configure network mode, cache settings, and disabled commands. Used for everyday bz settings.

Learn more

Starlark Configuration

Define registry sync workflows with Starlark. Used for mirroring BCR to internal registries.

Learn more


TOML Configuration

TOML files configure bz’s runtime behavior. Files are loaded from multiple locations with later files overriding earlier ones.

File Locations

LocationPurpose
/etc/bz/config.tomlSystem-wide defaults
~/.config/bz/config.tomlUser preferences
.bz.tomlProject-specific settings

Example

[network]
mode = "prefer-offline"
registry = "https://bcr.bazel.build"
timeout = "30s"
[cache]
dir = "~/.cache/bz"
[commands]
disabled = []

Environment Variables

VariableDescription
BZ_OFFLINEEnable offline mode
BZ_PREFER_OFFLINEEnable prefer-offline mode
BZ_REGISTRYOverride registry URL
BZ_CACHE_DIROverride cache directory
BZ_DISABLE_COMMANDSDisable commands (comma-separated)

Full TOML documentation


Starlark Configuration

Starlark files (bz.star) define sync workflows for mirroring modules between registries. This is an advanced feature for organizations maintaining internal registries.

Basic Example

bz.star
bcr = registry.http("https://bcr.bazel.build")
mirror = registry.file("/path/to/mirror")
sync.workflow(
name = "sync-all",
origin = bcr,
destination = mirror,
modules = ["rules_go", "rules_python"],
)

Run with:

Terminal window
bz mod sync sync-all

Starlark Documentation

Starlark Basics

Learn the Starlark language basics for writing configurations.

Learn more

Registries

Configure source and destination registries.

Learn more

Publishers

Set up different publishing backends.

Learn more

Transforms

Transform modules as they sync.

Learn more


Configuration Precedence

All configuration is merged in this order (later overrides earlier):

  1. Built-in defaults
  2. System config (/etc/bz/config.toml)
  3. User config (~/.config/bz/config.toml)
  4. Project config (.bz.toml)
  5. Environment variables
  6. CLI flags