Skip to content

Deployment and updates

The fleet is deployed with colmena 🡕: a single command builds and applies the configuration on one or more hosts, remotely, from the admin workstation.

Fenêtre de terminal
just apply <target> [action] # alias : a
  • target = hostname, pattern ('*'), list (a,b) or colmena tag (@server).
  • action = switch (default), boot, test or build.
CommandPurpose
just apply <target>Build + activate on the target(s)
just apply-localApply on the current machine (alias al)
just apply-verbose <target>Same as apply in trace mode (alias av)

Build confidence through action: each step is less risky than the next.

Fenêtre de terminal
just apply <host> build # downloads + compiles: 100% safe, nothing is activated
just apply <host> test # activates without switching: no generation, no boot
just apply <host> # switch: activates and creates a new generation

Progress from core to edge: deploy nodes in this order, to never cut off access to a node by the one preceding it.

Diagram

The system is pinned by flakes. Updating = refresh the inputs, then redeploy.

Fenêtre de terminal
just update-flake # updates dnf/ + root, commits the locks
just apply '*' # deploys the update

Two services combine to avoid recompiling or re-downloading derivations on each deployment.

ServiceRole
harmoniaServes the local /nix/store, signed, directly to hosts (LAN, or VPN if global).
nix-cachePer-zone nginx proxy that caches the public cache.nixos.org cache on the gateway.

A host queries these sources in the following priority order. The first fetch from the Internet is thus shared across the whole zone.

PrioritySourceScope
20zone harmoniaLAN, what the zone has compiled
35zone nix-cache proxyLAN, shared mirror of the public cache
40cache.nixos.org directlysafety net if the gateway is down
45global harmonialast resort, over the VPN

Fetching a package and building it are two distinct needs. The binary cache above covers the first. For the second, a powerful network host can take over the long compilations of an administration host.

Declare it with the build-farm feature:

etc/config.yaml
features: ["build-farm"]

Each administration host then adds it to its nix.buildMachines, connecting over SSH with the nix deployment account. Nothing else to configure: the key and the authorization are already in place across the whole fleet.