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.
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.
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.
Wires the L4 guest VM from docs/ARCHITECTURE.md into the homelab
flake. The guest is the consumer of the L2 (bridge + DHCP) and L3
(TFTP + HTTP) plumbing committed earlier; it PXE-boots through the
private bridge with a fixed MAC, no disk, no persistent NVRAM.
- modules/options.nix: new options.pxe-infra.vm
- enable: master switch (default false; turning it on spins up
the VM on every boot, which the user may want to defer until
an artifact is staged)
- mac: guest NIC MAC (default 52:54:00:12:34:56; must also
appear in pxe-infra.dhcp.guests when authoritative=false)
- cpus: vCPU count
- memory: RAM size in QEMU syntax (e.g. "2G")
- modules/pxe-infra/vm.nix: new file. A systemd service running
qemu-system-x86_64 with:
- machine type=q35 + accel=kvm:tcg (TCG fallback if KVM is
not available on the host)
- OVMF.fd as a read-only pflash drive (UEFI only — B.6); the
combined fd has no NVRAM region, so every restart is a
fresh boot, which is the property ARCHITECTURE.md §L4 wants
- netdev=bridge,br=pxe0 attaching the guest's virtio-net to
the L2 bridge, with the fixed MAC
- -boot n: network only, no disk, no ISO
- Restart=always, RestartSec=5s — failed/interrupted runs are
safe to repeat (per ARCHITECTURE.md "Run lifecycle")
- modules/pxe-infra/default.nix: imports the new vm.nix.
Refs: docs/ARCHITECTURE.md §L4, docs/OPEN-QUESTIONS.md
"Resolved (2026-10-13)" B.6 (UEFI only).