1
1
Fork 1
mirror of https://github.com/oddlama/nixos-extra-modules.git synced 2025-10-10 22:00:39 +02:00

feat: allow changing interface name in VM

This commit is contained in:
Patrick 2025-01-03 00:22:38 +01:00
parent 6a4736e077
commit 2502ff50ab
No known key found for this signature in database
GPG key ID: 451F95EFB8BECD0F
2 changed files with 27 additions and 15 deletions

View file

@ -202,7 +202,14 @@ in {
description = "An attrset correlating the host interface to which the microvm should be attached via macvtap, with its mac address";
type = types.attrsOf (
types.submodule (submod-iface: {
options.mac = mkOption {
options = {
hostLink = mkOption {
type = types.str;
description = "The name of the host side link to which this interface will bind.";
default = submod-iface.config._module.args.name;
example = "lan";
};
mac = mkOption {
type = types.net.mac;
description = "The MAC address for the guest's macvtap interface";
default = let
@ -217,6 +224,7 @@ in {
))
."${submod.config._module.args.name}-${submod-iface.config._module.args.name}";
};
};
})
);
default = {};

View file

@ -47,12 +47,16 @@ in {
# MACVTAP bridge to the host's network
interfaces = flip mapAttrsToList guestCfg.microvm.interfaces (
interface: {mac, ...}: {
_: {
mac,
hostLink,
...
}: {
type = "macvtap";
id = "vm-${replaceStrings [":"] [""] mac}";
inherit mac;
macvtap = {
link = interface;
link = hostLink;
mode = "bridge";
};
}