Skip to content

Commit

Permalink
nixos/networkd: add BridgeVLAN options
Browse files Browse the repository at this point in the history
  • Loading branch information
apfelkuchen6 committed Mar 16, 2023
1 parent cd650b3 commit 0ddfb0a
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions nixos/modules/system/boot/networkd.nix
Original file line number Diff line number Diff line change
Expand Up @@ -1414,6 +1414,16 @@ let
(assertInt "Weight")
(assertRange "Weight" 1 1023)
];

sectionBridgeVLAN = checkUnitConfig "BridgeVLAN" [
(assertOnlyFields [
"VLAN"
"EgressUntagged"
"PVID"
])
(assertInt "PVID")
(assertRange "PVID" 0 4094)
];
};
};

Expand Down Expand Up @@ -1879,6 +1889,21 @@ let
};
};

bridgeVLANOptions = {
options = {
bridgeMDBConfig = mkOption {
default = {};
example = { VLAN = 20; };
type = types.addCheck (types.attrsOf unitOption) check.network.sectionBridgeVLAN;
description = lib.mdDoc ''
Each attribute in this set specifies an option in the
`[BridgeVLAN]` section of the unit. See
{manpage}`systemd.network(5)` for details.
'';
};
};
};

networkOptions = commonNetworkOptions // {

linkConfig = mkOption {
Expand Down Expand Up @@ -2357,6 +2382,27 @@ let
'';
};

bridgeVLANConfig = mkOption {
default = {};
example = { VLAN = "10-20"; };
type = types.addCheck (types.attrsOf unitOption) check.network.sectionbridgeVLAN;
description = lib.mdDoc ''
Each attribute in this set specifies an option in the
`[BridgeVLAN]` section of the unit. See
{manpage}`systemd.network(5)` for details.
'';
};

bridgeVLANs = mkOption {
default = [];
example = [ { bridgeVLANConfig = { VLAN = "10-20"; }; } ];
type = with types; listOf (submodule bridgeVLANOptions);
description = lib.mdDoc ''
A list of BridgeVLAN sections to be added to the unit. See
{manpage}`systemd.network(5)` for details.
'';
};

name = mkOption {
type = types.nullOr types.str;
default = null;
Expand Down Expand Up @@ -2888,6 +2934,10 @@ let
[QuickFairQueueingClass]
${attrsToSection def.quickFairQueueingConfigClass}
''
+ flip concatMapStrings def.bridgeVLANs (x: ''
[BridgeVLAN]
${attrsToSection x.bridgeVLANConfig}
'')
+ def.extraConfig;
};

Expand Down

0 comments on commit 0ddfb0a

Please sign in to comment.