Files
nix-config/hosts/12kingdoms-shushou/microvm.nix
T
ryan4yin | 二花 de6a66ccd4 fix(microvm): run k3s guests from their nixosConfigurations entry (#483)
Assisted-by: DeepSeek Harness 0.2.1-rc.2 (claude-opus-5-5)
2026-10-21 21:32:56 +08:00

44 lines
1.2 KiB
Nix

{
microvm,
inputs,
...
}:
{
# Run the k3s-test VMs as MicroVMs instead of KubeVirt domains.
imports = [ microvm.nixosModules.host ];
# Each guest runs its `nixosConfigurations` entry, the system that `just test`
# and `just microvm-deploy` see, instead of a second evaluation on the host.
microvm.vms.k3s-test-1-master-3 = {
autostart = true;
restartIfChanged = true;
evaluatedConfig = inputs.self.nixosConfigurations.k3s-test-1-master-3;
};
microvm.vms.k3s-test-1-worker-3 = {
autostart = true;
restartIfChanged = true;
evaluatedConfig = inputs.self.nixosConfigurations.k3s-test-1-worker-3;
};
# Attach the guest's tap to the VM bridge, the same way the physical NIC is
# attached. The name is vm<last IP octet> from lib/genMicrovmGuestModule.nix:
# 192.168.5.116 -> vm116, 192.168.5.113 -> vm113.
systemd.network.networks."20-vm116" = {
matchConfig.Name = [ "vm116" ];
networkConfig = {
LinkLocalAddressing = "no";
Bridge = "br0";
};
linkConfig.RequiredForOnline = "no";
};
systemd.network.networks."20-vm113" = {
matchConfig.Name = [ "vm113" ];
networkConfig = {
LinkLocalAddressing = "no";
Bridge = "br0";
};
linkConfig.RequiredForOnline = "no";
};
}