41 lines
849 B
Nix
41 lines
849 B
Nix
{
|
|
lib,
|
|
config,
|
|
pkgs,
|
|
...
|
|
}: 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 = ''
|
|
#!/run/current-system/sw/bin/zsh
|
|
cd /home/horseman/nix-config
|
|
git pull
|
|
sudo nix flake update
|
|
rebuild .#${config.networking.hostName}
|
|
git commit flake.lock -m "Update flake"
|
|
git push
|
|
'';
|
|
serviceConfig = {
|
|
Type = "oneshot";
|
|
User = "root";
|
|
};
|
|
};
|
|
};
|
|
}
|