[microvm] differentiate between stable and unstable nixpkgs

This commit is contained in:
2024-11-21 15:50:13 +01:00
parent 84fef37dc7
commit d2e97448f7

View File

@@ -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