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 #

Rule families #

FamilyStatusWhat exists
Rustbuiltcargo_workspace and cargo_package, driven by Cargo.lock, one compile action per crate, with pinned Rust versions and CPU levels
Nodebuiltnpm_package, npm_modules, tsc_check, tsc_build, jest_test, node_tree_test, node_tree_build and more, over a pinned Node.js
Zigbuiltzig_exe, zig_test, zig_module, on a pinned Zig
C/C++builta toolchain for the prelude's cxx_library and cxx_binary on a pinned Zig, plus symbol and glibc-floor gates
Mojobuiltmojo_package, on mopm, which decides what to build; buildrules runs it as cached actions
Pythonplannedno 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 check

A 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 #