Add wake online
This commit is contained in:
32
modules/optionnals/wakeonlan.nix
Normal file
32
modules/optionnals/wakeonlan.nix
Normal file
@@ -0,0 +1,32 @@
|
||||
{
|
||||
config,
|
||||
pkgs,
|
||||
hostname,
|
||||
...
|
||||
}:
|
||||
{
|
||||
systemd.services."wol@$${config.my.lanInterface}" = {
|
||||
description = "Wake-on-LAN for ${config.my.lanInterface}";
|
||||
after = [ "network.target" ];
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
serviceConfig = {
|
||||
Type = "oneshot";
|
||||
ExecStart = "${pkgs.ethtool}/bin/ethtool -s ${config.my.lanInterface} wol g";
|
||||
RandomizedDelaySec = "30s";
|
||||
};
|
||||
};
|
||||
environment.systemPackages = [ pkgs.ethtool ];
|
||||
|
||||
boot.initrd.network = {
|
||||
enable = true;
|
||||
ssh = {
|
||||
enable = true;
|
||||
port = 2222;
|
||||
authorizedKeys = [ "ssh-ed25519 AAAA..." ]; # ta clé publique
|
||||
hostKeys = [ "/etc/secrets/initrd/ssh_host_ed25519_key" ];
|
||||
};
|
||||
};
|
||||
boot.kernelParams = [
|
||||
"ip=192.168.0.2::192.168.0.254:255.255.255.0:${hostname}:${config.my.lanInterface}:off"
|
||||
];
|
||||
}
|
||||
Reference in New Issue
Block a user