diff options
author | Andrew Hoff <ahoff@anduril.com> | 2023-01-07 15:43:15 -0500 |
---|---|---|
committer | Andrew Hoff <ahoff@anduril.com> | 2023-01-22 12:20:40 -0500 |
commit | 6ae3e7695e27a4f7afb1d2017f5967d5e82f4c00 (patch) | |
tree | bc34c5eb552872cc71b946c06b240b1b1100d202 /nixos/modules/virtualisation | |
parent | 1c18d9a5fbb064e8b948b75b420e3c3d78d16935 (diff) |
nixos/virtualisation: add option for explicitly named network interfaces
Adds a new option to the virtualisation modules that enables specifying explicitly named network interfaces in QEMU VMs. The existing `virtualisation.vlans` is still supported for cases where the name of the network interface is irrelevant.
Diffstat (limited to 'nixos/modules/virtualisation')
-rw-r--r-- | nixos/modules/virtualisation/qemu-vm.nix | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/nixos/modules/virtualisation/qemu-vm.nix b/nixos/modules/virtualisation/qemu-vm.nix index 4520408ca3379..6f03f9e83b362 100644 --- a/nixos/modules/virtualisation/qemu-vm.nix +++ b/nixos/modules/virtualisation/qemu-vm.nix @@ -545,7 +545,8 @@ in virtualisation.vlans = mkOption { type = types.listOf types.ints.unsigned; - default = [ 1 ]; + default = if config.virtualisation.interfaces == {} then [ 1 ] else [ ]; + defaultText = lib.literalExpression ''if config.virtualisation.interfaces == {} then [ 1 ] else [ ]''; example = [ 1 2 ]; description = lib.mdDoc '' @@ -560,6 +561,35 @@ in ''; }; + virtualisation.interfaces = mkOption { + default = {}; + example = { + enp1s0.vlan = 1; + }; + description = lib.mdDoc '' + Network interfaces to add to the VM. + ''; + type = with types; attrsOf (submodule { + options = { + vlan = mkOption { + type = types.ints.unsigned; + description = lib.mdDoc '' + VLAN to which the network interface is connected. + ''; + }; + + assignIP = mkOption { + type = types.bool; + default = false; + description = lib.mdDoc '' + Automatically assign an IP address to the network interface using the same scheme as + virtualisation.vlans. + ''; + }; + }; + }); + }; + virtualisation.writableStore = mkOption { type = types.bool; |