@@ -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−}