diff --git a/hosts/README.md b/hosts/README.md index 1a26f506..d9cc2e74 100644 --- a/hosts/README.md +++ b/hosts/README.md @@ -180,6 +180,13 @@ qemu-kvm path; there are none right now. settings). Deploy serially (`-p 1`) and re-check VM reachability afterwards. - Use `boot` + a serial reboot for anything that can drop the network mid-flight — `systemd.network` / `br0` changes, nixpkgs updates, or any broad rebuild. +- `switch` enforces this through `system.switch.inhibitors` in + [genVmHostModule.nix](../lib/genVmHostModule.nix): when the kernel, its parameters or modules, the + initrd, systemd, `networkd.conf`, or the `br0` / uplink units change, `switch-to-configuration` + prints `There are changes to critical components of the system` and exits before installing the + boot loader, and Colmena reports the activation as failed. Colmena has already pointed the system + profile at the new generation, so rerun with `just boot` and reboot, or switch anyway on + the host with `NIXOS_NO_CHECK=1 /nix/var/nix/profiles/system/bin/switch-to-configuration switch`. - If a host loses VM networking, check `br0` and the VM taps, or reboot the host. ## Boot Recovery on Physical Servers diff --git a/lib/genVmHostModule.nix b/lib/genVmHostModule.nix index 16a21d58..c9e8b5cc 100644 --- a/lib/genVmHostModule.nix +++ b/lib/genVmHostModule.nix @@ -9,6 +9,7 @@ let inherit (networking.hostsAddr.${hostName}) iface ipv4; ipv4WithMask = "${ipv4}/24"; in +{ config, lib, ... }: { # CPU policy belongs to physical hosts; guests do not control hardware frequency. imports = [ @@ -142,6 +143,22 @@ in }; }; + # `switch` refuses changes that only a reboot applies or that can drop br0 mid-flight; deploy + # those with `boot` (hosts/README.md). Guest tap units are left out so a new guest still switches. + system.switch.inhibitors = { + kernel = toString config.system.build.kernel; + kernel-params = toString config.boot.kernelParams; + kernel-modules = toString config.system.modulesTree; + initrd = toString config.system.build.initialRamdisk; + systemd = toString config.systemd.package; + } + // lib.genAttrs [ + "systemd/networkd.conf" + "systemd/network/10-br0.netdev" + "systemd/network/10-br0.network" + "systemd/network/20-${iface}.network" + ] (name: toString config.environment.etc.${name}.source); + # systemd-journal - cap disk usage, but keep plenty of history on the big # persistent disk (/var/log is preserved to /persistent). # https://www.freedesktop.org/software/systemd/man/latest/journald.conf.html