summary refs log tree commit diff
path: root/nixos
diff options
context:
space:
mode:
authorPhilip Taron <philip.taron@gmail.com>2023-11-17 13:08:18 -0800
committerJörg Thalheim <Mic92@users.noreply.github.com>2023-11-18 08:43:21 +0100
commitbc7a939ced9c33e424478a41aba57f2f5864229b (patch)
tree1a4cdecec9fecbdf5d7b74f40674b0f7967f099c /nixos
parent7686f24675e861ceb05bc7539a549bd4bd72dfcd (diff)
downloadnixpkgs-bc7a939ced9c33e424478a41aba57f2f5864229b.tar
nixpkgs-bc7a939ced9c33e424478a41aba57f2f5864229b.tar.gz
nixpkgs-bc7a939ced9c33e424478a41aba57f2f5864229b.tar.bz2
nixpkgs-bc7a939ced9c33e424478a41aba57f2f5864229b.tar.lz
nixpkgs-bc7a939ced9c33e424478a41aba57f2f5864229b.tar.xz
nixpkgs-bc7a939ced9c33e424478a41aba57f2f5864229b.tar.zst
nixpkgs-bc7a939ced9c33e424478a41aba57f2f5864229b.zip
nixos/networkd: add [IPVLAN] and [IPVTAP] configuration options to systemd.netdev files
[IPVLAN](https://www.freedesktop.org/software/systemd/man/latest/systemd.netdev.html#%5BIPVLAN%5D%20Section%20Options)
[IPVTAP](https://www.freedesktop.org/software/systemd/man/latest/systemd.netdev.html#%5BIPVTAP%5D%20Section%20Options)
Diffstat (limited to 'nixos')
-rw-r--r--nixos/lib/systemd-network-units.nix6
-rw-r--r--nixos/modules/system/boot/networkd.nix34
2 files changed, 40 insertions, 0 deletions
diff --git a/nixos/lib/systemd-network-units.nix b/nixos/lib/systemd-network-units.nix
index 8bda1a8bfdc..1d5f823f367 100644
--- a/nixos/lib/systemd-network-units.nix
+++ b/nixos/lib/systemd-network-units.nix
@@ -23,6 +23,12 @@ in {
     '' + optionalString (def.vlanConfig != { }) ''
       [VLAN]
       ${attrsToSection def.vlanConfig}
+    '' + optionalString (def.ipvlanConfig != { }) ''
+      [IPVLAN]
+      ${attrsToSection def.ipvlanConfig}
+    '' + optionalString (def.ipvtapConfig != { }) ''
+      [IPVTAP]
+      ${attrsToSection def.ipvtapConfig}
     '' + optionalString (def.macvlanConfig != { }) ''
       [MACVLAN]
       ${attrsToSection def.macvlanConfig}
diff --git a/nixos/modules/system/boot/networkd.nix b/nixos/modules/system/boot/networkd.nix
index be41654a05d..b61db86cbaa 100644
--- a/nixos/modules/system/boot/networkd.nix
+++ b/nixos/modules/system/boot/networkd.nix
@@ -122,6 +122,16 @@ let
         (assertValueOneOf "PacketInfo" boolValues)
         (assertValueOneOf "VNetHeader" boolValues)
       ];
+
+      # See https://www.freedesktop.org/software/systemd/man/latest/systemd.netdev.html#%5BIPVTAP%5D%20Section%20Options
+      ipVlanVtapChecks = [
+        (assertOnlyFields [
+          "Mode"
+          "Flags"
+        ])
+        (assertValueOneOf "Mode" ["L2" "L3" "L3S" ])
+        (assertValueOneOf "Flags" ["private" "vepa" "bridge" ])
+      ];
     in {
 
       sectionNetdev = checkUnitConfig "Netdev" [
@@ -192,6 +202,10 @@ let
         (assertValueOneOf "ReorderHeader" boolValues)
       ];
 
+      sectionIPVLAN = checkUnitConfig "IPVLAN" ipVlanVtapChecks;
+
+      sectionIPVTAP = checkUnitConfig "IPVTAP" ipVlanVtapChecks;
+
       sectionMACVLAN = checkUnitConfig "MACVLAN" [
         (assertOnlyFields [
           "Mode"
@@ -1625,6 +1639,26 @@ let
       '';
     };
 
+    ipvlanConfig = mkOption {
+      default = {};
+      example = { Mode = "L2"; Flags = "private"; };
+      type = types.addCheck (types.attrsOf unitOption) check.netdev.sectionIPVLAN;
+      description = lib.mdDoc ''
+        Each attribute in this set specifies an option in the `[IPVLAN]` section of the unit.
+        See {manpage}`systemd.netdev(5)` for details.
+      '';
+    };
+
+    ipvtapConfig = mkOption {
+      default = {};
+      example = { Mode = "L3"; Flags = "vepa"; };
+      type = types.addCheck (types.attrsOf unitOption) check.netdev.sectionIPVTAP;
+      description = lib.mdDoc ''
+        Each attribute in this set specifies an option in the `[IPVTAP]` section of the unit.
+        See {manpage}`systemd.netdev(5)` for details.
+      '';
+    };
+
     macvlanConfig = mkOption {
       default = {};
       example = { Mode = "private"; };