summary refs log tree commit diff
diff options
context:
space:
mode:
authorMichele Guerini Rocco <rnhmjoj@users.noreply.github.com>2021-10-09 10:34:26 +0200
committerGitHub <noreply@github.com>2021-10-09 10:34:26 +0200
commit46b2a2594a362cdeffc925e2e7bb5906f5c3e25c (patch)
treed40b06904524a672392af12b1a2d53faaceb9463
parent5170bbc0158daeaefca344fbf2275e1f261f9067 (diff)
parent31f04fec3c4c993d75ea4c7243fbc57103525282 (diff)
downloadnixpkgs-46b2a2594a362cdeffc925e2e7bb5906f5c3e25c.tar
nixpkgs-46b2a2594a362cdeffc925e2e7bb5906f5c3e25c.tar.gz
nixpkgs-46b2a2594a362cdeffc925e2e7bb5906f5c3e25c.tar.bz2
nixpkgs-46b2a2594a362cdeffc925e2e7bb5906f5c3e25c.tar.lz
nixpkgs-46b2a2594a362cdeffc925e2e7bb5906f5c3e25c.tar.xz
nixpkgs-46b2a2594a362cdeffc925e2e7bb5906f5c3e25c.tar.zst
nixpkgs-46b2a2594a362cdeffc925e2e7bb5906f5c3e25c.zip
Merge pull request #140779 from legendofmiracles/wol
nixos/wakeonlan: switch to systemd.link and to nixos/networking
-rw-r--r--nixos/doc/manual/from_md/release-notes/rl-2111.section.xml7
-rw-r--r--nixos/doc/manual/release-notes/rl-2111.section.md2
-rw-r--r--nixos/modules/module-list.nix1
-rw-r--r--nixos/modules/services/networking/wakeonlan.nix70
-rw-r--r--nixos/modules/tasks/network-interfaces-scripted.nix2
-rw-r--r--nixos/modules/tasks/network-interfaces.nix7
6 files changed, 18 insertions, 71 deletions
diff --git a/nixos/doc/manual/from_md/release-notes/rl-2111.section.xml b/nixos/doc/manual/from_md/release-notes/rl-2111.section.xml
index 25f984f9378..1e732be031e 100644
--- a/nixos/doc/manual/from_md/release-notes/rl-2111.section.xml
+++ b/nixos/doc/manual/from_md/release-notes/rl-2111.section.xml
@@ -336,6 +336,13 @@
     <itemizedlist>
       <listitem>
         <para>
+          The <literal>services.wakeonlan</literal> option was removed,
+          and replaced with
+          <literal>networking.interfaces.&lt;name&gt;.wakeOnLan</literal>.
+        </para>
+      </listitem>
+      <listitem>
+        <para>
           The <literal>security.wrappers</literal> option now requires
           to always specify an owner, group and whether the
           setuid/setgid bit should be set. This is motivated by the fact
diff --git a/nixos/doc/manual/release-notes/rl-2111.section.md b/nixos/doc/manual/release-notes/rl-2111.section.md
index 40a671e3efa..3abd869d672 100644
--- a/nixos/doc/manual/release-notes/rl-2111.section.md
+++ b/nixos/doc/manual/release-notes/rl-2111.section.md
@@ -103,6 +103,8 @@ In addition to numerous new and upgraded packages, this release has the followin
 
 ## Backward Incompatibilities {#sec-release-21.11-incompatibilities}
 
+- The `services.wakeonlan` option was removed, and replaced with `networking.interfaces.<name>.wakeOnLan`.
+
 - The `security.wrappers` option now requires to always specify an owner, group and whether the setuid/setgid bit should be set.
   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.
 
diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix
index f701f38c9dd..19cb2ddb8b2 100644
--- a/nixos/modules/module-list.nix
+++ b/nixos/modules/module-list.nix
@@ -883,7 +883,6 @@
   ./services/video/unifi-video.nix
   ./services/networking/v2ray.nix
   ./services/networking/vsftpd.nix
-  ./services/networking/wakeonlan.nix
   ./services/networking/wasabibackend.nix
   ./services/networking/websockify.nix
   ./services/networking/wg-quick.nix
diff --git a/nixos/modules/services/networking/wakeonlan.nix b/nixos/modules/services/networking/wakeonlan.nix
deleted file mode 100644
index c6291366b0f..00000000000
--- a/nixos/modules/services/networking/wakeonlan.nix
+++ /dev/null
@@ -1,70 +0,0 @@
-{ config, lib, pkgs, ... }:
-
-with lib;
-
-let
-  interfaces = config.services.wakeonlan.interfaces;
-
-  ethtool = "${pkgs.ethtool}/sbin/ethtool";
-
-  passwordParameter = password : if (password == "") then "" else
-    "sopass ${password}";
-
-  methodParameter = {method, password} :
-    if method == "magicpacket" then "wol g"
-    else if method == "password" then "wol s so ${passwordParameter password}"
-    else throw "Wake-On-Lan method not supported";
-
-  line = { interface, method ? "magicpacket", password ? "" }: ''
-    ${ethtool} -s ${interface} ${methodParameter {inherit method password;}}
-  '';
-
-  concatStrings = foldr (x: y: x + y) "";
-  lines = concatStrings (map (l: line l) interfaces);
-
-in
-{
-
-  ###### interface
-
-  options = {
-
-    services.wakeonlan.interfaces = mkOption {
-      default = [ ];
-      type = types.listOf (types.submodule { options = {
-        interface = mkOption {
-          type = types.str;
-          description = "Interface to enable for Wake-On-Lan.";
-        };
-        method = mkOption {
-          type = types.enum [ "magicpacket" "password"];
-          description = "Wake-On-Lan method for this interface.";
-        };
-        password = mkOption {
-          type = types.strMatching "[a-fA-F0-9]{2}:([a-fA-F0-9]{2}:){4}[a-fA-F0-9]{2}";
-          description = "The password has the shape of six bytes in hexadecimal separated by a colon each.";
-        };
-      };});
-      example = [
-        {
-          interface = "eth0";
-          method = "password";
-          password = "00:11:22:33:44:55";
-        }
-      ];
-      description = ''
-        Interfaces where to enable Wake-On-LAN, and how. Two methods available:
-        "magicpacket" and "password". The password has the shape of six bytes
-        in hexadecimal separated by a colon each. For more information,
-        check the ethtool manual.
-      '';
-    };
-
-  };
-
-
-  ###### implementation
-
-  config.powerManagement.powerUpCommands = lines;
-
-}
diff --git a/nixos/modules/tasks/network-interfaces-scripted.nix b/nixos/modules/tasks/network-interfaces-scripted.nix
index 11bd159319a..79624ec7072 100644
--- a/nixos/modules/tasks/network-interfaces-scripted.nix
+++ b/nixos/modules/tasks/network-interfaces-scripted.nix
@@ -61,6 +61,8 @@ let
           MACAddress = i.macAddress;
         } // optionalAttrs (i.mtu != null) {
           MTUBytes = toString i.mtu;
+        } // optionalAttrs (i.wakeOnLan.enable == true) {
+          WakeOnLan = "magic";
         };
       };
     in listToAttrs (map createNetworkLink interfaces);
diff --git a/nixos/modules/tasks/network-interfaces.nix b/nixos/modules/tasks/network-interfaces.nix
index 47626bf030a..313b0fac7da 100644
--- a/nixos/modules/tasks/network-interfaces.nix
+++ b/nixos/modules/tasks/network-interfaces.nix
@@ -284,6 +284,13 @@ let
         '';
       };
 
+      wakeOnLan = {
+        enable = mkOption {
+          type = types.bool;
+          default = false;
+          description = "Wether to enable wol on this interface.";
+        };
+      };
     };
 
     config = {