all repos — nixfiles @ 74faf88c4f59a235c598cc9fdc76b2e07b9e4c39

System and user configuration, managed by nix and home-manager

darwin: auto-expire old home-manager generations
Alan Pearce alan@alanpearce.eu
Sun, 02 Apr 2023 20:26:42 +0200
commit

74faf88c4f59a235c598cc9fdc76b2e07b9e4c39

parent

843c2c669e0545eea3c2b7876aa6b83b24de03b6

1 files changed, 23 insertions(+), 0 deletions(-)

jump to
M user/settings/darwin.nixuser/settings/darwin.nix
@@ -42,6 +42,29 @@ programs.emacs.package = pkgs.emacs; 
   home.file.".hushlogin".text = "";
 
+  launchd.agents = {
+    home-manager-expire-generations = {
+      enable = true;
+
+      config = {
+        ProgramArguments = [
+          "${pkgs.home-manager}/bin/home-manager"
+          "expire-generations"
+          "-30 days"
+        ];
+        KeepAlive = false;
+        RunAtLoad = false;
+        StartCalendarInterval = [{
+          Hour = 12;
+          Minute = 00;
+          Weekday = 6; # Saturday
+        }];
+        ProcessType = "Background";
+        LowPriorityBackgroundIO = true;
+      };
+    };
+  };
+
   programs.zsh.shellAliases = {
     da = "darwin-rebuild";
     das = "darwin-rebuild switch";