diff --git a/configurations/mini-laptop.nix b/configurations/mini-laptop.nix index 0c2a88d..d0cbd61 100644 --- a/configurations/mini-laptop.nix +++ b/configurations/mini-laptop.nix @@ -38,16 +38,26 @@ # -------------------------------------------------------------------------- # PXE infrastructure rig (L2 of docs/ARCHITECTURE.md). - # Uncomment to enable on rydiwo. The rig gives rydiwo an isolated Linux - # bridge (`pxe-infra.bridge.name`, default `pxe0`) plus a MAC-filtered - # dnsmasq DHCP server bound only to that bridge — the real LAN is not - # touched. See `modules/options.nix` (options.pxe-infra.*) for the - # full option surface and `modules/pxe-infra/` for the implementation. + # Uncomment to enable on rydiwo. The rig gives rydiwo an isolated + # Linux bridge (`pxe-infra.bridge.name`, default `pxe0`) plus a + # MAC-filtered dnsmasq DHCP server bound only to that bridge — the + # real LAN is not touched. The QEMU guest (L4) is configured but + # NOT autostarted: start it by hand with + # systemctl start pxe-infra-vm + # when a test session needs it, and stop it the same way. Set + # `vm.autostart = true` here to bring the VM up on every boot + # (e.g. for a long unattended test run). See `modules/options.nix` + # (options.pxe-infra.*) for the full option surface and + # `modules/pxe-infra/` for the implementation. # # pxe-infra = { # enable = true; # bridge.address = "10.66.0.1"; # bridge.prefixLength = 24; + # vm = { + # enable = true; + # autostart = false; # start manually when testing + # }; # dhcp.guests = [ # { # mac = "52:54:00:12:34:56"; diff --git a/modules/options.nix b/modules/options.nix index bad6ae1..2b853f2 100644 --- a/modules/options.nix +++ b/modules/options.nix @@ -333,6 +333,21 @@ testable memory in Phase 3 (RAM burnin). ''; }; + autostart = lib.mkOption { + type = lib.types.bool; + default = false; + description = '' + Whether the QEMU guest starts on boot. Off by default: + for script-development iteration, you start it by hand + (`systemctl start pxe-infra-vm`) and stop it the same + way. Set this to true if you want the VM up whenever + rydiwo is up (e.g. while leaving a long unattended + test running). The systemd unit itself is always + present when pxe-infra.vm.enable is true, so toggling + autostart does not require anything beyond this + option flipping. + ''; + }; }; # iPXE bootloader staging. Bridges the UEFI firmware (which diff --git a/modules/pxe-infra/vm.nix b/modules/pxe-infra/vm.nix index f5a5a93..c682ef6 100644 --- a/modules/pxe-infra/vm.nix +++ b/modules/pxe-infra/vm.nix @@ -31,7 +31,12 @@ systemd.services.pxe-infra-vm = { description = "pxe-infra: PXE-boot QEMU/KVM guest (L4)"; - wantedBy = [ "multi-user.target" ]; + # Autostart is off by default. The unit still exists, so + # `systemctl start pxe-infra-vm` is enough to bring the + # guest up for a test session; `systemctl stop` to tear + # it down. To bring it up on every boot, set + # pxe-infra.vm.autostart = true. + wantedBy = lib.optional config.pxe-infra.vm.autostart "multi-user.target"; after = [ "pxe-infra-bridge.service" "dnsmasq.service"