LOOP · The DevOps Codex
Ch 03 · Build Systems & Artefacts
Chapter 03 · From Source to Artefact

Build Systems & Artefacts — deterministic outputs from deterministic inputs

A build system turns source code into runnable artefacts. The bad ones rebuild the world on every push and lie about reproducibility; the good ones compute a precise dependency graph, cache aggressively, and emit a signed bill of materials. This chapter compares the per-language and polyglot ecosystems, then dives into reproducibility, hermeticity, and registries.

3.1 · What a build system actually does

Definition. A build system is a directed-acyclic-graph evaluator that maps a set of input files and tools to a set of output artefacts, while reusing previously computed outputs whenever inputs are unchanged.

  • Graph — nodes are targets, edges are dependencies. Cycles are errors.
  • Cache — keyed by a hash of inputs + toolchain + flags. A cache hit skips work.
  • Parallelism — independent nodes run concurrently up to the configured worker count.
  • Reproducibility — same inputs → bit-identical outputs, regardless of when or where.
  • Incrementality — only the smallest sub-graph affected by a change is re-evaluated.
main.go util.go compile link app

3.2 · Per-language tools

LanguagePrimary tools (2026)Notes
C / C++Make, CMake, Meson, Ninja, xmakeCMake generates Ninja files; Ninja is the fast back-end.
JVMGradle 8.x, Maven 3.9+, Mill, sbtGradle has the strongest incremental + remote cache.
RustCargoWorkspaces, lockfile, optional sccache.
Gogo build, Go modulesBuilt-in cache at $GOCACHE.
JS / TSnpm, pnpm, yarn (Berry), Bunpnpm/yarn use content-addressed stores; Bun is the new fast runtime + installer.
.NETMSBuild, dotnet buildNuGet for packages; deterministic builds since .NET 5.
Scalasbt, Mill, Bleepsbt incremental compiler (Zinc) is the model.
Pythonuv (Astral), Poetry, Hatch, Rye, PDMuv (2024) is now the de-facto fast resolver/installer.
SwiftSwiftPM, XcodebuildBazel rules exist for very large iOS monorepos.

3.3 · Polyglot build tools

Definition. A polyglot build system handles multiple languages within one DAG, enabling cross-language dependencies, shared caching, and one BUILD definition language.

ToolOriginStrengthWatch out for
BazelGoogle (Blaze, 2015 OSS)Hermetic, remote cache, RBESteep onboarding, Starlark verbosity.
Buck2Meta (Rust rewrite, 2023 OSS)Faster than Buck1; remote executionSmaller ecosystem.
Pants 2Twitter origin → Toolchain Inc.Python-first polyglot, low boilerplateSmaller community than Bazel.
Please.buildThought MachineBazel-like, simplerNiche.
NxNrwl (2017)Best-in-class JS/TS monorepoJS-centric.
TurborepoVercelEasy ramp for JS/TS, remote cacheLess powerful graph than Nx/Bazel.
EarthlyEarthly Inc.Dockerfile + Makefile hybridContainer-overhead per step.
DaggerSolomon Hykes (post-Docker), 2022Programmable pipelines in Go/Python/TSNewer; engine in BuildKit.
Moon (moonrepo)OSS, 2022Modern monorepo orchestratorYounger ecosystem.

3.4 · Reproducible builds

Definition. A build is reproducible if anyone, given the same source code, build environment, and instructions, can recreate bit-for-bit identical copies of all artefacts.

  • SOURCE_DATE_EPOCH — an env var (reproducible-builds.org spec) used to pin timestamps embedded in archives, binaries, docs.
  • Pinned toolchains — exact compiler, linker, and stdlib versions; rustup-toolchain.toml, .tool-versions (asdf/mise).
  • Stable file ordering — sorted tarballs/zips; deterministic archive metadata (uid 0, gid 0).
  • Nix & Stagex — purely functional package managers that hash every input; the gold standard for reproducibility.
  • reproducible-builds.org — cross-distro project (Debian, Arch, Fedora, OpenSUSE) verifying their packages.
Why reproducibility matters for security: only a reproducible build lets independent parties confirm a binary came from the published source — a foundational defence against the SolarWinds-class supply-chain compromise.

3.5 · Hermetic builds

Definition. A hermetic build is one that depends only on declared inputs — no ambient network access, no host-system libraries, no time-of-day side effects.

TechniqueTool support
Sandboxed action execBazel sandbox, Buck2 sandbox, Nix sandbox
Vendored dependencies / lockfilesCargo, Go modules, pnpm, uv
Pinned toolchain in reporules_python, rules_go, rules_rust
Network disabled at build timeNix --offline, Bazel --experimental_repository_disable_download

3.6 · Build caches

The cache is what turns a 40-minute clean build into a 30-second incremental one. There are three layers:

  1. Local cache — $GOCACHE, ~/.gradle/caches, ~/.cache/bazel.
  2. Remote cache — shared between developers and CI: Bazel Remote Cache, Gradle Build Cache (Develocity), Turborepo Remote Cache, BuildBuddy, EngFlow, sccache, ccache.
  3. Remote execution (RBE) — actions run on a remote cluster; outputs streamed back. Bazel RBE, Buck2 RE, BuildBuddy, EngFlow.
# enable a remote cache for Bazel
build --remote_cache=grpcs://buildbuddy.io
build --remote_upload_local_results=true
build --bes_backend=grpcs://buildbuddy.io
build --bes_results_url=https://app.buildbuddy.io/invocation/

3.7 · Artefact registries

ArtefactCommon registries
Container / OCI imageDocker Hub, GHCR, Amazon ECR, Google Artifact Registry, Azure ACR, Quay, Harbor (self-hosted), Zot
JAR / MavenMaven Central, Sonatype Nexus, JFrog Artifactory, GitHub Packages, Cloudsmith
npmnpmjs.org, Verdaccio (self-hosted), Cloudsmith, Artifactory
PyPIPyPI.org, devpi, Cloudsmith, Artifactory
Helm charts, WASM, ML models, Cosign signaturesAny OCI-compatible registry (OCI 1.1 artefact spec, 2024)
Debian / RPMAptly, Pulp, Artifactory, Cloudsmith

3.8 · Artefact promotion

Definition. Promotion is the act of moving an immutable artefact through environments (dev → staging → prod) by changing its tags or metadata — never by rebuilding it.

Anti-pattern: rebuilding the same source for each environment. Different timestamps, different toolchain pulls, different attestations — and you've broken provenance.
  • Tag artefacts with immutable digests (e.g. sha256:…) not floating tags like latest.
  • Promotion is metadata + signature update only (Cosign, Notation).
  • Environments differ by config, not by build.

3.9 · BOMs and provenance

ConceptStandardTool examples
SBOM (Software Bill of Materials)SPDX (ISO/IEC 5962), CycloneDX (OWASP)Syft, Trivy, Microsoft SBOM Tool, cdxgen
Build provenanceSLSA v1.0 (2023, OpenSSF)GitHub Artifact Attestations, Sigstore Cosign, slsa-github-generator
Verifiable supply chainin-toto (CNCF graduated 2023)in-toto-attestation, witness
SignaturesSigstore / Cosign, Notation (CNCF), GPGcosign sign/verify, notation sign

SLSA levels (build track): L1 provenance exists → L2 signed by a hosted build service → L3 hardened, isolated builder → L4 two-party review + hermetic. See Ch 16 for the security chapter.

3.10 · Build observability

  • Develocity (formerly Gradle Enterprise) — build scans, performance hot-spots, remote cache analytics.
  • BuildBuddy & EngFlow — Bazel/Buck2 remote cache + RBE with deep timeline UIs.
  • BuildPulse, Trunk Flaky Tests, Datadog Test Optimisation — flakiness detection & quarantine.
  • OpenTelemetry CI/CD semantic conventions (2024 draft) — standard span/attribute names for builds.
Quick decision tree
  • Single language, small team → native tool (Cargo, Go, Maven, uv).
  • JS/TS monorepo → Nx or Turborepo.
  • Polyglot monorepo, > 100 engineers → Bazel or Buck2.
  • Need pipelines-as-code separate from CI vendor → Dagger or Earthly.
  • Strict reproducibility / supply-chain requirement → Nix or Stagex.

3.11 · Self-check

Q1 · What is the difference between a hermetic and a reproducible build?
They are synonyms.
Hermetic constrains the build environment; reproducible guarantees bit-identical outputs.
Hermetic is about caching; reproducible is about parallelism.
Reproducible builds require Nix; hermetic builds require Bazel.
Q2 · Which standard is the OWASP-maintained SBOM format?
SPDX
CycloneDX
in-toto
SLSA