Commit Graph
5 Commits
Author SHA1 Message Date
oqyude a98732d142 fix(pxe-infra): actually include dhcp-range in the dnsmasq settings
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
2026-10-13 03:34:54 +03:00
oqyudeandSisyphus f7acbc6868 fix(pxe-infra): put free pool in dhcp-range, not dhcp-host
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>
2026-10-13 03:32:16 +03:00
oqyude d7e46a4e89 feat(pxe-infra): stage iPXE EFI + boot.ipxe — completes the boot chain
Wires the missing piece between the L3 services and the L4 VM:
the firmware does DHCP+TFTP-fetch of an iPXE binary, then iPXE
fetches a static boot.ipxe script over HTTP, which sanboots the
alpine-worker raw image. Without this, the VM has a DHCP lease
but no filename to TFTP-fetch, so the chain stops at the
firmware.

- modules/options.nix: new options.pxe-infra.bootloader
  - enable: master switch (default true)
  - ipxeBinary: filename under tftpboot/ (default "ipxe.efi",
    the universal UEFI binary from pkgs.ipxe; "snp.efi" is a
    smaller virtio-net-only alternative)

- modules/pxe-infra/ipxe.nix: new file.
  - environment.etc drops pkgs.ipxe's binary under
    /etc/static/pxe-infra/tftpboot/<ipxeBinary>, plus a static
    boot.ipxe script under /etc/static/pxe-infra/http/.
  - The script uses iPXE's own ${boot-url} variable substitution
    (escaped with Nix's ''${...}'' so it survives into the
    output verbatim) to sanboot http://<bridge.address>/latest/
    alpine-worker.raw, with a 5s retry on failure.

- modules/pxe-infra/dhcp.nix: when both pxe-infra.tftp.enable
  and pxe-infra.bootloader.enable are on, dnsmasq settings now
  include `dhcp-boot=<ipxeBinary>`. The MAC filter (tag:!known)
  still drops requests from unknown MACs before they can use the
  filename.

- modules/pxe-infra/default.nix: imports ipxe.nix and adds two
  `L+` tmpfiles rules that symlink the iPXE binary and the
  boot.ipxe script from /etc/static/pxe-infra/... into the
  served TFTP/HTTP roots. `L+` (instead of plain `L`) means
  systemd-tmpfiles will update the symlink target on every
  boot, so pkgs.ipxe upgrades via nixos-rebuild take effect
  without redeploying anything.

Refs: docs/ARCHITECTURE.md §L3, §L4.
2026-10-13 02:46:07 +03:00
oqyude 54a93f1e48 feat(pxe-infra): add TFTP (via dnsmasq) and HTTP (via nginx) — L3
Wires the L3 PXE services from docs/ARCHITECTURE.md into the
homelab flake. The DHCP module already running on the bridge gets
TFTP bolted on (same dnsmasq daemon, same interface binding); a
new nginx vhost serves kernel, initramfs, and rootfs over HTTP
from the same private bridge.

- modules/options.nix: new options.pxe-infra.{artifacts, http, tftp}
  - artifacts.root defaults to /var/lib/pxe-infra; both servers
    read from subdirs of that path
  - http.{enable, port}: nginx listener (default port 80, bound
    to the bridge IP only)
  - tftp.enable: opt-out for the dnsmasq TFTP module

- modules/pxe-infra/dhcp.nix: when pxe-infra.tftp.enable, the
  dnsmasq settings now include `enable-tftp` and `tftp-root=`.
  No new daemon; the same bind-interfaces + interface= already
  restricts the DHCP server to the bridge, and that carries
  through to the TFTP server.

- modules/pxe-infra/http.nix: new file. services.nginx.enable
  and a single vhost listening on the bridge IP, root at
  artifacts.root/http, autoindex on. No default-server catch-all,
  so requests on any other interface are refused at the listen
  layer, not silently answered.

- modules/pxe-infra/default.nix: imports the new http.nix and
  adds systemd-tmpfiles rules that create artifacts.root plus
  its http/ and tftpboot/ subdirs at boot. The module does not
  populate them — that is L5 (image build)'s job.

nginx does not speak TFTP (UDP/69, RFC 1350); TFTP stays with
dnsmasq where it shares the daemon with DHCP. ARCHITECTURE.md
L3 calls out TFTP+HTTP conflation as the mistake; DHCP+TFTP
sharing a daemon is a natural fit and avoids a second service
on the Chuwi MiniBook.

Refs: docs/ARCHITECTURE.md §L3, docs/OPEN-QUESTIONS.md
"Resolved (2026-10-13)" B.9/B.10.
2026-10-13 02:35:59 +03:00
oqyude a940356e0a feat(pxe-infra): add isolated bridge + MAC-filtered DHCP module (L2)
Adds the L2 layer of the PXE pipeline test bed (docs/ARCHITECTURE.md
§L2) to rydiwo only — isolated private subnet, never touches LAN.

- modules/options.nix: options.pxe-infra.{enable, bridge, dhcp.*,
  guests[]} — fully typed, default master toggle is off so the
  existing rydiwo build is unchanged
- modules/pxe-infra/default.nix: umbrella that imports the two
  sub-modules; inert when the master toggle is off
- modules/pxe-infra/bridge.nix: idempotent systemd oneshot that
  creates the Linux bridge, assigns the lab host a private IPv4,
  and is explicitly NetworkManager.unmanaged so NM does not
  reconfigure it
- modules/pxe-infra/dhcp.nix: dnsmasq as DHCP-only on the bridge
  only (bind-interfaces + interface=, port=0 disables DNS, no-resolv,
  no-poll, cache-size=0); MAC-filtered via dhcp-host=…,set:known and
  dhcp-ignore=tag:!known when authoritative=false
- configurations/mini-laptop.nix: adds modules/pxe-infra to
  imports, plus a commented example showing how to enable for a
  real guest

Sidesteps docs/OPEN-QUESTIONS.md Q21 (LAN-permission) by design:
a fully isolated bridge satisfies L2 without the lab node answering
DHCP on the real LAN. nix flake check passes for all six hosts.

Refs: docs/ARCHITECTURE.md §L2, docs/OPEN-QUESTIONS.md F20/F21/F23.
2026-10-13 01:45:28 +03:00