diff options
| author | quentin@aristote.fr <quentin@aristote.fr> | 2023-10-29 19:26:40 +0100 |
|---|---|---|
| committer | quentin@aristote.fr <quentin@aristote.fr> | 2023-10-29 19:36:45 +0100 |
| commit | 73266ed6c2ddb39ee86a871156de58751c1dbfc4 (patch) | |
| tree | 756226a222e543e0b5d7a02e6a40a0aff253fddb /modules | |
| parent | 1138bb1c1fbe2bd1c91aa0fc2105a5be97b0495f (diff) | |
nixos: nix-gc: remove old hm generations
Diffstat (limited to 'modules')
| -rw-r--r-- | modules/nixos/personal/nix.nix | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/modules/nixos/personal/nix.nix b/modules/nixos/personal/nix.nix index 35d7fc7..9c8db45 100644 --- a/modules/nixos/personal/nix.nix +++ b/modules/nixos/personal/nix.nix @@ -54,6 +54,17 @@ in { wantedBy = lib.mkIf config.nix.gc.automatic ["nix-gc.service"]; personal.monitor = true; }; + nix-gc-remove-old-hm-gens = let + user = config.personal.user; + in { + enable = cfg.gc.enable && user.enable && user.homeManager.enable; + description = "Remove old Home Manager generations for user ${user.name}"; + serviceConfig.Type = "oneshot"; + script = "${pkgs.nix}/bin/nix-env --profile /home/${user.name}/.local/state/nix/profiles/home-manager --delete-generations old"; + before = lib.mkIf config.nix.gc.automatic ["nix-gc.service"]; + wantedBy = lib.mkIf config.nix.gc.automatic ["nix-gc.service"]; + personal.monitor = true; + }; }; programs.git = lib.mkIf (cfg.flake != null && lib.hasPrefix "git+file" cfg.flake) { enable = true; |
