From a07b8ffd6873f432d65c4450b800470423b1b993 Mon Sep 17 00:00:00 2001 From: kalipso Date: Sun, 22 Feb 2026 21:48:18 +0100 Subject: [PATCH] [run-vm] add testHost option to module to allow local testing again --- machines/modules/malobeo/microvm_host.nix | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/machines/modules/malobeo/microvm_host.nix b/machines/modules/malobeo/microvm_host.nix index 26ac75f8..805255e5 100644 --- a/machines/modules/malobeo/microvm_host.nix +++ b/machines/modules/malobeo/microvm_host.nix @@ -14,6 +14,12 @@ in description = lib.mdDoc "Setup bridge device for microvms."; }; + testHost = mkOption { + default = false; + type = types.bool; + description = lib.mdDoc "Enable when the host is used for development and testing using run-vm"; + }; + interface = mkOption { default = "eno1"; type = types.str; @@ -68,7 +74,7 @@ in systemd.network = mkIf (cfg.enableHostBridge || cfg.enableHostBridgeUnstable) { enable = true; networks."10-lan" = { - matchConfig.Name = [ "${cfg.interface}" "vm-*"]; + matchConfig.Name = ["vm-*"] ++ (if !cfg.testHost then [ "${cfg.interface}" ] else [ ]); networkConfig = { Bridge = "malobeo0"; }; @@ -81,7 +87,7 @@ in }; }; - networks."10-lan-bridge" = { + networks."10-lan-bridge" = if !cfg.testHost then { matchConfig.Name = "malobeo0"; networkConfig = { Address = [ "${cfg.address}" ]; @@ -90,6 +96,17 @@ in IPv6AcceptRA = true; }; linkConfig.RequiredForOnline = "routable"; + } else { + matchConfig.Name = "malobeo0"; + networkConfig = { + DHCPServer = true; + IPv6SendRA = true; + }; + addresses = if cfg.enableHostBridgeUnstable then [ + { Address = "10.0.0.1/24"; } + ] else [ + { Address = "10.0.0.1/24"; } + ]; }; };