diff --git a/hosts/ymir/configuration.nix b/hosts/ymir/configuration.nix index 67f71a7..7ea69cd 100644 --- a/hosts/ymir/configuration.nix +++ b/hosts/ymir/configuration.nix @@ -22,6 +22,7 @@ enableJellyfin = true; enableAarch64Emulation = true; disableHibernation = true; + enableWakeOnLan = true; }; # Bootloader. @@ -39,25 +40,9 @@ # Enable networking networking.networkmanager.enable = true; - networking.interfaces.enp3s0.wakeOnLan.enable = true; - # The services doesn't actually work atm, define an additional service - # see https://github.com/NixOS/nixpkgs/issues/91352 - systemd.services.wakeonlan = { - description = "Reenable wake on lan every boot"; - after = ["network.target"]; - serviceConfig = { - Type = "simple"; - RemainAfterExit = "true"; - ExecStart = "${pkgs.ethtool}/sbin/ethtool -s enp3s0 wol g"; - }; - wantedBy = ["default.target"]; - }; - hardware.nvidia-container-toolkit.enable = true; - # hardware.nvidia.package = config.boot.kernelPackages.nvidiaPackages.stable; # Enable OpenGL - programs.nix-required-mounts.enable = true; programs.nix-required-mounts.presets.nvidia-gpu.enable = true; # TODO: this ugly thing is necessary until this issue is resolved diff --git a/modules/default.nix b/modules/default.nix index b09c7ac..541af36 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -14,5 +14,6 @@ ./secrets.nix ./tailscale.nix ./users.nix + ./wake-on-lan.nix ]; } diff --git a/modules/wake-on-lan.nix b/modules/wake-on-lan.nix new file mode 100644 index 0000000..fa1b0d5 --- /dev/null +++ b/modules/wake-on-lan.nix @@ -0,0 +1,32 @@ +{ + pkgs, + lib, + config, + ... +}: { + options = { + myModules.enableWakeOnLan = lib.mkOption { + type = lib.types.bool; + default = false; + description = "Enable Wake on LAN"; + }; + }; + + config = lib.mkMerge [ + (lib.mkIf config.myModules.enableWakeOnLan { + networking.interfaces.enp3s0.wakeOnLan.enable = true; + # The services doesn't actually work atm, define an additional service + # see https://github.com/NixOS/nixpkgs/issues/91352 + systemd.services.wakeonlan = { + description = "Reenable wake on lan every boot"; + after = ["network.target"]; + serviceConfig = { + Type = "simple"; + RemainAfterExit = "true"; + ExecStart = "${pkgs.ethtool}/sbin/ethtool -s enp3s0 wol g"; + }; + wantedBy = ["default.target"]; + }; + }) + ]; +}