feat(homelab): refuse switch on kernel, initrd, systemd or br0 changes

Assisted-by: DeepSeek Harness (claude-opus-5-5)
This commit is contained in:
Ryan Yin committed 2026-11-17 21:05:20 +08:00
1 parent 08a4dd2e21
commit f76889a158
2 files changed
+24

No files matched your search

+7
View File
@@ -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 <host> 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
+17
View File
@@ -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