nix-meister: a builder VM for slop-broker #21

Open
opened 2026-11-28 18:18:18 +00:00 by slop-cannon · 0 comments

A VM on palace that takes over slop-broker's builds, with its own store on cellar's NVMe. This issue is the plan and its status. Keep the description current, and add progress as comments. When it's done, move the lasting facts into the box pages (a new one for nix-meister, plus palace, cellar and slop-broker), then close the issue.

Status

  • 1. Prepare the config on a branch
  • 2. Maintenance window (partition, cellar, palace, VF)
  • 3. Install nix-meister
  • 4. slop-broker change: copying from the builder's store (dev/slop-broker#15), released in 0.3.0 and pinned in #22. Running on palace, and tested there with the builder still local.
  • 5. Cut over
  • 6. Clean up

Why

  • slop deploy and slop build build in palace's own store: /nix is a 125G ext4 LV in the
    main thin pool on the 500 GB SATA SSD, 87G used. It's small and slow, and builds compete
    with palace's own system and its VMs' disks.
  • Those builds run agent-written Nix on the box that holds the deploy key. A VM moves them off
    it. Today only an nftables chain and a user without keys separate them.

palace's own /nix can't simply move to cellar's NVMe. palace hosts cellar, so the
disk doesn't exist until after palace has booted. The store has to belong to a VM that starts
after cellar, as slop-cannon's does.

Target layout

nix-meister
Host VM on palace in my.vms.instances, like slop-cannon
vCPUs 16c × 2t, overcommitted, with CPUWeight = 20 on vm@nix-meister, as nix-daemon has today
RAM 32 GiB; sfh drops from 32 to 16 GiB to make room (see Memory)
Disk New cellar export NVMeRaidp5, about 200 GiB, connected by palace and passed as a virtio disk (as slop-cannon-disk)
Network A new SR-IOV VF 6 on VLAN 120 (untrusted), added in the maintenance window (see Network)
Runs services.slop-broker-builder and its own nix-daemon; nothing else

Memory

palace has 128 GiB. The VMs now take 76 GiB (sfh 32, slop-cannon 24, cellar 16,
river 4), and builds may use up to MemoryMax = 40G of the rest.

  • sfh to 16 GiB. On 2026-11-28, after 6 days up, it used 5.8 GiB of 32 with 26 GiB
    available and no memory pressure (/proc/pressure/memory all zero). The hass container's
    27 GiB cgroup is almost all page cache (Frigate's recordings); unifi used 1.5 GiB. 16 GiB
    leaves about 10 GiB for cache. Look again just before the window.
  • With the builder at 32 GiB: 16 + 4 + 16 + 24 + 32 = 92 GiB of VMs, about 36 GiB for palace.
  • palace's nix-daemon limits (MemoryHigh/MemoryMax/CPUWeight in
    palace/slop-broker.nix) can go once
    agents' builds no longer run there.
  • vm@ units don't restart on deploy, so sfh's new size applies when it next starts, which
    is during the maintenance window anyway.

Disk

  • A new GPT partition p5 on NVMeRaid, following
    Adding an export. That needs every consumer down,
    including castle, so do it when castle is off.
  • Size: 200 GiB if the RAID has room after p1–p4 (check sgdisk -p in step 3 of that
    procedure). The builder needs the boxes' closures plus GC room, not palace's system.
  • Export: nqn.2016-06.io.spdk:nix-meister, serial SPDK00000000000005, hostnqn =
    palace's (my.nvme.uuid, the same as slop-cannon's: palace is the initiator for both).
  • On palace: a nix-meister-disk.service like slop-cannon-disk (await cellar, nvme connect with --ctrl-loss-tmo 60, udevadm wait for
    /dev/disk/by-id/nvme-SPDK_bdev_Controller_SPDK00000000000005, disconnect on stop).
    vm@nix-meister requires it, binds to it and starts after it.
  • palace's LVM filter ignores /dev/nvme* by every name since #19.
  • In the guest: an ordinary layout (ESP plus ext4 or an LVM /nix). Set nix.settings.min-free
    and max-free so the store collects its own garbage. GC roots for in-flight deploys are the
    builder's business, as now.

Network

VF 6 (44:00.7) on uplink-dave, VLAN 120 with MAC spoof checking, like slop-cannon's VF 5. The
routers then give it the Internet and nothing internal, as for slop-cannon, and palace needs
no NAT or forwarding rules.

  • Adding a VF resets them all. sriov_numvfs has to go to 0 before 7, which removes every
    VF, including cellar's VF 0. Do it at the end of the window, once cellar's new export is
    deployed: stop vm@cellar, change the count, start cellar, then the consumers. The udev rule
    in palace/default.nix only sets the count when
    the PF appears, so deploy the rule's 7 and set it by hand
    (echo 0 > …/sriov_numvfs; echo 7 > …/sriov_numvfs), or reboot palace instead.
  • Check the firmware's limit first (no downtime): cat /sys/bus/pci/devices/0000:44:00.0/sriov_totalvfs
    on palace. If it's 6, raising it is mlxconfig … set NUM_OF_VFS=… and a reboot of palace,
    which is a bigger window. Then fall back to a host-only tap on palace with NAT to the Internet
    only (the agent-builds chain's internalNets.nftReject applied to forwarded traffic).
  • The per-VF VLAN, spoof checking and carrier settings are applied on the PF along with the
    other VFs. Add VF 6 there and to the VF table.
  • It shares layer 2 with slop-cannon's agents. The broker's pinned host keys stop
    impersonation (StrictHostKeyChecking=accept-new, changed keys refused). The builder should
    only accept SSH from palace's address (and from the remote-build clients, if that happens).
    Dev settled on VLAN 120 rather than a VLAN of its own.
  • A static address in untrusted, outside both routers' DHCP pools, as an assignment like
    slop-cannon's. The broker reaches it on port 22.

slop-broker change (prerequisite for the cutover)

The broker copies what the builder built from its own store: nix copy --to ssh://<node> for
deploys, and --to ssh-ng://harmonia@object for slop build. With the builder's store in the VM,
both copy --from it instead. That streams through the broker without storing anything on
palace. Two alternatives were rejected:

  • Giving the builder the deploy key so it pushes itself. It runs agent-written Nix.
  • Using the VM as a remote build machine for palace's nix-daemon. Outputs would land back in
    palace's store.

Done in dev/slop-broker#15 (merged), released in 0.3.0.

  • No option: the broker always copies from
    ssh-ng://<builder.user>@<builder.hostname>:<port>?ssh-key=<broker key>. That's the same store
    while the builder is on palace, so it can ship before the cutover.
  • SSH options: builder.sshOpts may only be [ "-p" "<port>" ] (the module's default).
  • Forced command: the builder key's forced command serves nix-daemon --stdio, so the
    builder side needs no change beyond a release with it.

Steps

  1. Prepare the config on a branch (agent, no downtime).
    • cellar: the NVMeRaidp5 nvmfBdev entry in
      spdk.nix. Don't deploy it before
      the partition exists: spdk-tgt won't start with a config naming a missing bdev.
    • palace: nix-meister-disk.service, the VM instance (installerDisk too, for the
      install) with VF 6, the udev rule's VF count at 7 and VF 6's settings, sfh at 16 GiB.
    • Check sriov_totalvfs on palace (see Network).
    • The new box under nixos/boxes/home/palace/vms/, added to the configs list in
      flake.nix: services.slop-broker-builder (the configuration now in palace/slop-broker.nix,
      with the Gitea key moved to its secret), my.deploy.enable, SSH from palace only.
    • Leave services.slop-broker on palace pointing at the local builder until step 5.
    • check-system palace, check-system cellar, check-system nix-meister.
  2. Maintenance window (Dev or an agent with keys, from tower, with castle off).
    • Follow Adding an export steps 1–5 for p5.
    • Deploy cellar with the step 1 config, start spdk-tgt, and check the new bdev and
      subsystem (step 6 there).
    • Deploy palace. Its vm@ units don't restart.
    • Add the VF: stop vm@cellar, set sriov_numvfs to 0 then 7 (or reboot palace), and
      start vm@cellar and check its exports.
    • Start sfh (now 16 GiB), river and slop-cannon again as step 7 there says, and power
      castle back on.
  3. Install the builder VM (from tower). Start vm@nix-meister (it boots the installer
    ISO, since the disk is empty) and follow install-box.md. Then deploy it,
    check nix store ping and git ls-remote as slop-broker-build work, and that it can't reach
    internal networks (for example curl to a hi address fails).
  4. Release the slop-broker change and pin it here. Done: 0.3.0, pinned in #22.
  5. Cut over (one palace deploy plus a broker restart). services.slop-broker.deploy.builder
    gets hostname = nix-meister's address and sshOpts = [ "-p" "<its port>" ], and palace
    drops services.slop-broker-builder. Add nix-meister's
    host key to the broker's known_hosts first, or let accept-new take it on first use. Then slop deploy and slop build something small and check
    that the work happens in the VM (slop logs nix-meister nix-daemon.service).
  6. Clean up. Drop palace's nix-daemon limits and the agent-builds chain's
    slop-broker-build and nixbld rules, if nothing else builds there. Collect garbage on
    palace. Write the box page, update palace.md (VM table, disk section, slop-broker
    section), cellar.md (export table) and docs/slop-broker.md, and close this issue.

Later: a general remote builder

nix-meister could also take builds from Dev's own boxes (castle, tower) as a Nix remote
builder. Out of scope here; how it would work:

  • On nix-meister. A user for remote builds (nix.sshServe with write = true and
    protocol = "ssh-ng", or a plain user), with Dev's boxes' keys. It has to be in
    nix.settings.trusted-users: ssh-ng builds import the client's unsigned inputs.
  • On the clients. A small my.* module: nix.distributedBuilds = true, one
    nix.buildMachines entry (protocol = "ssh-ng", systems = [ "x86_64-linux" ], maxJobs,
    speedFactor, supportedFeatures = [ "nixos-test" "big-parallel" "kvm" "benchmark" ], with
    kvm working because palace has nested virtualisation), an age-secret key for root,
    programs.ssh.knownHosts for nix-meister, and builders-use-substitutes = true.
  • Reaching it. Boxes on hi/lo reach untrusted through the routers. tower would need a
    route when it's away (Tailscale or headscale).
  • Trust.
    • A trusted user can add any path to nix-meister's store, including fake outputs for
      derivations that a later slop deploy would reuse. So only keys that are already trusted
      with deploys (Dev's) may be trusted users there.
    • Agents (slop-cannon) must never be clients. Agents get builds there only through
      slop build.
    • The other direction is fine. Clients accept whatever nix-meister returns, but a
      compromised nix-meister already compromises deploys.
  • Contention. Dev's builds and agents' builds share its daemon and CPU weight. palace's VMs
    still win under contention.

Open questions

  • Whether sfh can go below 16 GiB.
  • Whether to make it a general remote builder (above), and for which boxes.
A VM on `palace` that takes over `slop-broker`'s builds, with its own store on `cellar`'s NVMe. This issue is the plan and its status. Keep the description current, and add progress as comments. When it's done, move the lasting facts into the box pages (a new one for `nix-meister`, plus [`palace`](https://git.nul.ie/dev/nixfiles/src/branch/master/docs/sites/home/palace.md), [`cellar`](https://git.nul.ie/dev/nixfiles/src/branch/master/docs/sites/home/cellar.md) and [`slop-broker`](https://git.nul.ie/dev/nixfiles/src/branch/master/docs/slop-broker.md)), then close the issue. ## Status - [ ] 1. Prepare the config on a branch - [ ] 2. Maintenance window (partition, `cellar`, `palace`, VF) - [ ] 3. Install `nix-meister` - [x] 4. slop-broker change: copying from the builder's store (dev/slop-broker#15), released in 0.3.0 and pinned in #22. Running on `palace`, and tested there with the builder still local. - [ ] 5. Cut over - [ ] 6. Clean up ## Why - `slop deploy` and `slop build` build in `palace`'s own store: `/nix` is a 125G ext4 LV in the `main` thin pool on the 500 GB SATA SSD, 87G used. It's small and slow, and builds compete with `palace`'s own system and its VMs' disks. - Those builds run agent-written Nix on the box that holds the deploy key. A VM moves them off it. Today only an nftables chain and a user without keys separate them. `palace`'s own `/nix` can't simply move to `cellar`'s NVMe. `palace` hosts `cellar`, so the disk doesn't exist until after `palace` has booted. The store has to belong to a VM that starts after `cellar`, as `slop-cannon`'s does. ## Target layout | | `nix-meister` | |---|---| | Host | VM on `palace` in `my.vms.instances`, like `slop-cannon` | | vCPUs | 16c × 2t, overcommitted, with `CPUWeight = 20` on `vm@nix-meister`, as `nix-daemon` has today | | RAM | 32 GiB; `sfh` drops from 32 to 16 GiB to make room (see [Memory](#memory)) | | Disk | New `cellar` export `NVMeRaidp5`, about 200 GiB, connected by `palace` and passed as a virtio disk (as `slop-cannon-disk`) | | Network | A new SR-IOV VF 6 on VLAN 120 (`untrusted`), added in the maintenance window (see [Network](#network)) | | Runs | `services.slop-broker-builder` and its own `nix-daemon`; nothing else | ### Memory `palace` has 128 GiB. The VMs now take 76 GiB (`sfh` 32, `slop-cannon` 24, `cellar` 16, `river` 4), and builds may use up to `MemoryMax = 40G` of the rest. - `sfh` to 16 GiB. On 2026-11-28, after 6 days up, it used 5.8 GiB of 32 with 26 GiB available and no memory pressure (`/proc/pressure/memory` all zero). The `hass` container's 27 GiB cgroup is almost all page cache (Frigate's recordings); `unifi` used 1.5 GiB. 16 GiB leaves about 10 GiB for cache. Look again just before the window. - With the builder at 32 GiB: 16 + 4 + 16 + 24 + 32 = 92 GiB of VMs, about 36 GiB for `palace`. - `palace`'s `nix-daemon` limits (`MemoryHigh`/`MemoryMax`/`CPUWeight` in [`palace/slop-broker.nix`](https://git.nul.ie/dev/nixfiles/src/branch/master/nixos/boxes/home/palace/slop-broker.nix)) can go once agents' builds no longer run there. - `vm@` units don't restart on deploy, so `sfh`'s new size applies when it next starts, which is during the maintenance window anyway. ### Disk - A new GPT partition `p5` on `NVMeRaid`, following [Adding an export](https://git.nul.ie/dev/nixfiles/src/branch/master/docs/sites/home/cellar.md#adding-an-export). That needs every consumer down, including `castle`, so do it when `castle` is off. - Size: 200 GiB if the RAID has room after `p1`–`p4` (check `sgdisk -p` in step 3 of that procedure). The builder needs the boxes' closures plus GC room, not `palace`'s system. - Export: `nqn.2016-06.io.spdk:nix-meister`, serial `SPDK00000000000005`, `hostnqn` = `palace`'s (`my.nvme.uuid`, the same as `slop-cannon`'s: `palace` is the initiator for both). - On `palace`: a `nix-meister-disk.service` like `slop-cannon-disk` (await `cellar`, `nvme connect` with `--ctrl-loss-tmo 60`, `udevadm wait` for `/dev/disk/by-id/nvme-SPDK_bdev_Controller_SPDK00000000000005`, disconnect on stop). `vm@nix-meister` requires it, binds to it and starts after it. - `palace`'s LVM filter ignores `/dev/nvme*` by every name since #19. - In the guest: an ordinary layout (ESP plus ext4 or an LVM `/nix`). Set `nix.settings.min-free` and `max-free` so the store collects its own garbage. GC roots for in-flight deploys are the builder's business, as now. ### Network VF 6 (`44:00.7`) on `uplink-dave`, VLAN 120 with MAC spoof checking, like `slop-cannon`'s VF 5. The routers then give it the Internet and nothing internal, as for `slop-cannon`, and `palace` needs no NAT or forwarding rules. - **Adding a VF resets them all.** `sriov_numvfs` has to go to 0 before 7, which removes every VF, including `cellar`'s VF 0. Do it at the end of the window, once `cellar`'s new export is deployed: stop `vm@cellar`, change the count, start `cellar`, then the consumers. The udev rule in [`palace/default.nix`](https://git.nul.ie/dev/nixfiles/src/branch/master/nixos/boxes/home/palace/default.nix) only sets the count when the PF appears, so deploy the rule's `7` and set it by hand (`echo 0 > …/sriov_numvfs; echo 7 > …/sriov_numvfs`), or reboot `palace` instead. - **Check the firmware's limit first** (no downtime): `cat /sys/bus/pci/devices/0000:44:00.0/sriov_totalvfs` on `palace`. If it's 6, raising it is `mlxconfig … set NUM_OF_VFS=…` and a reboot of `palace`, which is a bigger window. Then fall back to a host-only tap on `palace` with NAT to the Internet only (the `agent-builds` chain's `internalNets.nftReject` applied to forwarded traffic). - The per-VF VLAN, spoof checking and carrier settings are applied on the PF along with the other VFs. Add VF 6 there and to the [VF table](https://git.nul.ie/dev/nixfiles/src/branch/master/docs/sites/home/palace.md#connectx-4-vfs). - **It shares layer 2 with `slop-cannon`'s agents.** The broker's pinned host keys stop impersonation (`StrictHostKeyChecking=accept-new`, changed keys refused). The builder should only accept SSH from `palace`'s address (and from the remote-build clients, if that happens). Dev settled on VLAN 120 rather than a VLAN of its own. - A static address in `untrusted`, outside both routers' DHCP pools, as an assignment like `slop-cannon`'s. The broker reaches it on port 22. ### slop-broker change (prerequisite for the cutover) The broker copies what the builder built from its own store: `nix copy --to ssh://<node>` for deploys, and `--to ssh-ng://harmonia@object` for `slop build`. With the builder's store in the VM, both copy `--from` it instead. That streams through the broker without storing anything on `palace`. Two alternatives were rejected: - Giving the builder the deploy key so it pushes itself. It runs agent-written Nix. - Using the VM as a remote build machine for `palace`'s `nix-daemon`. Outputs would land back in `palace`'s store. Done in dev/slop-broker#15 (merged), released in 0.3.0. - **No option:** the broker always copies from `ssh-ng://<builder.user>@<builder.hostname>:<port>?ssh-key=<broker key>`. That's the same store while the builder is on `palace`, so it can ship before the cutover. - **SSH options:** `builder.sshOpts` may only be `[ "-p" "<port>" ]` (the module's default). - **Forced command:** the builder key's forced command serves `nix-daemon --stdio`, so the builder side needs no change beyond a release with it. ## Steps 1. **Prepare the config on a branch** (agent, no downtime). - `cellar`: the `NVMeRaidp5` `nvmfBdev` entry in [`spdk.nix`](https://git.nul.ie/dev/nixfiles/src/branch/master/nixos/boxes/home/palace/vms/cellar/spdk.nix). Don't deploy it before the partition exists: `spdk-tgt` won't start with a config naming a missing bdev. - `palace`: `nix-meister-disk.service`, the VM instance (`installerDisk` too, for the install) with VF 6, the udev rule's VF count at 7 and VF 6's settings, `sfh` at 16 GiB. - Check `sriov_totalvfs` on `palace` (see [Network](#network)). - The new box under `nixos/boxes/home/palace/vms/`, added to the `configs` list in `flake.nix`: `services.slop-broker-builder` (the configuration now in `palace/slop-broker.nix`, with the Gitea key moved to its secret), `my.deploy.enable`, SSH from `palace` only. - Leave `services.slop-broker` on `palace` pointing at the local builder until step 5. - `check-system palace`, `check-system cellar`, `check-system nix-meister`. 2. **Maintenance window** (Dev or an agent with keys, from `tower`, with `castle` off). - Follow [Adding an export](https://git.nul.ie/dev/nixfiles/src/branch/master/docs/sites/home/cellar.md#adding-an-export) steps 1–5 for `p5`. - Deploy `cellar` with the step 1 config, start `spdk-tgt`, and check the new bdev and subsystem (step 6 there). - Deploy `palace`. Its `vm@` units don't restart. - Add the VF: stop `vm@cellar`, set `sriov_numvfs` to 0 then 7 (or reboot `palace`), and start `vm@cellar` and check its exports. - Start `sfh` (now 16 GiB), `river` and `slop-cannon` again as step 7 there says, and power `castle` back on. 3. **Install the builder VM** (from `tower`). Start `vm@nix-meister` (it boots the installer ISO, since the disk is empty) and follow [`install-box.md`](https://git.nul.ie/dev/nixfiles/src/branch/master/docs/install-box.md). Then deploy it, check `nix store ping` and `git ls-remote` as `slop-broker-build` work, and that it can't reach internal networks (for example `curl` to a `hi` address fails). 4. **Release the slop-broker change** and pin it here. Done: 0.3.0, pinned in #22. 5. **Cut over** (one `palace` deploy plus a broker restart). `services.slop-broker.deploy.builder` gets `hostname` = `nix-meister`'s address and `sshOpts = [ "-p" "<its port>" ]`, and `palace` drops `services.slop-broker-builder`. Add `nix-meister`'s host key to the broker's `known_hosts` first, or let `accept-new` take it on first use. Then `slop deploy` and `slop build` something small and check that the work happens in the VM (`slop logs nix-meister nix-daemon.service`). 6. **Clean up.** Drop `palace`'s `nix-daemon` limits and the `agent-builds` chain's `slop-broker-build` and `nixbld` rules, if nothing else builds there. Collect garbage on `palace`. Write the box page, update `palace.md` (VM table, disk section, `slop-broker` section), `cellar.md` (export table) and `docs/slop-broker.md`, and close this issue. ## Later: a general remote builder `nix-meister` could also take builds from Dev's own boxes (`castle`, `tower`) as a Nix remote builder. Out of scope here; how it would work: - **On `nix-meister`.** A user for remote builds (`nix.sshServe` with `write = true` and `protocol = "ssh-ng"`, or a plain user), with Dev's boxes' keys. It has to be in `nix.settings.trusted-users`: `ssh-ng` builds import the client's unsigned inputs. - **On the clients.** A small `my.*` module: `nix.distributedBuilds = true`, one `nix.buildMachines` entry (`protocol = "ssh-ng"`, `systems = [ "x86_64-linux" ]`, `maxJobs`, `speedFactor`, `supportedFeatures = [ "nixos-test" "big-parallel" "kvm" "benchmark" ]`, with `kvm` working because `palace` has nested virtualisation), an age-secret key for root, `programs.ssh.knownHosts` for `nix-meister`, and `builders-use-substitutes = true`. - **Reaching it.** Boxes on `hi`/`lo` reach `untrusted` through the routers. `tower` would need a route when it's away (Tailscale or headscale). - **Trust.** - A trusted user can add any path to `nix-meister`'s store, including fake outputs for derivations that a later `slop deploy` would reuse. So only keys that are already trusted with deploys (Dev's) may be trusted users there. - Agents (`slop-cannon`) must never be clients. Agents get builds there only through `slop build`. - The other direction is fine. Clients accept whatever `nix-meister` returns, but a compromised `nix-meister` already compromises deploys. - **Contention.** Dev's builds and agents' builds share its daemon and CPU weight. `palace`'s VMs still win under contention. ## Open questions - Whether `sfh` can go below 16 GiB. - Whether to make it a general remote builder ([above](#later-a-general-remote-builder)), and for which boxes.
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: dev/nixfiles#21