feat(users): cleanup old home-manager profiles

This commit is contained in:
Malte Tammena 2024-02-03 21:02:24 +01:00
parent 6d363ea446
commit dc9251000e
4 changed files with 50 additions and 1 deletions

View file

@ -29,6 +29,7 @@ in {
imports = [
../modules/boilr.nix
../modules/restic-backup.nix
../modules/profiles-cleanup.nix
];
config = {
@ -48,6 +49,8 @@ in {
};
};
xdg.enable = true;
# Make sure firefox is my default browser
programs.firefox.enable = true;

View file

@ -118,6 +118,7 @@ in {
./nb.nix
../modules/restic-backup.nix
../modules/colors.nix
../modules/profiles-cleanup.nix
];
config = {
@ -208,6 +209,8 @@ in {
};
};
xdg.enable = true;
# Make sure firefox is my default browser
programs.firefox.enable = true;

View file

@ -18,7 +18,10 @@
];
}));
in {
imports = [../modules/restic-backup.nix];
imports = [
../modules/restic-backup.nix
../modules/profiles-cleanup.nix
];
config = {
home.packages = with pkgs; [
@ -46,6 +49,8 @@ in {
programs.broot.enable = true;
programs.fish.enable = true;
xdg.enable = true;
services.restic = {
enable = true;
paths = ["/home/marie/Uni" "/home/marie/Bilder" "/home/marie/Promotion"];

View file

@ -0,0 +1,38 @@
{
pkgs,
lib,
config,
...
}: {
# This is a fix for https://github.com/nix-community/home-manager/issues/4672
systemd.user = {
services = {
home-manager-profiles-cleanup = {
Unit.Description = "Clean up HM user profiles.";
Service = {
Type = "oneshot";
ExecStart = lib.getExe (pkgs.writeShellApplication {
name = "home-manager-profiles-cleanup-start-script";
text = ''
${lib.getExe config.nix.package} profile wipe-history \
--profile "${config.xdg.stateHome}/nix/profiles/home-manager" \
--older-than '30d'
'';
});
};
};
};
timers.home-manager-profiles-cleanup = {
Unit.Description = "Clean up HM user profiles.";
Timer = {
OnCalendar = "weekly";
Persistent = true;
};
Install.WantedBy = ["timers.target"];
};
};
}