From 18d69f6e9d0a7ebdc9a5a018b80e5066358fbc23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20M=C3=B6ller?= Date: Tue, 7 Apr 2026 10:44:36 +0200 Subject: [PATCH] nixos/systemd-networkd: Allow three value variant in ipv6AcceptRAConfig.RouteMetric option --- nixos/lib/systemd-lib.nix | 15 +++++++++++++++ nixos/modules/system/boot/networkd.nix | 3 +-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/nixos/lib/systemd-lib.nix b/nixos/lib/systemd-lib.nix index 8397eca39c51..13c529d53619 100644 --- a/nixos/lib/systemd-lib.nix +++ b/nixos/lib/systemd-lib.nix @@ -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 diff --git a/nixos/modules/system/boot/networkd.nix b/nixos/modules/system/boot/networkd.nix index cc120e5d2e6e..a4f0dedb94a7 100644 --- a/nixos/modules/system/boot/networkd.nix +++ b/nixos/modules/system/boot/networkd.nix @@ -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)