1
0
Fork 0
mirror of https://github.com/nix-community/home-manager.git synced 2025-11-08 19:46:05 +01:00

services.home-manager.autoExpire: add support for darwin

This commit is contained in:
Damien Cassou 2025-05-19 21:44:03 +02:00 committed by Austin Horstman
parent 04ebd2c422
commit 2097441633
6 changed files with 77 additions and 0 deletions

View file

@ -55,6 +55,8 @@ in
as the `OnCalendar` option.
The format is described in {manpage}`systemd.time(7)`.
${lib.hm.darwin.intervalDocumentation}
'';
};
@ -104,6 +106,23 @@ in
};
};
})
(lib.mkIf pkgs.stdenv.isDarwin {
assertions = [
(lib.hm.darwin.assertInterval "services.home-manager.autoExpire.frequency" cfg.frequency pkgs)
];
launchd.agents.home-manager-auto-expire = {
enable = true;
config = {
ProgramArguments = [ (toString script) ];
ProcessType = "Background";
StartCalendarInterval = lib.hm.darwin.mkCalendarInterval cfg.frequency;
StandardOutPath = "${config.home.homeDirectory}/Library/Logs/home-manager-auto-expire/launchd-stdout.log";
StandardErrorPath = "${config.home.homeDirectory}/Library/Logs/home-manager-auto-expire/launchd-stderr.log";
};
};
})
]
);
}

View file

@ -335,6 +335,7 @@ import nmtSrc {
./modules/services/emacs-darwin
./modules/services/espanso-darwin
./modules/services/git-sync-darwin
./modules/services/home-manager-auto-expire-darwin
./modules/services/imapnotify-darwin
./modules/services/jankyborders
./modules/services/macos-remap-keys

View file

@ -0,0 +1,14 @@
{
services.home-manager.autoExpire = {
enable = true;
frequency = "weekly";
};
nmt.script = ''
serviceFile=LaunchAgents/org.nix-community.home.home-manager-auto-expire.plist
assertFileExists "$serviceFile"
serviceFileNormalized="$(normalizeStorePaths "$serviceFile")"
assertFileContent "$serviceFileNormalized" ${./expected-agent.plist}
'';
}

View file

@ -0,0 +1,4 @@
{
darwin-home-manager-autoExpire-service-basic-configuration = ./basic-configuration.nix;
darwin-home-manager-autoExpire-frequency-assertion = ./frequency-assertion.nix;
}

View file

@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>org.nix-community.home.home-manager-auto-expire</string>
<key>ProcessType</key>
<string>Background</string>
<key>ProgramArguments</key>
<array>
<string>/nix/store/00000000000000000000000000000000-home-manager-auto-expire</string>
</array>
<key>StandardErrorPath</key>
<string>/home/hm-user/Library/Logs/home-manager-auto-expire/launchd-stderr.log</string>
<key>StandardOutPath</key>
<string>/home/hm-user/Library/Logs/home-manager-auto-expire/launchd-stdout.log</string>
<key>StartCalendarInterval</key>
<array>
<dict>
<key>Hour</key>
<integer>0</integer>
<key>Minute</key>
<integer>0</integer>
<key>Weekday</key>
<integer>1</integer>
</dict>
</array>
</dict>
</plist>

View file

@ -0,0 +1,10 @@
{
services.home-manager.autoExpire = {
enable = true;
frequency = "00:02:00";
};
test.asserts.assertions.expected = [
"On Darwin services.home-manager.autoExpire.frequency must be one of: hourly, daily, weekly, monthly, semiannually, annually."
];
}