commit bf4873eb012235b4d82cd79c4f508064ead301ab Author: Joao Porta <jpedro.porta@gmail.com> Date: Fri Jul 17 17:24:26 2026 -0300 wake on lan
2.0 KiB
2.0 KiB
1. Create the WOL NixOS module
- 1.1 Create
modules/nixos/wake-on-lan/default.nixwith acustom.wake-on-lan.enableoption. - 1.2 Define a systemd
oneshotservicewol-enp14s0.servicethat runsethtool -s enp14s0 wol g. - 1.3 Wire the unit's
after/wantstonetwork-online.targetandNetworkManager.serviceso it runs after the link is up. - 1.4 Add the unit to the resume path so
wol gis re-applied after suspend/resume (usesystemd-suspend.serviceor apathunit hook).
2. Add packages and the convenience wrapper
- 2.1 Add
pkgs.ethtoolandpkgs.wakeonlantoenvironment.systemPackageswhen the module is enabled. (Note:pkgs.iputilsdoes not providewakeonlanin nixpkgs — see implementation note.) - 2.2 Create a
wake-jpporta-nixosshell script viapkgs.writeShellScriptBinthat invokeswakeonlan -i ${1:-255.255.255.255} d8:43:ae:5a:ae:12. - 2.3 Add the wrapper to
environment.systemPackages.
3. Wire the module into the host
- 3.1 Add
../../modules/nixos/wake-on-lantoimportsinhosts/jpporta-nixos/configuration.nix. - 3.2 Add
custom.wake-on-lan.enable = true;under the existingcustom = { ... };block in the host config.
4. Verify and document
- 4.1 Rebuild the system with
sudo nixos-rebuild switch --flake .#jpporta-nixos. - 4.2 Run
ethtool enp14s0and confirmSupports Wake-on:listsgandWake-on: g. - 4.3 Run
systemctl status wol-enp14s0.serviceand confirm the unit isactive (exited). - 4.4 Run
wake-jpporta-nixosonce while the machine is up to confirm the script runs without error (it will be a no-op when the host is already up). - 4.5 Shut the machine down, then run
wake-jpporta-nixosfrom another machine on the same LAN and confirmjpporta-nixospowers on. - 4.6 Document the BIOS-level prerequisite ("Wake on LAN" enabled, "After Power Loss" → Power Off / Stay Off) in the change notes or a README so it's not lost.