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).
35 lines
1.1 KiB
Nix
35 lines
1.1 KiB
Nix
# pxe-infra — isolated private network for PXE VM guests (L2/L3 of
|
|
# docs/ARCHITECTURE.md). Provides a Linux bridge, a MAC-filtered
|
|
# DHCP server, a TFTP server (iPXE bootloader), and an HTTP server
|
|
# (kernel/initramfs/rootfs), so a fresh VM can netboot from this
|
|
# host without touching the real LAN.
|
|
#
|
|
# Master toggle: `pxe-infra.enable`. Submodules guard their own
|
|
# config with `lib.mkIf config.pxe-infra.enable`, so importing
|
|
# this umbrella alone has no effect on a host that opts out.
|
|
{
|
|
config,
|
|
lib,
|
|
...
|
|
}:
|
|
{
|
|
imports = [
|
|
./bridge.nix
|
|
./dhcp.nix
|
|
./http.nix
|
|
./vm.nix
|
|
];
|
|
|
|
config = lib.mkIf config.pxe-infra.enable {
|
|
# Create the artifact directory tree at boot. TFTP and HTTP
|
|
# both serve from here; the actual artifacts land in this tree
|
|
# by whatever means (manual copy, deploy step, mkosi output
|
|
# directory — see docs/OPEN-QUESTIONS.md B.9/B.10).
|
|
systemd.tmpfiles.rules = [
|
|
"d ${config.pxe-infra.artifacts.root} 0755 root root - -"
|
|
"d ${config.pxe-infra.artifacts.root}/http 0755 root root - -"
|
|
"d ${config.pxe-infra.artifacts.root}/tftpboot 0755 root root - -"
|
|
];
|
|
};
|
|
}
|