mirror of
https://github.com/JaxTheWolf/nixos.git
synced 2026-04-01 02:00:22 +02:00
services.nix: delete old generations, automatically run gc
This commit is contained in:
@@ -151,5 +151,23 @@
|
||||
Persistent = true;
|
||||
};
|
||||
};
|
||||
services."nix-prune-generations" = {
|
||||
description = "Keep only 5 system generations and run nix-collect-garbage";
|
||||
serviceConfig = {
|
||||
Type = "oneshot";
|
||||
ExecStart = ''
|
||||
${pkgs.nix}/bin/nix-env -p /nix/var/nix/profiles/system --delete-generations +5 || true
|
||||
${pkgs.nix}/bin/nix-collect-garbage -d || true
|
||||
'';
|
||||
Nice = "10";
|
||||
};
|
||||
};
|
||||
timers."nix-prune-generations" = {
|
||||
wantedBy = [ "timers.target" ];
|
||||
timerConfig = {
|
||||
OnCalendar = "weekly";
|
||||
Persistent = true;
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user