diff options
author | ign0tus <ign0tus@posteo.de> | 2023-09-28 17:04:35 +0200 |
---|---|---|
committer | ign0tus <ign0tus@posteo.de> | 2023-09-28 17:04:35 +0200 |
commit | 237f7ba7d2b2be46049e3327eb8208b5ac450940 (patch) | |
tree | 62ca872974d28715a3a64ba845ef1a8e43b94f1d | |
parent | d76e8633bfe92a60e59aa1b4074c65f0bee436a9 (diff) | |
download | nixlib-237f7ba7d2b2be46049e3327eb8208b5ac450940.tar nixlib-237f7ba7d2b2be46049e3327eb8208b5ac450940.tar.gz nixlib-237f7ba7d2b2be46049e3327eb8208b5ac450940.tar.bz2 nixlib-237f7ba7d2b2be46049e3327eb8208b5ac450940.tar.lz nixlib-237f7ba7d2b2be46049e3327eb8208b5ac450940.tar.xz nixlib-237f7ba7d2b2be46049e3327eb8208b5ac450940.tar.zst nixlib-237f7ba7d2b2be46049e3327eb8208b5ac450940.zip |
networkd: Allow combinations of WakeOnLan policies
To comply with the systemd.link WakeOnLan[^1] specification, the option "off" and all other possible policy combinations must be allowed. [^1]: https://www.freedesktop.org/software/systemd/man/systemd.link.html#WakeOnLan=
-rw-r--r-- | nixos/lib/systemd-lib.nix | 4 | ||||
-rw-r--r-- | nixos/modules/system/boot/networkd.nix | 2 |
2 files changed, 5 insertions, 1 deletions
diff --git a/nixos/lib/systemd-lib.nix b/nixos/lib/systemd-lib.nix index f6535b514065..5669aae0bc19 100644 --- a/nixos/lib/systemd-lib.nix +++ b/nixos/lib/systemd-lib.nix @@ -80,6 +80,10 @@ in rec { optional (attr ? ${name} && !elem attr.${name} values) "Systemd ${group} field `${name}' cannot have value `${toString attr.${name}}'."; + assertValuesSomeOfOr = name: values: default: group: attr: + optional (attr ? ${name} && !(all (x: elem x values) (splitString " " attr.${name}) || attr.${name} == default)) + "Systemd ${group} field `${name}' cannot have value `${toString attr.${name}}'."; + assertHasField = name: group: attr: optional (!(attr ? ${name})) "Systemd ${group} field `${name}' must exist."; diff --git a/nixos/modules/system/boot/networkd.nix b/nixos/modules/system/boot/networkd.nix index 238c6670ea0f..d203038dc329 100644 --- a/nixos/modules/system/boot/networkd.nix +++ b/nixos/modules/system/boot/networkd.nix @@ -83,7 +83,7 @@ let (assertByteFormat "BitsPerSecond") (assertValueOneOf "Duplex" ["half" "full"]) (assertValueOneOf "AutoNegotiation" boolValues) - (assertValueOneOf "WakeOnLan" ["phy" "unicast" "multicast" "broadcast" "arp" "magic" "secureon" "off"]) + (assertValuesSomeOfOr "WakeOnLan" ["phy" "unicast" "multicast" "broadcast" "arp" "magic" "secureon"] "off") (assertValueOneOf "Port" ["tp" "aui" "bnc" "mii" "fibre"]) (assertValueOneOf "ReceiveChecksumOffload" boolValues) (assertValueOneOf "TransmitChecksumOffload" boolValues) |