Made timers their own module
This commit is contained in:
parent
b2687e271a
commit
270a739287
6 changed files with 89 additions and 37 deletions
|
|
@ -16,23 +16,5 @@
|
||||||
|
|
||||||
networking.hostName = "solis";
|
networking.hostName = "solis";
|
||||||
|
|
||||||
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";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
system.stateVersion = "24.11";
|
system.stateVersion = "24.11";
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -37,5 +37,9 @@
|
||||||
terminal = {
|
terminal = {
|
||||||
zsh.enable = true;
|
zsh.enable = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
timers = {
|
||||||
|
backup.enable = true;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,24 +16,5 @@
|
||||||
|
|
||||||
networking.hostName = "terra";
|
networking.hostName = "terra";
|
||||||
|
|
||||||
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";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
system.stateVersion = "24.11";
|
system.stateVersion = "24.11";
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -50,5 +50,9 @@
|
||||||
terminal = {
|
terminal = {
|
||||||
zsh.enable = true;
|
zsh.enable = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
timers = {
|
||||||
|
wol.enable = true;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
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