home: add automatic home-manager cleanup service

This commit is contained in:
Leonardo Eugênio 2025-03-27 01:07:27 -03:00
parent 0f61393bf3
commit 8cae611cd5
No known key found for this signature in database
GPG key ID: 2F8F21CE8721456B
2 changed files with 29 additions and 2 deletions

28
user/home-manager.nix Normal file
View file

@ -0,0 +1,28 @@
{ pkgs, lib, ... }:
{
programs.home-manager.enable = true;
systemd.user.services.home-manager-expire = {
Unit = {
Description = "Remove old home-manager generations";
};
Service = {
Type = "oneshot";
ExecStart = pkgs.writeShellScript "home-manager-expire" ''
${lib.getExe pkgs.home-manager} expire-generations 7d
'';
};
};
systemd.user.timers.home-manager-expire = {
Unit = {
Description = "Remove old home-manager generations";
};
Timer = {
OnCalendar = "daily";
Unit = "home-manager-expire.service";
};
Install = {
WantedBy = [ "timers.target" ];
};
};
}