nh: fix clean option behaviour for Darwin
This commit is contained in:
parent
78fc50f1cf
commit
e8a3e2c1e0
6 changed files with 77 additions and 5 deletions
|
|
@ -37,7 +37,9 @@ in
|
|||
description = ''
|
||||
How often cleanup is performed.
|
||||
|
||||
The format is described in {manpage}`systemd.time(7)`.
|
||||
On linux the format is described in {manpage}`systemd.time(7)`.
|
||||
|
||||
${lib.hm.darwin.intervalDocumentation}
|
||||
'';
|
||||
};
|
||||
|
||||
|
|
@ -59,6 +61,10 @@ in
|
|||
lib.optional (cfg.clean.enable && config.nix.gc.automatic)
|
||||
"programs.nh.clean.enable and nix.gc.automatic (Home-Manager) are both enabled. Please use one or the other to avoid conflict.";
|
||||
|
||||
assertions = lib.optionals pkgs.stdenv.isDarwin [
|
||||
(lib.hm.darwin.assertInterval "programs.nh.clean.dates" cfg.clean.dates pkgs)
|
||||
];
|
||||
|
||||
home = lib.mkIf cfg.enable {
|
||||
packages = [ cfg.package ];
|
||||
sessionVariables = lib.mkIf (cfg.flake != null) (
|
||||
|
|
@ -70,7 +76,7 @@ in
|
|||
);
|
||||
};
|
||||
|
||||
systemd.user = lib.mkIf cfg.clean.enable {
|
||||
systemd.user = lib.mkIf (cfg.clean.enable && pkgs.stdenv.isLinux) {
|
||||
services.nh-clean = {
|
||||
Unit.Description = "Nh clean (user)";
|
||||
|
||||
|
|
@ -90,6 +96,21 @@ in
|
|||
|
||||
Install.WantedBy = [ "timers.target" ];
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
launchd.agents.nh-clean = lib.mkIf (cfg.clean.enable && pkgs.stdenv.isDarwin) {
|
||||
enable = true;
|
||||
config = {
|
||||
ProgramArguments = [
|
||||
"${lib.getExe cfg.package}"
|
||||
"clean"
|
||||
"user"
|
||||
] ++ lib.optional (cfg.clean.extraArgs != "") cfg.clean.extraArgs;
|
||||
|
||||
StartCalendarInterval = lib.hm.darwin.mkCalendarInterval cfg.clean.dates;
|
||||
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue