summary refs log tree commit diff
path: root/nixos/modules/system
diff options
context:
space:
mode:
authorIvan Trubach <mr.trubach@icloud.com>2023-07-08 07:35:18 +0300
committerIvan Trubach <mr.trubach@icloud.com>2023-09-04 20:38:54 +0300
commitbc644aee70ff319d98ee1a75c8faf4767d6cdca6 (patch)
tree54df1979293c836fa13957a81c975b8d50af1389 /nixos/modules/system
parent8f21f3a0a3b65567f21697597d7b061a4731345a (diff)
downloadnixpkgs-bc644aee70ff319d98ee1a75c8faf4767d6cdca6.tar
nixpkgs-bc644aee70ff319d98ee1a75c8faf4767d6cdca6.tar.gz
nixpkgs-bc644aee70ff319d98ee1a75c8faf4767d6cdca6.tar.bz2
nixpkgs-bc644aee70ff319d98ee1a75c8faf4767d6cdca6.tar.lz
nixpkgs-bc644aee70ff319d98ee1a75c8faf4767d6cdca6.tar.xz
nixpkgs-bc644aee70ff319d98ee1a75c8faf4767d6cdca6.tar.zst
nixpkgs-bc644aee70ff319d98ee1a75c8faf4767d6cdca6.zip
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.
Diffstat (limited to 'nixos/modules/system')
-rw-r--r--nixos/modules/system/boot/networkd.nix29
1 files changed, 18 insertions, 11 deletions
diff --git a/nixos/modules/system/boot/networkd.nix b/nixos/modules/system/boot/networkd.nix
index 463e2b8d90b..cc70f971aca 100644
--- a/nixos/modules/system/boot/networkd.nix
+++ b/nixos/modules/system/boot/networkd.nix
@@ -514,17 +514,24 @@ let
         (assertValueOneOf "Unmanaged" boolValues)
         (assertInt "Group")
         (assertRange "Group" 0 2147483647)
-        (assertValueOneOf "RequiredForOnline" (boolValues ++ [
-          "missing"
-          "off"
-          "no-carrier"
-          "dormant"
-          "degraded-carrier"
-          "carrier"
-          "degraded"
-          "enslaved"
-          "routable"
-        ]))
+        (assertValueOneOf "RequiredForOnline" (boolValues ++ (
+          let
+            # https://freedesktop.org/software/systemd/man/networkctl.html#missing
+            operationalStates = [
+              "missing"
+              "off"
+              "no-carrier"
+              "dormant"
+              "degraded-carrier"
+              "carrier"
+              "degraded"
+              "enslaved"
+              "routable"
+            ];
+            operationalStateRanges = concatLists (imap0 (i: min: map (max: "${min}:${max}") (drop i operationalStates)) operationalStates);
+          in
+          operationalStates ++ operationalStateRanges
+        )))
         (assertValueOneOf "RequiredFamilyForOnline" [
           "ipv4"
           "ipv6"