cleanNix: set systemd timer

This commit is contained in:
2026-05-18 19:16:09 +02:00
parent 9425c5f740
commit d71a5e4356
3 changed files with 46 additions and 1 deletions
+45
View File
@@ -0,0 +1,45 @@
{pkgs, ...}: {
# Ensure your script is available system-wide
environment.systemPackages = [
(pkgs.callPackage ../scripts/cleanNix.nix {})
];
users.users.tomasr = {
linger = true; # lingering is required
};
systemd.user.services.custom-autoupdate = {
description = "NixOS configuration auto cleanup";
serviceConfig = {
Type = "oneshot";
ExecStart = "/run/current-system/sw/bin/custom-cleanNix";
# safety for long rebuilds
TimeoutStartSec = "45min";
TimeoutStopSec = "10min";
# avoid overlap
RemainAfterExit = true;
# tweaks that should make the system run normally during the rebuilds
Nice = 10;
IOSchedulingClass = "best-effort";
IOSchedulingPriority = 7;
};
};
# Systemd USER timer
systemd.user.timers.custom-autoupdate = {
wantedBy = ["timers.target"];
timerConfig = {
OnCalendar = "Sat *-*-* 20:00:00"; # runs saturday night. If for whatever reason something breaks. I have whole sunday to fix it.
Persistent = true; # if it happens during shutted down
# avoids thundering herd on boot
RandomizedDelaySec = "2h";
};
};
}