Commit 0ddfb0a5 authored by apfelkuchen06's avatar apfelkuchen06
Browse files

nixos/networkd: add BridgeVLAN options

parent cd650b3f
Loading
Loading
Loading
Loading
+50 −0
Original line number Diff line number Diff line
@@ -1414,6 +1414,16 @@ let
        (assertInt "Weight")
        (assertRange "Weight" 1 1023)
      ];

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

@@ -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 {
@@ -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;
@@ -2888,6 +2934,10 @@ let
          [QuickFairQueueingClass]
          ${attrsToSection def.quickFairQueueingConfigClass}
        ''
        + flip concatMapStrings def.bridgeVLANs (x: ''
          [BridgeVLAN]
          ${attrsToSection x.bridgeVLANConfig}
        '')
        + def.extraConfig;
    };