1
0
Fork 0
mirror of https://github.com/nix-community/home-manager.git synced 2025-11-21 17:59:39 +01:00

services.home-manager.autoExpire: wrap systemd configuration within a isLinux condition

This commit is contained in:
Damien Cassou 2025-05-19 21:36:09 +02:00 committed by Austin Horstman
parent 45c2985644
commit 382b34f656

View file

@ -70,40 +70,40 @@ in
};
};
config = lib.mkIf cfg.enable {
assertions = [
(lib.hm.assertions.assertPlatform "services.home-manager.autoExpire" pkgs lib.platforms.linux)
];
config = lib.mkIf cfg.enable (
lib.mkMerge [
(lib.mkIf pkgs.stdenv.isLinux {
systemd.user = {
timers.home-manager-auto-expire = {
Unit.Description = "Home Manager expire generations timer";
systemd.user = {
timers.home-manager-auto-expire = {
Unit.Description = "Home Manager expire generations timer";
Install.WantedBy = [ "timers.target" ];
Install.WantedBy = [ "timers.target" ];
Timer = {
OnCalendar = cfg.frequency;
Unit = "home-manager-auto-expire.service";
Persistent = true;
};
};
Timer = {
OnCalendar = cfg.frequency;
Unit = "home-manager-auto-expire.service";
Persistent = true;
services.home-manager-auto-expire = {
Unit.Description = "Home Manager expire generations";
Service.ExecStart = toString (
pkgs.writeShellScript "home-manager-auto-expire" (
''
echo "Expire old Home Manager generations"
${homeManagerPackage}/bin/home-manager expire-generations '${cfg.timestamp}'
''
+ lib.optionalString cfg.store.cleanup ''
echo "Clean-up Nix store"
${pkgs.nix}/bin/nix-collect-garbage ${cfg.store.options}
''
)
);
};
};
};
services.home-manager-auto-expire = {
Unit.Description = "Home Manager expire generations";
Service.ExecStart = toString (
pkgs.writeShellScript "home-manager-auto-expire" (
''
echo "Expire old Home Manager generations"
${homeManagerPackage}/bin/home-manager expire-generations '${cfg.timestamp}'
''
+ lib.optionalString cfg.store.cleanup ''
echo "Clean-up Nix store"
${pkgs.nix}/bin/nix-collect-garbage ${cfg.store.options}
''
)
);
};
};
};
})
]
);
}