nixos/networkd: allow state ranges in RequiredForOnline

RequiredForOnline takes a boolean or a minimum operational state and an
optional maximum operational state. In the latter case, range values are
separated with colon.
This commit is contained in:
Ivan Trubach 2023-07-08 07:35:18 +03:00
parent 8f21f3a0a3
commit bc644aee70

View file

@ -514,17 +514,24 @@ let
(assertValueOneOf "Unmanaged" boolValues) (assertValueOneOf "Unmanaged" boolValues)
(assertInt "Group") (assertInt "Group")
(assertRange "Group" 0 2147483647) (assertRange "Group" 0 2147483647)
(assertValueOneOf "RequiredForOnline" (boolValues ++ [ (assertValueOneOf "RequiredForOnline" (boolValues ++ (
"missing" let
"off" # https://freedesktop.org/software/systemd/man/networkctl.html#missing
"no-carrier" operationalStates = [
"dormant" "missing"
"degraded-carrier" "off"
"carrier" "no-carrier"
"degraded" "dormant"
"enslaved" "degraded-carrier"
"routable" "carrier"
])) "degraded"
"enslaved"
"routable"
];
operationalStateRanges = concatLists (imap0 (i: min: map (max: "${min}:${max}") (drop i operationalStates)) operationalStates);
in
operationalStates ++ operationalStateRanges
)))
(assertValueOneOf "RequiredFamilyForOnline" [ (assertValueOneOf "RequiredFamilyForOnline" [
"ipv4" "ipv4"
"ipv6" "ipv6"