Made timers their own module
This commit is contained in:
parent
b2687e271a
commit
270a739287
6 changed files with 89 additions and 37 deletions
40
modules/timers/backup.nix
Normal file
40
modules/timers/backup.nix
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
{
|
||||
inputs,
|
||||
outputs,
|
||||
lib,
|
||||
config,
|
||||
pkgs,
|
||||
...
|
||||
}: let
|
||||
inherit (lib) mkEnableOption mkIf mkOption types;
|
||||
cfg = config.horseman.timers.backup;
|
||||
homeCfg = config.horseman;
|
||||
in {
|
||||
options = {
|
||||
horseman.timers.backup = {
|
||||
enable = mkEnableOption "Enables the backup service";
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
assert homeCfg.network.syncthing || throw "Syncthing has not been enabled on this machine, refusing to add timer.";
|
||||
|
||||
systemd.timers."backupsyncthing" = {
|
||||
wantedby = ["timers.target"];
|
||||
timerconfig = {
|
||||
oncalendar = "weekly";
|
||||
persistent = true;
|
||||
};
|
||||
};
|
||||
|
||||
systemd.services."backupsyncthing" = {
|
||||
script = ''
|
||||
/home/horseman/nix-config/misc/backup.sh
|
||||
'';
|
||||
serviceconfig = {
|
||||
type = "oneshot";
|
||||
user = "horseman";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
41
modules/timers/wol.nix
Normal file
41
modules/timers/wol.nix
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
{
|
||||
inputs,
|
||||
outputs,
|
||||
lib,
|
||||
config,
|
||||
pkgs,
|
||||
...
|
||||
}: let
|
||||
inherit (lib) mkEnableOption mkIf mkOption types;
|
||||
cfg = config.horseman.timers.wol;
|
||||
homeCfg = config.horseman;
|
||||
in {
|
||||
options = {
|
||||
horseman.timers.wol = {
|
||||
enable = mkEnableOption "Enables Wake on LAN on boot";
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
assert homeCfg.apps.terminal || throw "wakeonlan has not been not installed on this machine, refusing to add timer.";
|
||||
|
||||
systemd.timers."enable-wol" = {
|
||||
wantedBy = ["timers.target"];
|
||||
timerConfig = {
|
||||
OnBootSec = "5m";
|
||||
OnUnitActiveSec = "1m";
|
||||
Unit = "enable-wol.service";
|
||||
};
|
||||
};
|
||||
|
||||
systemd.services."enable-wol" = {
|
||||
script = ''
|
||||
/home/horseman/nix-config/misc/startup.sh
|
||||
'';
|
||||
serviceConfig = {
|
||||
Type = "oneshot";
|
||||
User = "root";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue