diff --git a/nixos/modules/system/boot/networkd.nix b/nixos/modules/system/boot/networkd.nix
index 662dfe2db989..2e17bdf6bb65 100644
--- a/nixos/modules/system/boot/networkd.nix
+++ b/nixos/modules/system/boot/networkd.nix
@@ -131,6 +131,7 @@ let
"fou"
"xfrm"
"ifb"
+ "batadv"
])
(assertByteFormat "MTUBytes")
(assertMacAddress "MACAddress")
@@ -381,6 +382,29 @@ let
(assertInt "Table")
(assertMinimum "Table" 0)
];
+
+ sectionBatmanAdvanced = checkUnitConfig "BatmanAdvanced" [
+ (assertOnlyFields [
+ "GatewayMode"
+ "Aggregation"
+ "BridgeLoopAvoidance"
+ "DistributedArpTable"
+ "Fragmentation"
+ "HopPenalty"
+ "OriginatorIntervalSec"
+ "GatewayBandwithDown"
+ "GatewayBandwithUp"
+ "RoutingAlgorithm"
+ ])
+ (assertValueOneOf "GatewayMode" ["off" "client" "server"])
+ (assertValueOneOf "Aggregation" boolValues)
+ (assertValueOneOf "BridgeLoopAvoidance" boolValues)
+ (assertValueOneOf "DistributedArpTable" boolValues)
+ (assertValueOneOf "Fragmentation" boolValues)
+ (assertInt "HopPenalty")
+ (assertRange "HopPenalty" 0 255)
+ (assertValueOneOf "RoutingAlgorithm" ["batman-v" "batman-iv"])
+ ];
};
network = {
@@ -473,6 +497,7 @@ let
"IgnoreCarrierLoss"
"Xfrm"
"KeepConfiguration"
+ "BatmanAdvanced"
])
# Note: For DHCP the values both, none, v4, v6 are deprecated
(assertValueOneOf "DHCP" ["yes" "no" "ipv4" "ipv6"])
@@ -1056,6 +1081,21 @@ let
'';
};
+ batmanAdvancedConfig = mkOption {
+ default = {};
+ example = {
+ GatewayMode = "server";
+ RoutingAlgorithm = "batman-v";
+ };
+ type = types.addCheck (types.attrsOf unitOption) check.netdev.sectionBatmanAdvanced;
+ description = ''
+ Each attribute in this set specifies an option in the
+ [BatmanAdvanced] section of the unit. See
+ systemd.netdev
+ 5 for details.
+ '';
+ };
+
};
addressOptions = {
@@ -1507,6 +1547,10 @@ let
[VRF]
${attrsToSection def.vrfConfig}
''
+ + optionalString (def.batmanAdvancedConfig != { }) ''
+ [BatmanAdvanced]
+ ${attrsToSection def.batmanAdvancedConfig}
+ ''
+ def.extraConfig;
};