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)

Changed files
+40
nixos
lib
modules
system
+6
nixos/lib/systemd-network-units.nix
···
'' + 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}
+34
nixos/modules/system/boot/networkd.nix
···
(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" [
···
(assertValueOneOf "LooseBinding" boolValues)
(assertValueOneOf "ReorderHeader" boolValues)
];
+
+
sectionIPVLAN = checkUnitConfig "IPVLAN" ipVlanVtapChecks;
+
+
sectionIPVTAP = checkUnitConfig "IPVTAP" ipVlanVtapChecks;
sectionMACVLAN = checkUnitConfig "MACVLAN" [
(assertOnlyFields [
···
Each attribute in this set specifies an option in the
`[VLAN]` section of the unit. See
{manpage}`systemd.netdev(5)` for details.
+
'';
+
};
+
+
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.
'';
};