From a899d5b15968ca90c33ecc335d80321a1f8be612 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonardo=20Eug=C3=AAnio?= Date: Thu, 27 Mar 2025 01:07:27 -0300 Subject: [PATCH] home: add automatic home-manager cleanup service --- user/home-manager.nix | 28 ++++++++++++++++++++++++++++ user/home.nix | 3 +-- 2 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 user/home-manager.nix diff --git a/user/home-manager.nix b/user/home-manager.nix new file mode 100644 index 0000000..9c8452a --- /dev/null +++ b/user/home-manager.nix @@ -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" ]; + }; + }; +} diff --git a/user/home.nix b/user/home.nix index 271ceee..31e3871 100644 --- a/user/home.nix +++ b/user/home.nix @@ -9,6 +9,7 @@ { imports = [ ./dummy.nix + ./home-manager.nix ./waybar ./helix.nix ./kakoune @@ -58,8 +59,6 @@ home.username = "lelgenio"; home.homeDirectory = "/home/lelgenio"; - # Let Home Manager install and manage itself. - programs.home-manager.enable = true; home.packages = with pkgs; [ terminal