nixos/systemd-networkd: Allow three value variant in ipv6AcceptRAConfig.RouteMetric option

This commit is contained in:
Fabian Möller
2026-04-07 10:44:36 +02:00
parent 7b609cb932
commit 18d69f6e9d
2 changed files with 16 additions and 2 deletions
+15
View File
@@ -278,6 +278,21 @@ rec {
attr ? ${name} && !(hasPrefix "@" attr.${name})
) "Systemd ${group} field `${name}' is not a systemd credential";
assertRouteMetricOrTriple =
name: group: attr:
let
isMetric = n: 0 <= n && 4294967295 >= n;
parts = splitString ":" attr.${name};
partsValid =
length parts == 3 && all (p: (match "[0-9]+" p) != null && isMetric (toIntBase10 p)) parts;
valid = (isInt attr.${name} && isMetric attr.${name}) || partsValid;
in
optional (attr ? ${name} && !valid) (
"Systemd ${group} field `${name}' must either be an integer in the range [0,4294967295]"
+ " or a string containing three integers separated with `:`"
);
checkUnitConfig =
group: checks: attrs:
let
+1 -2
View File
@@ -1744,8 +1744,7 @@ let
(assertValueOneOf "UseDNR" boolValues)
(assertValueOneOf "UseDomains" (boolValues ++ [ "route" ]))
(assertRange "RouteTable" 0 4294967295)
(assertInt "RouteMetric")
(assertRange "RouteMetric" 0 4294967295)
(assertRouteMetricOrTriple "RouteMetric")
(assertValueOneOf "QuickAck" boolValues)
(assertValueOneOf "UseMTU" boolValues)
(assertValueOneOf "UseHopLimit" boolValues)