[microvm] setup network, allow adding bridge interface to host
All checks were successful
Evaluate Hydra Jobs / eval-hydra-jobs (push) Successful in 3m19s
Evaluate Hydra Jobs / eval-hydra-jobs (pull_request) Successful in 3m20s

This commit is contained in:
2024-11-18 22:55:03 +01:00
parent d1afbe9f14
commit 05ec7004ad
2 changed files with 63 additions and 0 deletions

View File

@@ -62,6 +62,31 @@ in
specialArgs.inputs = inputs;
modules = defaultMicroVMModules ++ [
./durruti/configuration.nix
{
microvm = {
interfaces = [
{
type = "tap";
id = "vm-test1";
mac = "02:00:00:00:00:01";
}
];
};
systemd.network.enable = true;
systemd.network.networks."20-lan" = {
matchConfig.Type = "ether";
networkConfig = {
Address = ["10.0.0.3/24" "2001:db8::b/64"];
Gateway = "10.0.0.1";
DNS = ["1.1.1.1"];
IPv6AcceptRA = true;
DHCP = "no";
};
};
}
];
};

View File

@@ -19,6 +19,14 @@ in
default = "";
description = lib.mdDoc "ip of nix container provided for malo";
};
microvm = {
enableHostBridge = mkOption {
default = false;
type = types.bool;
description = lib.mdDoc "Setup bridge device for microvms.";
};
};
};
};
@@ -45,5 +53,35 @@ in
locations."/".proxyPass = "http://${cfg.host_ip}:80";
};
systemd.network = mkIf cfg.microvm.enableHostBridge {
enable = true;
# create a bride device that all the microvms will be connected to
netdevs."10-microvm".netdevConfig = {
Kind = "bridge";
Name = "microvm";
};
networks."10-microvm" = {
matchConfig.Name = "microvm";
networkConfig = {
DHCPServer = true;
IPv6SendRA = true;
};
addresses = [ {
Address = "10.0.0.1/24";
} {
Address = "fd12:3456:789a::1/64";
} ];
ipv6Prefixes = [ {
Prefix = "fd12:3456:789a::/64";
} ];
};
# connect the vms to the bridge
networks."11-microvm" = {
matchConfig.Name = "vm-*";
networkConfig.Bridge = "microvm";
};
};
};
}