From d2127286768d121feeb7335a9317d67056f6859a Mon Sep 17 00:00:00 2001 From: kalipso Date: Thu, 21 Nov 2024 15:50:13 +0100 Subject: [PATCH] [microvm] differentiate between stable and unstable nixpkgs --- machines/modules/malobeo/microvm_host.nix | 32 ++++++++++++++++------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/machines/modules/malobeo/microvm_host.nix b/machines/modules/malobeo/microvm_host.nix index 0dbbafc..8846a4b 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."; }; + enableHostBridgeUnstable = mkOption { + default = false; + type = types.bool; + description = lib.mdDoc "Setup bridge device for microvms."; + }; + deployHosts = mkOption { default = []; type = types.listOf types.str; @@ -29,8 +35,17 @@ in inputs.microvm.nixosModules.host ]; - config = mkIf cfg.enableHostBridge { - systemd.network = { + config = { + assertions = [ + { + assertion = !(cfg.enableHostBridgeUnstable && cfg.enableHostBridge); + message = '' + Only enableHostBridge or enableHostBridgeUnstable! Not Both! + ''; + } + ]; + + systemd.network = mkIf (cfg.enableHostBridge || cfg.enableHostBridgeUnstable) { enable = true; # create a bride device that all the microvms will be connected to netdevs."10-microvm".netdevConfig = { @@ -44,14 +59,11 @@ in DHCPServer = true; IPv6SendRA = true; }; - addresses = [ { - Address = "10.0.0.1/24"; - } { - Address = "fd12:3456:789a::1/64"; - } ]; - ipv6Prefixes = [ { - Prefix = "fd12:3456:789a::/64"; - } ]; + addresses = if cfg.enableHostBridgeUnstable then [ + { Address = "10.0.0.1/24"; } + ] else [ + { addressConfig.Address = "10.0.0.1/24"; } + ]; }; # connect the vms to the bridge