add flake updating timer
This commit is contained in:
parent
22fb3d09f3
commit
81c5ee9778
3 changed files with 41 additions and 0 deletions
|
|
@ -33,6 +33,7 @@
|
||||||
timers = {
|
timers = {
|
||||||
backup.enable = true;
|
backup.enable = true;
|
||||||
rooms.enable = true;
|
rooms.enable = true;
|
||||||
|
flakeUpdate.enable = true;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,5 +3,6 @@
|
||||||
./wol.nix
|
./wol.nix
|
||||||
./backup.nix
|
./backup.nix
|
||||||
./rooms.nix
|
./rooms.nix
|
||||||
|
./flakeUpdate.nix
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
39
modules/timers/flakeUpdate.nix
Normal file
39
modules/timers/flakeUpdate.nix
Normal 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";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue