feat(chen): WoL

This commit is contained in:
arcnmx 2024-05-11 12:33:10 -07:00
parent 6cfaf82535
commit 81ae90dd12
12 changed files with 77 additions and 4 deletions

31
nixos/wake-chen.nix Normal file
View file

@ -0,0 +1,31 @@
{
config,
pkgs,
gensokyo-zone,
lib,
...
}: let
inherit (gensokyo-zone.lib) mapOptionDefaults;
inherit (lib.meta) getExe;
chen = gensokyo-zone.systems.chen.config;
service = "wake-chen";
in {
systemd.services.${service} = {
path = [ pkgs.wol ];
script = ''
exec wol ${chen.network.networks.local.macAddress}
'';
environment = mapOptionDefaults {
WOL_MAC_ADDRESS = chen.network.networks.local.macAddress;
};
serviceConfig = mapOptionDefaults {
Type = "oneshot";
RemainAfterExit = false;
} // {
ExecStart = [
"${getExe pkgs.wol} $WOL_MAC_ADDRESS"
];
};
};
services.systemd2mqtt.units = [ "${service}.service" ];
}