lol

Merge pull request #257510 from ign0tus/fix/wake-on-lan-policy

Fix: WakeOnLan policy

authored by

Florian Klink and committed by
GitHub
42f2e2da 8d301f41

+24 -2
+4
nixos/lib/systemd-lib.nix
··· 80 80 optional (attr ? ${name} && !elem attr.${name} values) 81 81 "Systemd ${group} field `${name}' cannot have value `${toString attr.${name}}'."; 82 82 83 + assertValuesSomeOfOr = name: values: default: group: attr: 84 + optional (attr ? ${name} && !(all (x: elem x values) (splitString " " attr.${name}) || attr.${name} == default)) 85 + "Systemd ${group} field `${name}' cannot have value `${toString attr.${name}}'."; 86 + 83 87 assertHasField = name: group: attr: 84 88 optional (!(attr ? ${name})) 85 89 "Systemd ${group} field `${name}' must exist.";
+1 -1
nixos/modules/system/boot/networkd.nix
··· 83 83 (assertByteFormat "BitsPerSecond") 84 84 (assertValueOneOf "Duplex" ["half" "full"]) 85 85 (assertValueOneOf "AutoNegotiation" boolValues) 86 - (assertValueOneOf "WakeOnLan" ["phy" "unicast" "multicast" "broadcast" "arp" "magic" "secureon" "off"]) 86 + (assertValuesSomeOfOr "WakeOnLan" ["phy" "unicast" "multicast" "broadcast" "arp" "magic" "secureon"] "off") 87 87 (assertValueOneOf "Port" ["tp" "aui" "bnc" "mii" "fibre"]) 88 88 (assertValueOneOf "ReceiveChecksumOffload" boolValues) 89 89 (assertValueOneOf "TransmitChecksumOffload" boolValues)
+1 -1
nixos/modules/tasks/network-interfaces-scripted.nix
··· 62 62 } // optionalAttrs (i.mtu != null) { 63 63 MTUBytes = toString i.mtu; 64 64 } // optionalAttrs (i.wakeOnLan.enable == true) { 65 - WakeOnLan = "magic"; 65 + WakeOnLan = concatStringsSep " " i.wakeOnLan.policy; 66 66 }; 67 67 }; 68 68 in listToAttrs (map createNetworkLink interfaces);
+18
nixos/modules/tasks/network-interfaces.nix
··· 327 327 default = false; 328 328 description = lib.mdDoc "Whether to enable wol on this interface."; 329 329 }; 330 + policy = mkOption { 331 + type = with types; listOf ( 332 + enum ["phy" "unicast" "multicast" "broadcast" "arp" "magic" "secureon"] 333 + ); 334 + default = ["magic"]; 335 + description = lib.mdDoc '' 336 + The [Wake-on-LAN policy](https://www.freedesktop.org/software/systemd/man/systemd.link.html#WakeOnLan=) 337 + to set for the device. 338 + 339 + The options are 340 + - `phy`: Wake on PHY activity 341 + - `unicast`: Wake on unicast messages 342 + - `multicast`: Wake on multicast messages 343 + - `broadcast`: Wake on broadcast messages 344 + - `arp`: Wake on ARP 345 + - `magic`: Wake on receipt of a magic packet 346 + ''; 347 + }; 330 348 }; 331 349 }; 332 350