Per-UID design of herdr (Unix sockets, no HTTP) drove the home-manager
choice over a NixOS module — mirrors the existing opencode-web pattern.
- home/modules/herdr.nix: new systemd user service running
herdr 0.9.3 on sapphira, --session herdr-prod,
EnvironmentFile from sops opencode_server. 2G/4G cgroup caps,
Restart=always (mitigates herdr#4920).
- modules/server/nginx.nix: herdr.zeroq.su vhost with Authelia
forward-auth (wildcard *.zeroq.su policy already covers it).
Upstream 127.0.0.1:7317 is the Bun server from the
devswha/herdr-web-ui plugin (970star, MIT) — vhost 502s until
'herdr plugin install devswha/herdr-web-ui' runs.
- modules/server/coredns.nix: 192.168.1.20 herdr.zeroq.su A record.
- home/server.nix: import the new module.
Три предыдущие попытки (a807701, e6e82b8, переход на unitConfig) закрепляли
баг вместо того, чтобы его лечить: они писали
systemd.services.gitea-runner-ci-sapphira (обычный дефис) при том, что
upstream регистрирует юнит как
nameValuePair "gitea-runner-${escapeSystemdPath name}"
а escapeSystemdPath превращает '-' в литеральный '\x2d'. Обе формы
рендерятся в один файл gitea-runner-ci-sapphira.service, но это два
разных атрибута; неэкранированный создавал фантомный юнит без
ExecStart, фантом выигрывал рендер, и systemd отказывался стартовать
("Service has no ExecStart=... Refusing."). Юнит молчал 12 часов
(2026-10-14 16:25 .. 2026-10-15 01:23), при этом сборка проходила.
Правка:
- unitKey = "gitea-runner-ci\\x2dsapphira" — байт-в-байт с upstream.
- systemd.services.${unitKey} = { ... } вместо двух разных attrset'ов.
- assertions-растяжка: падает на отсутствии ExecStart, чтобы будущий
rename upstream'а сломал сборку, а не юнит.
- wants/after = lib.mkAfter [ nginx.service gitea.service ... ] — как
first-class опции, не через unitConfig (те молча терялись).
- serviceConfig.RestartSec = lib.mkForce "30s" — upstream даёт 2s,
что крутит журнал при задержке TLS; Restart=on-failure уже был от
upstream, его не трогаем.
Хранилище: storage-guard через ConditionPathIsMountPoint убран. У живого
раннера ноль дескрипторов на /mnt/services (cwd /var/lib/gitea-runner/
ci-sapphira на rootfs, workdir-parent /tmp, токен /var/lib/gitea-runner/
registration-token на rootfs) — гвард охранял пустое множество. Вместо
этого Wants+After на nginx.service + gitea.service: реальная зависимость,
а не фикция.
Wants, не Requires: After= означает "started", а не "serving" — TLS
ещё не провижен в момент старта nginx (acme-git.zeroq.su.service
срабатывает позже). Requires отменил бы наш start-job при сбое gitea, и
отменённый job не триггерит Restart. Wants пробует рано, Restart=on-
failure + RestartSec=30s даёт retry-петлю.
См. ADR-0004 / R1.14, закрывает задачу T18.
Проверено на sapphira после nixos-rebuild switch 2026-10-15T01:23:
- systemctl is-active: active
- nix eval attrNames: только gitea-runner-ci\x2dsapphira, фантома нет
- rendered unit: ExecStart=…/gitea-runner daemon, Wants=network-online.
target nginx.service gitea.service, After=…+nginx.service gitea.service,
Restart=on-failure, RestartSec=30s, ConditionPathIsMountPoint отсутствует
Фаза 06_METASTATE: рефреш бухгалтерского слоя.
Фазы manifest.json и checkpoints.json синхронизированы (analyse,
roadmap, decomposition, metastate теперь completed).
T4 (мёртвый storage-guard): notes переписан под 13/12, убрана ложная
рекомендация RequiresMountsFor, направление починки через unitConfig/
unit., ссылка на ADR-0004.
T15 (CI/pre-commit): ложное «.ci/checks.sh (executable)» заменено
на факт режима 100644 (см. T20).
T16 (E3, закомментированные модули): notes отражает современное
состояние (0 закомментированных, 12 в archive/server-modules/ + 3 в
archive/containers/ + stirling-pdf.nix удалён в 5dd7a58).
T19 (R1.14, из этого коммита): completed.
T20 (новый, pending, severity: high): .ci/checks.sh лежит в git с
режимом 100644, оба call-site (.github/workflows/nix-checks.yml:20
run: .ci/checks.sh; .pre-commit-config.yaml:10 entry: ... language:
script) зовут его как исполняемый — оба падают с permission denied.
Все три проверки T15 (:latest, nix flake check, sops path_regex)
ни разу не запускались, инварианты не защищены. Фикс тривиален
(chmod +x или bash .ci/checks.sh в обоих вызовах), но требует
осознанного решения — отсюда severity high.
ADR-0002 (backups external): status draft → accepted. Владелец так и
не ответил на 5.6, риск формализован как R1.9.
Удалён .agent/tasks/manifest.md — единственный источник истины
manifest.json.
checkpoints.json: known_doc_drift → resolved_doc_drift, добавлен
protocol_deviations (6.3 архивация пропущена осознанно; .agent/
requests/ никогда не существовало; 6.4/6.5/6.7/6.8 выполнены).
R1.2 (мёртвый storage-guard): mkStorageGuard возвращает только
ConditionPathIsMountPoint; RequiresMountsFor отсутствует намеренно
(создаёт dependency, по которой systemd сам монтирует ФС при старте
юнита и обессмысливает гвард — проверено 2026-10-10). Все потребители
передают ConditionPathIsMountPoint через serviceConfig → рендерится
в [Service], где systemd его не читает. Масштаб: 13 systemd-юнитов /
12 сервисов (postgresql, samba, homebox, gitea, navidrome, syncthing,
uptime-kuma, immich, nextcloud, calibre-web, 3x-ui, tape-rotation x2).
R1.14 (новый, из ADR-0004): имя systemd.services.<…> при переопределении
upstream-юнита должно побайтово совпадать с nameValuePair-ключом
модуля. Диагностировать юнит только чтением файла, не systemctl show.
R2: ссылка обновлена с opencode.nix:339 на :407; баг serviceConfig
отмечен как исправленный в c73a698, R2 удерживает от регрессии.
Ловушки (trap table):
- server/default.nix:37-50 — заменена: закомментированных импортов 0,
T16 завершена, архив 12+3+1.
- opencode.nix:339 — заменена: правильный паттерн на строке 407.
nextcloud.nix:73 → :80 (100.64.0.0 живёт там, не на :73).
Все правки зеркально продублированы в AGENTS.md (always-loaded
mirror).
Переопределяя systemd-юнит, который порождает upstream-модуль через
nameValuePair (например services.gitea-actions-runner), имя атрибута в
systemd.services.<…> должно побайтово совпадать с тем, что передаётся в
nameValuePair. escapeSystemdPath превращает '-' в литеральный '\x2d', что
для gitea-runner-ci-sapphira даёт ключ gitea-runner-ci\x2dsapphira (с
обратным слэшем). Обе формы рендерятся в один и тот же файл, но это
два разных атрибута; неэкранированный вариант создаёт фантомный юнит
без ExecStart, который выигрывает рендер — и systemd отказывается
стартовать. Юнит gitea-runner-ci-sapphira молчал 12 часов
(2026-10-14 16:25 → 2026-10-15 01:23).
Фикс — unitKey = "gitea-runner-ci\\x2dsapphira" плюс assertions-
растяжка в modules/server/gitea-runner.nix, которая валит сборку при
отсутствии ExecStart.
Этот же ADR формализует инвариант R1.14 (см. .agent/rules/project-rules.md).
Смежная находка: ConditionPathIsMountPoint в mkStorageGuard
(lib/xlib/helpers.nix:180-189) попадает в [Service] и игнорируется
systemd — задача T4 остаётся pending.
Fills in TOKEN with the value from Gitea's "Create new runner" admin
panel, completing the placeholder introduced when host-mode Actions was
enabled. Edited via `sops secrets/gitea-runner-registration.env`, so the
commit carries ciphertext only — the age recipient key stays outside
the repo.
The runner re-registers on its own: ExecStartPre compares the .runner
hash against TOKEN and re-runs registration when they diverge.
Reverts the plugin registration added in 4ff7188 ("opencode:
opencode-loop added"). The entry had to be dropped from both places
inside programs.opencode, otherwise the plugin keeps loading in the
TUI:
settings.plugin -> ~/.config/opencode/opencode.json
tui.plugin -> ~/.config/opencode/tui.json
oh-my-openagent is untouched; its agent and category overrides in
~/.omo/omo.jsonc still apply.
The NixOS gitea-actions-runner module sets StateDirectory to private/gitea-runner
(mode 700 in /var/lib/), so symlink /var/lib/gitea-runner -> private/gitea-runner
resolves into a root-only directory tree. The static gitea-runner user (uid 973)
cannot traverse that tree → mkdir within host.workdir_parent failed with EACCES.
Move workdir_parent to /var/lib/gitea-runner-work (sibling of the symlink,
no parent traversal through /var/lib/private). tmpfiles creates it owned
by gitea-runner with mode 0755.
Also still using rootfs to avoid the bind-mount RO issue that bit earlier.
Workflow runs at 16:04 and 16:11 failed at:
mkdir /mnt/services/gitea-runner-work/<id>: read-only file system
The bind mount /mnt/services occasionally flips RO during nixos-rebuild
activation (transient window while systemd re-creates .mount units). It's
back to RW a few seconds later (verified manually at 19:11 as uid 973),
but act_runner fails fast — by the time the unit retries the mount is
still in its intermittent state, and the job's mkdir dies.
Move workspace to /var/lib/gitea-runner/work (rootfs, always RW). 4 GiB
eMMC has plenty of room for short-lived job scratch dirs.
A two-trigger workflow — manual (workflow_dispatch) and on every push to
dev — that runs a single shell step on 'runs-on: native' to verify the
sapphira runner is healthy: hostname/whoami/pwd plus probes for the
common ZeroQ-workflow tools (nix, git, python3) and the act_runner
environment variables (RUNNER_NAME, RUNNER_TEMP).
Useful as a quick health check after any change to modules/server/
gitea-runner.nix, secrets/gitea-runner-registration.env, or after a
NixOS upgrade.
Nixpkgs's services.gitea-actions-runner.module uses EnvironmentFile=
instance.tokenFile; systemd reads KEY=VALUE lines, not YAML. The previous
key="registration_token" with format="yaml" produced /var/lib/gitea-runner/
registration-token as YAML, which systemd silently failed to parse — the
runner process received an empty $TOKEN and Gitea replied with
"runner registration token not found".
Switch to format="dotenv" and drop the key= parameter (dotenv has no key
concept, the file is one TOKEN=... line). The companion secret file is
renamed accordingly:
secrets/gitea-runner-registration.yaml → secrets/gitea-runner-registration.env
Verified at 2026-10-14 17:36 MSK on sapphira with token in place — register
+ declare succeed, runner shows up green in Gitea admin UI.
ServiceConfig-level leaf assignments (or a single lib.mkMerge block) into
systemd.services.gitea-runner-ci-sapphira.serviceConfig were silently
replacing Nixpkgs's services.gitea-actions-runner module output: the
generated unit came out without ExecStart / ExecStartPre / LoadCredential
/ User / Restart / RestartSec / StateDirectory, so systemd refused to
start the service ('Service has no ExecStart=... Refusing').
[Unit]-side overrides DO merge, so the storage guard (ConditionPathIsMountPoint
on xlib.dirs.server-home) and the local-fs.target After= are kept.
Cgroup caps (CPUQuota, MemoryMax, OOM knobs) are deferred — a follow-up
should add them via a systemd drop-in
(/etc/systemd/system/gitea-runner-ci\x2dsapphira.service.d/override.conf)
so the upstream ExecStart path stays intact.
Verified at 2026-10-14 17:36 MSK: register + declare succeed on sapphira
after this commit's deploy + a sops format fix (next commit).
Replace the manual `ip tuntap add` + `ip link set master` pattern in the
VM service with the standard `-netdev bridge,helper=...` approach. This
removes the bespoke tap lifecycle from the systemd script and uses
qemu's own bridge helper for TAP creation/teardown.
What changed in vm.nix:
- Added security.wrappers.qemu-bridge-helper: a setuid root wrapper
at /run/wrappers/bin/qemu-bridge-helper that execs the nixpkgs
binary (${pkgs.qemu}/libexec/qemu-bridge-helper).
- Added /etc/qemu/bridge.conf restricting the helper to the pxe0
bridge (single `allow pxe0` line).
- Added /run/wrappers/bin to the service PATH and `helper=` option
on -netdev bridge, so qemu finds the wrapper.
- Removed the tap creation in the script and the teardown in
postStop — qemu-bridge-helper handles both.
- Inlined `chmod 4755` on the wrapper at the top of the service
script. The security.wrappers activation script in this NixOS
version (qemu 11.1.1, edk2 202608) doesn't always apply the
setuid bit, leaving the wrapper at mode 0511 which makes the
helper fail to create the TAP. The inlined chmod is idempotent
and runs as root (system service). Remove this once upstream
NixOS is fixed.
Verified 2026-10-14 on rydiwo:
- direct mode: VM boots, tap0 (created by helper) attaches to
pxe0, all network up.
- pxe mode: iPXE chain works end-to-end through the bridge —
snp.efi -> autoexec.ipxe -> boot.ipxe (vmlinuz-virt Not found is
expected; /latest/ copies were cleaned up after the H_fix.1b
test).
T10 fix (autoexec.ipxe on TFTP root) is independent and already
committed (7c9a8d8 + syntax fix ae14fec). Closes T13.
Nix indented strings use \x27\x27 (two single quotes) as delimiters, not \x27\x27\x27
(three). The autoexec.ipxe block added in 7c9a8d8 used \x27\x27\x27 which
the parser rejects with "unexpected end of file, expecting indented
string or \x27${ or end of an indented string". Replacing with the
correct \x27\x27 makes both copies (this one and the home-manager
symlink target) parse cleanly and unblocks nixos-rebuild.
iPXE in UEFI mode looks for autoexec.ipxe on the same TFTP server it
was loaded from, and runs it as the boot script. Without it, the iPXE
instance that replaced the firmware PXE ROM has nothing to chain to
and ends up in No more network devices -> #GP.
This was the root cause of T10 (the iPXE 2.0.0 #GP with RIP 0x7EE8A5FC
or 0x7EC9456F depending on which point in the chain it crashed at).
Adding a 1-line autoexec.ipxe that chains to the HTTP-served boot.ipxe
makes the full chain work end-to-end: snp.efi -> autoexec.ipxe ->
boot.ipxe -> vmlinuz-virt+initramfs-virt -> kernel boot -> Alpine Init.
ipxe.nix: new environment.etc entry autoexec.ipxe via pkgs.writeText.
default.nix: tmpfiles rule symlinks it into the served TFTP root.
Verified 2026-10-14 on rydiwo with manual QEMU test (H_fix.1b):
snp.efi (iPXE 2.0.0) loaded, autoexec.ipxe found, HTTP boot.ipxe
fetched, kernel+initrd downloaded, handoff to firmware, Alpine Init
ran. No #GP. Detailed diagnostic in pxe-infra-automation
.agent/notes/T10-diagnostic-2026-10-14.md.
The default "direct" preserves the proven E2E behavior
(2026-10-13). "pxe" enables the full L3 boot chain
(-boot n, no virtio drive) for reproducing T10 (iPXE 2.0.0
#GP at ExitBootServices, RIP 0x7EE8A5FC) and verifying any
fix. Switch modes by editing pxe-infra.vm.bootMode in
configurations/rydiwo and running nixos-rebuild switch —
no other changes needed.
iPXE 2.0.0 reliably #GPs at RIP 0x7EE8A5FC (RAX=0xAF...AF) when handing off a 1-2 GB raw image back to the firmware under QEMU/OVMF, regardless of whether the boot primitive is sanboot, imgfetch+boot, or kernel+initrd+boot, regardless of iPXE binary (universal or snp-only), and regardless of VM memory (2G or 4G). The image itself is fine (kernel+initrd extract cleanly, BOOTX64.EFI is in the ESP, systemd-boot config is set up). The crash is in iPXE 2.0.0 `s exit-to-firmware path under this QEMU/OVMF combination.
Workaround: attach the Alpine worker image as a local virtio drive in the QEMU command line. The firmware (OVMF) finds BOOTX64.EFI in the image's ESP and boots the kernel from the image's ext4 partition. The network is still there (pxe0-tap, dnsmasq, nginx, report-sink), so the runner inside the guest can still POST to the report-sink and the VM can still talk to the L2/L3 services at runtime. The image attached is the same artifact nginx serves for the real PXE rig (the `latest` symlink at `artifacts.root/http/latest/`); deploy.sh keeps both paths in sync.
Refs: docs/ARCHITECTURE.md section L4.
All four attempts to sanboot the Alpine raw image through iPXE crash at the same RIP offset (0x35FC from the iPXE image base) regardless of memory (2G or 4G), iPXE binary (universal or snp-only), or image virtual size (2G or 1G). Common factor: all used sanboot to present the URL as a block device.
Replace boot.ipxe with iPXE's kernel/initrd/boot primitive. This bypasses sanboot and the SAN device creation path entirely. The kernel will fail to find a rootfs (no /dev/sda* is exposed) and panic — but kernel boot messages in the journal will tell us whether iPXE's kernel-initrd handoff works at all. If it does, the bug is isolated to the sanboot/SAN-device code path. If it also crashes, the bug is in shared iPXE code (HTTP download buffer management, probably).
The universal UEFI binary ipxe.efi (1.2 MB, all NIC drivers)
crashes at the same offset (0x35FC from the iPXE image
base) whether the VM has 2 GB or 4 GB of RAM, with
RAX = 0xAF...AF (iPXE uninit-memory fill). So this is not
OOM (the memory bump did not help) and not a NIC driver
issue (we use virtio-net, which the universal binary handles);
it is a deterministic bug somewhere in the sanboot/download
buffer path of the universal binary when the image is 2 GB.
snp.efi (310 KB, SNP-only — the driver virtio-net speaks)
is a separate iPXE build with a smaller code path: no UNDI,
no PXE prefix, no multi-NIC code. The same bug may not be
there, or the different code layout may avoid the bad
offset. Worth a try before reaching for GRUB or NFS root.
The opt-in is just bootloader.ipxeBinary = "snp.efi"; on
the pxe-infra attrset. The tmpfiles rule in
modules/pxe-infra/default.nix will symlink the new name
into the served TFTP root, and the next DHCP offer from
dnsmasq will hand it to the firmware.
iPXE's sanboot for an HTTP URL needs to hold the entire image
in its own heap. The raw Alpine image is 2 GB; with the
default 2 GB VM RAM, iPXE's allocator runs out around the
2 GB mark, leaves uninitialised 0xAF...AF fill in the
fresh pages, and the firmware's next read from that area
raises #GP at RIP 0x7EE855FC with RAX = 0xAF...AF.
Bumping pxe-infra.vm.memory to 4G gives iPXE roughly 2G of
heap for the download, which is exactly what a 2G image
needs. The rest goes to OVMF firmware and friends.
The previous run of imgfetch+boot crashed at RIP 0x7EE855FC in iPXE. iPXE was passing the full 2GB raw disk image to the firmware 'boot' primitive, which expects a UEFI PE executable (a small file with a PE header), not a 2GB block-device image. The firmware's PE loader hits uninitialised memory and the RIP-AF pattern reappears.
The earlier sanboot attempt also crashed, but that was before the systemd-boot fix gave the image a real \EFI\BOOT\BOOTX64.EFI. sanboot presents the URL as a block device, the firmware walks the GPT and finds the ESP, systemd-boot runs, and the kernel boots from the local ext4 partition. This is the right primitive for raw disk images served over HTTP.
Refs: docs/ARCHITECTURE.md section L4.
iPXE sanbooted the Alpine raw image and crashed with a #GP at RIP 0x7EE855FC, RAX=0xAF...AF — the AF pattern is the uninit-memory marker iPXE puts in block-device descriptors, which sanboot reads back. Splitting OVMF CODE+VARS did not change the RIP, which is in iPXE not OVMF, confirming the fault is on the iPXE side.
sanboot uses the legacy INT13 interface to present the URL as a disk; for a UEFI-only guest (B.6) the EFI firmware protocols are more direct. imgfetch downloads the (sparse, 159M actual) image into a memory block and boot invokes the EFI LoadImage/StartImage path on it, which is the same path the firmware would use for a normal disk boot. Removes the INT13 detour that was crashing.
Refs: docs/ARCHITECTURE.md section L4.
iPXE loaded boot.ipxe and tried to sanboot the Alpine raw image, but the firmware raised a #GP fault at RIP 0x7EC8B5FC with RAX=0xAF...AF. The AF pattern in RAX is a tell: it is the poisoned-memory value QEMU leaves in regions the firmware has not initialised. The combined OVMF.fd is read-only and carries no NVRAM region the firmware can write to, so ExitBootServices during the iPXE-to-image handoff cannot record its boot variables and the firmware crashes.
Switch to the split CODE+VARS form that nixpkgs ships: mount OVMF_CODE.fd read-only, seed a writable copy of OVMF_VARS.fd at /var/lib/pxe-infra/ovmf-vars.bin on first run, and pass it as a second pflash drive. iPXE can then write the chain target into NVRAM and the firmware hands off cleanly.
Refs: docs/ARCHITECTURE.md section L4.
The previous commit computed `dhcpRange` in the let-block
but never put it into the `base` attrset that becomes the
dnsmasq settings. The value was dead code, the rendered
conf had no dhcp-range line, dnsmasq still didnt open
dhcp-host and dhcp-range are different dnsmasq keys. The
free-pool lines from the optional rangeStart/rangeEnd options
were being concatenated into the dhcp-host list, which
dnsmasq rendered as
dhcp-host=52:54:00:12:34:56,10.66.0.10,pxe-vm-01,set:known
dhcp-host=10.66.0.100,10.66.0.200,12h
i.e. it would try to give IP 10.66.0.200 to the device whose
MAC is 10.66.0.100. Even worse, with no dhcp-range at all,
dnsmasq does not open its DHCP server socket — it only runs
TFTP. The UEFI firmware in the VM would send DISCOVER and
get nothing back, ending in PXE-E18: Server response
timeout.
Move the pool to its own list, with a sane
default (the entire /24 minus the host address) so the
server actually starts even when rangeStart/rangeEnd are
left null. The MAC filter (dhcp-ignore=tag:!known) still
prevents unknown MACs from getting a lease from the range.
Co-authored-by: Sisyphus <sisyphus@local>
By default invokes /etc/qemu-ifup
after opening the tap (and /etc/qemu-ifdown on shutdown).
That script does not exist on a stock NixOS install, and
QEMU fails with:
network script /etc/qemu-ifup failed with status 256
The pre-start already brings the tap up (ip link set … up)
and the postStop tears it down, so we tell QEMU not to
call out to /etc/qemu-if{up,down} via script=no,
downscript=no.
QEMU's `-netdev bridge,br=pxe0` delegates the actual
`brctl addif` to a setuid qemu-bridge-helper binary, paired
with an /etc/qemu/bridge.conf ACL file. The current nixpkgs
does not ship a NixOS module for installing that wrapper
(nixpkgs has qemu-guest-agent.nix — a different thing, the
in-VM guest agent) so the default is to fail with:
failed to parse default acl file /etc/qemu/bridge.conf
-netdev bridge,…: bridge helper failed
The standard workaround is the same pattern NixOS itself
uses in qemu-vm.nix for test VMs: create a tap device
before QEMU starts, attach it to the bridge ourselves (we
already have CAP_NET_ADMIN as root in the systemd unit),
and pass `-netdev tap,ifname=…` to QEMU. No helper needed.
- modules/pxe-infra/vm.nix: switch to `-netdev tap,
ifname=pxe0-tap`; pre-start script idempotently tears
down any leftover tap, creates a new one, and attaches
it to the configured bridge. `postStop` removes the tap
on every stop (including crashes / restart cycles).
- modules/pxe-infra/bridge.nix: drop the no-op
`services.qemuGuest.enable = true;` (option doesn't exist
in this nixpkgs).
nixpkgs OVMF.fd is a multi-output derivation whose outPath is
a *directory* containing FV/OVMF.fd (combined CODE+VARS),
FV/OVMF_CODE.fd, FV/OVMF_VARS.fd, and share/. QEMU needs a
regular file for -drive if=pflash,format=raw,readonly=on,
and rejected the directory with:
'file' driver requires '.../OVMF-202608-fd'
to be a regular file
Use the combined FV/OVMF.fd (4 MB, CODE+VARS in one).
Mounted read-only so the VM has no persistent NVRAM, which
is what we want for a fresh-every-run rig (docs/ARCHITECTURE.md
§L4). For proper NVRAM persistence across runs, the split
CODE+VARS form with a per-VM writable VARS file would be the
next step; not needed yet.
NixOS systemd module does not have a `wantedBefore` attribute
(it is a Unit-file directive, not a NixOS option). The
equivalent is `before = [ "dnsmasq.service" ]`, which says
"this unit is ordered to start before dnsmasq.service". The
previous value made nix flake check / nixos-rebuild fail
with:
error: The option
`systemd.services.pxe-infra-bridge.wantedBefore` does not exist.
Did you mean `systemd.services.pxe-infra-bridge.wantedBy`,
`systemd.services.pxe-infra-bridge.before` or
`systemd.services.pxe-infra-bridge.after`?
which surfaced when we tried to actually switch on the rig
after enabling pxe-infra in mini-laptop.nix.
The L1–L6 plumbing is now in place (oqyude/nixos@a940356 …
85953f9, pxe-infra-automation@15c8c3e), the L5 image is built
and staged at /var/lib/pxe-infra/http/574ccbe/alpine-worker.raw
with a `latest` symlink. Time to actually switch the rig on.
Per the user constraint ("VM is for script development
iteration, not permanent"), the L4 guest is configured but
NOT autostarted. The systemd unit exists; `systemctl start
pxe-infra-vm` brings the guest up for a test session, and
`systemctl stop` tears it down. The bridge, DHCP+TFTP, HTTP,
iPXE staging, and report sink all start on boot as expected.
After this lands, `ip a` should show `pxe0` with
10.66.0.1/24, `curl http://10.66.0.1/` should show the nginx
autoindex with the staged image, and `systemctl status
pxe-infra-vm` should report `Loaded …; inactive (dead)` — the
unit is there, just not started.
The QEMU/KVM guest was unconditionally
`wantedBy = [ "multi-user.target" ]`, which means it would
have come up on every boot of rydiwo. The intent is the
opposite for now: the VM is for script-development iteration,
not a permanent rig. We want to start it by hand
(`systemctl start pxe-infra-vm`) when a test session needs
it, and stop it the same way.
- modules/options.nix: new options.pxe-infra.vm.autostart
(default false). Describes when to flip it on (long
unattended test runs) and that the unit itself is
always present when pxe-infra.vm.enable is true.
- modules/pxe-infra/vm.nix: wantedBy is now
`lib.optional config.pxe-infra.vm.autostart "multi-user.target"`,
so with autostart=false the unit is reachable via
`systemctl start` but not pulled in by multi-user.target.
- configurations/mini-laptop.nix: commented example now
shows the `vm.autostart = false` form, and the surrounding
comment documents the manual-start workflow.
The last layer of the boot-and-report pipeline. Per
docs/ARCHITECTURE.md §L6, the report sink must survive the VM
disappearing — anything inside the guest is gone the moment the
VM tears down. This module provides that place: a minimal HTTP
service bound to the bridge IP that accepts run reports and
writes them to disk atomically.
- modules/options.nix: new options.pxe-infra.reportSink
- enable: master switch (default true)
- port: TCP port (default 8080; unprivileged so DynamicUser
can run the daemon without CAP_NET_BIND_SERVICE)
- modules/pxe-infra/report-sink.py: new file, the actual
service. Python stdlib only (no third-party deps, no version
drift, no extra security surface). Endpoints:
POST /report — body is JSON with at least `run_id`; the
file is written atomically (temp + rename)
to /var/lib/pxe-infra/reports/<run_id>.json
GET /health — returns "ok" for liveness checks
A 1 MB body cap is plenty for any structured run report
per RUNNER-DESIGN.md. Path-traversal hardening: run_id must
match [A-Za-z0-9_-]+.
- modules/pxe-infra/report-sink.nix: new file, the Nix module
that wraps report-sink.py. systemd service with:
- DynamicUser + StateDirectory="pxe-infra/reports": no
persistent system-user state, the daemon writes into
/var/lib/pxe-infra/reports/ as a throwaway UID
- NoNewPrivileges, ProtectSystem=strict, ProtectHome,
PrivateTmp, RestrictAddressFamilies=AF_INET{,6}: only
needs to bind a TCP socket and write one file
- Environment sets REPORTS_BIND to the bridge IP, so the
daemon never accidentally listens on 0.0.0.0
- modules/pxe-infra/default.nix: imports the new module.
Refs: docs/ARCHITECTURE.md §L6, docs/RUNNER-DESIGN.md
"Result object".