Hermetic, multi-language builds for Buck2
buildrules is a set of Buck2 rules and a small command line. It builds a project from the files its native tools already use (Cargo.toml, Cargo.lock, package-lock.json), pins every toolchain by hash, and caches each dependency separately on any remote execution farm that speaks the REAPI protocol.
Note. buildrules is a v0 proof of concept. It builds for Linux x86_64 only. Actions run on a remote execution farm by default, or on your own machine if you opt in. The Rust, Node, Zig, C/C++ and Mojo rules exist; Python, macOS and Windows are planned. A release is a tagged source archive and the command line for three platforms, made automatically from
main. Every page says which parts are built and which are not.What it gives you #
- Lockfile-native. Your lockfile is the dependency list. buildrules does not keep a second one; it reads
Cargo.lockandpackage-lock.jsonand builds exactly what they say. See lockfile-native. - Your native tools keep working.
cargo build,cargo testandnpm testrun on the same files, with the same compiler version, as the Buck2 build. See native-tool parity. - Hermetic. The compiler, the Node.js runtime and the other tools are downloads pinned by sha256. An action has no
PATHand no host compiler, and the Node actions have no network. See hermetic pinned toolchains. - Per-dependency caching. Each registry crate compiles in its own action and each npm package is its own pinned download, so a remote cache can reuse everything a change did not touch. See per-crate caching.
- Remote by default, local on request. Actions run on a farm you connect with a gitignored
.buckconfig.local; no endpoint is ever written into a repository. Without a farm,-c buildrules_re.mode=localruns them on your machine with the same pinned toolchains. See remote execution.
Rule families #
| Family | Status | What exists |
|---|---|---|
| Rust | built | cargo_workspace and cargo_package, driven by Cargo.lock, one compile action per crate, with pinned Rust versions and CPU levels |
| Node | built | npm_package, npm_modules, tsc_check, tsc_build, jest_test, node_tree_test, node_tree_build and more, over a pinned Node.js |
| Zig | built | zig_exe, zig_test, zig_module, on a pinned Zig |
| C/C++ | built | a toolchain for the prelude's cxx_library and cxx_binary on a pinned Zig, plus symbol and glibc-floor gates |
| Mojo | built | mojo_package, on mopm, which decides what to build; buildrules runs it as cached actions |
| Python | planned | no rules yet |
A first look #
For a Rust workspace, this is the whole workflow. Getting started explains each step.
shell
buildrules init . --git https://github.com/komira-ai/buildrules --commit <40-hex commit>
buildrules cargo new crates/hello
buildrules sync
buck2 build //crates/hello:test //crates/hello:debug
buildrules checkA member's BUCK file is two lines, and buildrules writes it:
crates/hello/BUCK
load("//:buildrules.bzl", "cargo_package")
cargo_package(path = ".")Where to go next #
- Why buildrules: the argument, the design and what is not done.
- Getting started: set up a repository and build a crate.
- How to use it: the manual, with configuration and examples by language.
- Concepts: how the lockfile, the pins and the sync model fit together.
- Rules reference: every rule family and what is planned.
- CLI reference: commands, flags and exit codes.
- Remote execution: connect a farm.
- FAQ: limits and common questions.