Files
nixos/modules/pxe-infra/default.nix
T
oqyude 046a92700a fix(pxe-infra): add autoexec.ipxe to TFTP root (resolves iPXE #GP / T10)
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.
2026-10-14 14:32:08 +03:00

53 lines
2.3 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
./ipxe.nix
./report-sink.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).
#
# The `L+` rules symlink the iPXE binary and boot.ipxe script
# from /etc/static/pxe-infra/... (where the ipxe.nix module
# drops them via environment.etc) into the served roots, so
# `nixos-rebuild` upgrades of pkgs.ipxe are picked up at the
# next boot without redeploying anything.
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 - -"
"L+ ${config.pxe-infra.artifacts.root}/tftpboot/${config.pxe-infra.bootloader.ipxeBinary} - - - - /etc/static/pxe-infra/tftpboot/${config.pxe-infra.bootloader.ipxeBinary}"
"L+ ${config.pxe-infra.artifacts.root}/http/boot.ipxe - - - - /etc/static/pxe-infra/http/boot.ipxe"
# autoexec.ipxe — chains to the HTTP-served boot.ipxe. iPXE
# in UEFI mode looks for `autoexec.ipxe` on the same TFTP
# server it was loaded from. The actual file is produced by
# ipxe.nix via pkgs.writeText and dropped under
# /etc/static/pxe-infra/tftpboot/; this rule symlinks it into
# the served root. See ipxe.nix and
# .agent/notes/T10-diagnostic-2026-10-14.md.
"L+ ${config.pxe-infra.artifacts.root}/tftpboot/autoexec.ipxe - - - - /etc/static/pxe-infra/tftpboot/autoexec.ipxe"
];
};
}