2021-07-08 22:27:52 +00:00
|
|
|
{ pkgs, config, ... }:
|
2021-07-09 11:39:48 +00:00
|
|
|
let
|
|
|
|
|
|
|
|
configPath = "${config.home.homeDirectory}/git/config";
|
|
|
|
configGit = "${pkgs.git}/bin/git -C ${configPath}";
|
|
|
|
script = pkgs.writeShellScript "hourly-maintenance" ''
|
|
|
|
set -e
|
|
|
|
${configGit} fetch
|
|
|
|
if [[ "$(${configGit} rev-parse master)" == "$(${configGit} rev-parse origin/master)" ]]; then
|
|
|
|
echo "Git repo up-to-date, not doing anything."
|
|
|
|
exit 0;
|
|
|
|
else
|
2022-03-07 18:40:12 +00:00
|
|
|
${pkgs.foot}/bin/foot --hold ${config.home.profileDirectory}/bin/maintenance
|
2021-07-09 11:39:48 +00:00
|
|
|
fi
|
|
|
|
'';
|
|
|
|
in
|
2021-07-08 22:27:52 +00:00
|
|
|
{
|
|
|
|
systemd.user = {
|
|
|
|
services.maintenance = {
|
|
|
|
Unit.Description = "Routine maintenance";
|
|
|
|
Service = {
|
|
|
|
Type = "oneshot";
|
2021-07-09 11:39:48 +00:00
|
|
|
ExecStart = toString script;
|
2021-07-08 22:27:52 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
timers.maintenance = {
|
|
|
|
Unit.Description = "Hourly maintenance";
|
|
|
|
Timer.OnCalendar = "hourly";
|
|
|
|
Install.WantedBy = [ "timers.target" ];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|