wake-on-lan: move to module

main
Zynh Ludwig 2024-09-13 19:16:49 -07:00
parent ce1d38f3f2
commit 0f4d2374bf
2 changed files with 27 additions and 12 deletions

View File

@ -2,7 +2,7 @@
# your system. Help is available in the configuration.nix(5) man page
# and in the NixOS manual (accessible by running `nixos-help`).
{ pkgs, inputs, lib, config, ... }:
{ pkgs, inputs, config, ... }:
{
imports = [
@ -19,6 +19,7 @@
snowhawk = {
nix-ld.enable = true;
wake-on-lan.enable = true;
dwm.enable = true;
syncthing.enable = true;
plymouth.enable = true;
@ -104,17 +105,6 @@
services.avahi.enable = true;
systemd.services.wakeonlan = {
description = "reenable wakeonlan every boot";
after = [ "network.target" ];
serviceConfig = {
Type = "simple";
RemainAfterExit = "true";
ExecStart = "${lib.getExe pkgs.ethtool} -s enp7s0 wol g";
};
wantedBy = [ "default.target" ];
};
# Open ports in the firewall.
# networking.firewall.allowedTCPPorts = [ ... ];
# networking.firewall.allowedUDPPorts = [ ... ];

25
modules/wake-on-lan.nix Normal file
View File

@ -0,0 +1,25 @@
{ config, lib, pkgs, ... }:
let
inherit (lib) mkIf mkEnableOption;
cfg = config.snowhawk.wake-on-lan;
in
{
options.snowhawk.wake-on-lan = {
enable = mkEnableOption "wake-on-lan nixos module";
};
config = mkIf cfg.enable {
systemd.services.wakeonlan = {
description = "reenable wakeonlan every boot";
after = [ "network.target" ];
serviceConfig = {
Type = "simple";
RemainAfterExit = "true";
ExecStart = "${lib.getExe pkgs.ethtool} -s enp7s0 wol g";
};
wantedBy = [ "default.target" ];
};
};
}