git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #140779 from legendofmiracles/wol

nixos/wakeonlan: switch to systemd.link and to nixos/networking

commit46b2a2594a362cdeffc925e2e7bb5906f5c3e25c authorMichele Guerini Rocco <rnhmjoj@users.noreply.github.com> dateSat 9 Oct 2021, 10:34 (5 years ago) parent5170bbc31f04fe
6 files changed+18−71
nixos/doc/manual/from_md/release-notes/rl-2111.section.xml+7 nixos/doc/manual/release-notes/rl-2111.section.md+2 nixos/modules/module-list.nix−1 nixos/modules/services/networking/wakeonlan.nix−70 nixos/modules/tasks/network-interfaces-scripted.nix+2 nixos/modules/tasks/network-interfaces.nix+7
nixos/doc/manual/from_md/release-notes/rl-2111.section.xml+7
@@ -334,6 +334,13 @@
334334 <section xml:id="sec-release-21.11-incompatibilities">
335335 <title>Backward Incompatibilities</title>
336336 <itemizedlist>
337+ <listitem>
338+ <para>
339+ The <literal>services.wakeonlan</literal> option was removed,
340+ and replaced with
341+ <literal>networking.interfaces.&lt;name&gt;.wakeOnLan</literal>.
342+ </para>
343+ </listitem>
337344 <listitem>
338345 <para>
339346 The <literal>security.wrappers</literal> option now requires
nixos/doc/manual/release-notes/rl-2111.section.md+2
@@ -103,6 +103,8 @@ In addition to numerous new and upgraded packages, this release has the followin
103103
104104## Backward Incompatibilities {#sec-release-21.11-incompatibilities}
105105
106+- The `services.wakeonlan` option was removed, and replaced with `networking.interfaces.<name>.wakeOnLan`.
107+
106108- The `security.wrappers` option now requires to always specify an owner, group and whether the setuid/setgid bit should be set.
107109 This is motivated by the fact that before NixOS 21.11, specifying either setuid or setgid but not owner/group resulted in wrappers owned by nobody/nogroup, which is unsafe.
108110
nixos/modules/module-list.nix−1
@@ -883,7 +883,6 @@
883883 ./services/video/unifi-video.nix
884884 ./services/networking/v2ray.nix
885885 ./services/networking/vsftpd.nix
886− ./services/networking/wakeonlan.nix
887886 ./services/networking/wasabibackend.nix
888887 ./services/networking/websockify.nix
889888 ./services/networking/wg-quick.nix
nixos/modules/services/networking/wakeonlan.nixdeleted−70
@@ -1,70 +0,0 @@
1−{ config, lib, pkgs, ... }:
2−
3−with lib;
4−
5−let
6− interfaces = config.services.wakeonlan.interfaces;
7−
8− ethtool = "${pkgs.ethtool}/sbin/ethtool";
9−
10− passwordParameter = password : if (password == "") then "" else
11− "sopass ${password}";
12−
13− methodParameter = {method, password} :
14− if method == "magicpacket" then "wol g"
15− else if method == "password" then "wol s so ${passwordParameter password}"
16− else throw "Wake-On-Lan method not supported";
17−
18− line = { interface, method ? "magicpacket", password ? "" }: ''
19− ${ethtool} -s ${interface} ${methodParameter {inherit method password;}}
20− '';
21−
22− concatStrings = foldr (x: y: x + y) "";
23− lines = concatStrings (map (l: line l) interfaces);
24−
25−in
26−{
27−
28− ###### interface
29−
30− options = {
31−
32− services.wakeonlan.interfaces = mkOption {
33− default = [ ];
34− type = types.listOf (types.submodule { options = {
35− interface = mkOption {
36− type = types.str;
37− description = "Interface to enable for Wake-On-Lan.";
38− };
39− method = mkOption {
40− type = types.enum [ "magicpacket" "password"];
41− description = "Wake-On-Lan method for this interface.";
42− };
43− password = mkOption {
44− type = types.strMatching "[a-fA-F0-9]{2}:([a-fA-F0-9]{2}:){4}[a-fA-F0-9]{2}";
45− description = "The password has the shape of six bytes in hexadecimal separated by a colon each.";
46− };
47− };});
48− example = [
49− {
50− interface = "eth0";
51− method = "password";
52− password = "00:11:22:33:44:55";
53− }
54− ];
55− description = ''
56− Interfaces where to enable Wake-On-LAN, and how. Two methods available:
57− "magicpacket" and "password". The password has the shape of six bytes
58− in hexadecimal separated by a colon each. For more information,
59− check the ethtool manual.
60− '';
61− };
62−
63− };
64−
65−
66− ###### implementation
67−
68− config.powerManagement.powerUpCommands = lines;
69−
70−}
nixos/modules/tasks/network-interfaces-scripted.nix+2
@@ -61,6 +61,8 @@ let
6161 MACAddress = i.macAddress;
6262 } // optionalAttrs (i.mtu != null) {
6363 MTUBytes = toString i.mtu;
64+ } // optionalAttrs (i.wakeOnLan.enable == true) {
65+ WakeOnLan = "magic";
6466 };
6567 };
6668 in listToAttrs (map createNetworkLink interfaces);
nixos/modules/tasks/network-interfaces.nix+7
@@ -284,6 +284,13 @@ let
284284 '';
285285 };
286286
287+ wakeOnLan = {
288+ enable = mkOption {
289+ type = types.bool;
290+ default = false;
291+ description = "Wether to enable wol on this interface.";
292+ };
293+ };
287294 };
288295
289296 config = {