Unverified Commit fbebe4cd authored by Florian Klink's avatar Florian Klink Committed by GitHub
Browse files

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

nixos/systemd-networkd: Allow three value variant in ipv6AcceptRAConfig.RouteMetric option (#507540)
parents 58cc3f99 18d69f6e
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -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
Original line number Diff line number Diff line
@@ -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)