Concepts

The ideas behind the rules, in the order you meet them. Each section says what is built today and what is not.

Lockfile-native #

The lockfile you already commit decides what is built. buildrules has no dependency list of its own and never resolves versions by itself.

Hermetic pinned toolchains #

Every tool a build action runs is an input of that action, downloaded by URL, sha256 and size from a table in the rules. A wrong hash or size fails the download. Actions have no PATH and inherit nothing from the worker.

ToolPinned asUsed by
Rust compiler, standard library, Cargo, clippy1.95.0 (the default) and 1.85.0 (the oldest supported), per component, from the official distribution; more with buildrules-pins.tomlRust rules, buildrules sync
Node.js24.21.0 (linux-x64), with the C++ runtime libraries it loads from pinned conda packagesNode rules
Zigpinned releases, 0.12.0 and 0.15.2Zig rules, the C/C++ toolchain, buildrules' own tools
busyboxa static build, 1.35.0the shell and file utilities that actions use

The Node actions run with an empty environment (a scratch HOME, UTC, no network) and the lockfile's packages unpacked with no install scripts. No host node, npm or compiler is read.

Limit. The farm still has to provide a Linux x86_64 kernel, glibc 2.34 or newer, libgcc_s.so.1 and libz.so.1 (the Rust compiler needs them; they are not pinned yet). Everything else comes from the pins.

rust-toolchain.toml is required #

A Rust repository must have a rust-toolchain.toml. sync and check fail without it. This is deliberate: it makes plain cargo (through rustup) and the Buck2 build use the same compiler, and it gives the build a version to compare with its pin.

Per-crate caching #

A Rust build is not one cargo build in a box. Each crate, registry or workspace, compiles in its own action, so a remote cache can reuse every crate a change did not touch.

Note. Caching works wherever the farm has an REAPI action cache. With only Buck2's local cache you still get correct builds, but not the sharing between machines.

The sync and check model #

Starlark cannot read TOML, so buildrules cannot read Cargo.toml while Buck2 loads a package. sync does it ahead of time and writes the result as data. The Buck2 macros read that data and never run Cargo.

FileWritten byPurpose
buildrules.lock.bzlsyncthe table: sha256 of Cargo.lock and each manifest, the compiler version, the policy, and one row per unit
buildrules.bzlsyncbinds the table to cargo_workspace and cargo_package; every BUCK file loads it
third_party/buildrules/BUCKsyncthe registry crates as units, with their source hashes
<member>/BUCKcargo new, init, adopttwo lines; never rewritten

A table that no longer matches Cargo's files is red, never silently used. There are three layers, from cheap to thorough:

Generated files say "Do not edit" in their first line. check fails on a hand-edited buildrules.bzl. A second sync on unchanged inputs writes the same bytes.

Native-tool parity #

Adopting buildrules does not take Cargo or npm away.

Some Cargo behavior is not reproduced yet:

Limits today #

shell
buildrules check   # exit 0: in sync; 1: stale or refused, with the fix printed; 2: usage