add flake updating timer

This commit is contained in:
KoenDR06 2025-11-19 21:55:01 +01:00
parent 22fb3d09f3
commit 81c5ee9778
3 changed files with 41 additions and 0 deletions

View file

@ -33,6 +33,7 @@
timers = {
backup.enable = true;
rooms.enable = true;
flakeUpdate.enable = true;
};
};
}

View file

@ -3,5 +3,6 @@
./wol.nix
./backup.nix
./rooms.nix
./flakeUpdate.nix
];
}

View file

@ -0,0 +1,39 @@
{
lib,
config,
...
}: let
inherit (lib) mkEnableOption mkIf;
cfg = config.horseman.timers.flakeUpdate;
in {
options = {
horseman.timers.flakeUpdate = {
enable = mkEnableOption "Updates flake.nix weekly";
};
};
config = mkIf cfg.enable {
systemd.timers."flake-update" = {
wantedBy = ["timers.target"];
timerConfig = {
OnCalendar = "weekly";
Persistent = true;
};
};
systemd.services."flake-update" = {
script = ''
cd /home/horseman/nix-config
git pull
nix flake update
rebuild .#${config.networking.hostName}
git commit flake.lock -m "Update flake"
git push
'';
serviceConfig = {
Type = "oneshot";
User = "root";
};
};
};
}