infra_wiki

NixOS

The flake that builds each Linux host and OS image, the fleet baseline each host shares, and the daily upgrade from main.

NixOS builds the lab's general-purpose Linux hosts from Nix code. Kubernetes nodes run Talos Linux.

One flake builds the NixOS hosts, OS images and Nix-built packages. The registry, nix/hosts/default.nix, lists them.

Parts#

PartJobWhere it runs
RegistryLists each host, image and package. flake.nix derives its outputs from it.Evaluation
Fleet baselineThe modules each deployable host gets, in nix/profiles/fleet.nixEach host entry
sops-nixDecrypts host secrets with the SSH host keyHosts that import nix/system/sops.nix
NetbootServes x86 PXE boot and forge's signed RAM-boot imagespore
Talos bootServes folly's signed iPXE, HookOS and Talos ISO on the bootstrap VLANspore
KeaLeases folly's netboot pool and names the signed iPXE, through the gateway's relayspore
TinkerbellRuns folly's reprovisioning workflows and drives the nodes' BMCsspore
Build host and cacheCI builds and the Nix cachesGitHub Actions, Cachix and forge

Registry#

The header of nix/hosts/default.nix defines each field. kind sets the default baseline, and baseline overrides it, as in iso and netboot.

kindDefault baselineResult
hostFleet baseline, nix/profiles/fleet.nixA deployable system
imageImage baseline, nix/profiles/base.nixA built image, such as wsl
packageNoneA plain derivation, such as asterisk-image
  • A host turns off part of the fleet baseline with an explicit override, or with a homelab.fleet.* option that the image baseline declares.

Auto-upgrade#

A host with auto-upgrade rebuilds from main at 03:37 local time, up to an hour later at random, and switches without a reboot. A failed build keeps the running generation.

HostsAuto-upgradeSet in
Pi 4 hosts (microSD root)Offnix/hardware/pi4/default.nix
Pi Zero hostsOffnix/profiles/pi-zero.nix
Every other hostOnnix/system/nixos.nix

Rules#

  • If you deploy a host change from a branch, merge it before the next auto-upgrade, or the upgrade removes it.
  • Read addresses and names through nix/lib/networks.nix, nix/lib/anchor.nix and nix/lib/fleet.nix, which project the topology files. A copied value goes stale when the topology file changes.
  • A new host cannot decrypt its SOPS file until its SSH host key is a recipient, as Manage SOPS secrets describes.
  • Run mise run nix:check before a PR. It evaluates each configuration and runs the fleet assertions in nix/lib/checks.nix, and a failure fails nix-ci.

Where it lives#

  • nix/hosts/: the registry and one file per host
  • nix/profiles/, nix/hardware/, nix/system/ and nix/services/: baselines, board support, fleet modules and service modules
  • nix/images/: image modules
  • .github/workflows/nix-ci.yaml: the PR flake check and the builds on main

Edit on GitHub

↑↓ move ↵ open esc close