diff --git a/modules/programs/git.nix b/modules/programs/git.nix
index 385885861..6862888de 100644
--- a/modules/programs/git.nix
+++ b/modules/programs/git.nix
@@ -753,6 +753,54 @@ in
};
in
lib.attrsets.mapAttrs' toSystemdTimer cfg.maintenance.timers;
+
+ launchd.agents =
+ let
+ baseArguments = [
+ "${lib.getExe cfg.package}"
+ "for-each-repo"
+ "--keep-going"
+ "--config=maintenance.repo"
+ "maintenance"
+ "run"
+ ];
+ in
+ {
+ "git-maintenance-hourly" = {
+ enable = true;
+ config = {
+ ProgramArguments = baseArguments ++ [ "--schedule=hourly" ];
+ StartCalendarInterval = map (hour: {
+ Hour = hour;
+ Minute = 53;
+ }) (lib.range 1 23);
+ };
+ };
+ "git-maintenance-daily" = {
+ enable = true;
+ config = {
+ ProgramArguments = baseArguments ++ [ "--schedule=daily" ];
+ StartCalendarInterval = map (weekday: {
+ Weekday = weekday;
+ Hour = 0;
+ Minute = 53;
+ }) (lib.range 1 6);
+ };
+ };
+ "git-maintenance-weekly" = {
+ enable = true;
+ config = {
+ ProgramArguments = baseArguments ++ [ "--schedule=weekly" ];
+ StartCalendarInterval = [
+ {
+ Weekday = 0;
+ Hour = 0;
+ Minute = 53;
+ }
+ ];
+ };
+ };
+ };
})
(mkIf cfg.diff-highlight.enable {
diff --git a/tests/modules/programs/git/default.nix b/tests/modules/programs/git/default.nix
index 4c7baa6ab..631b7f137 100644
--- a/tests/modules/programs/git/default.nix
+++ b/tests/modules/programs/git/default.nix
@@ -8,4 +8,5 @@
git-without-signing-key-id = ./git-without-signing-key-id.nix;
git-without-signing = ./git-without-signing.nix;
git-with-hooks = ./git-with-hooks.nix;
+ git-with-maintenance = ./git-with-maintenance.nix;
}
diff --git a/tests/modules/programs/git/expected-agent-daily.plist b/tests/modules/programs/git/expected-agent-daily.plist
new file mode 100644
index 000000000..d96a936aa
--- /dev/null
+++ b/tests/modules/programs/git/expected-agent-daily.plist
@@ -0,0 +1,69 @@
+
+
+
+
+ Label
+ org.nix-community.home.git-maintenance-daily
+ ProgramArguments
+
+ @git@/bin/git
+ for-each-repo
+ --keep-going
+ --config=maintenance.repo
+ maintenance
+ run
+ --schedule=daily
+
+ StartCalendarInterval
+
+
+ Hour
+ 0
+ Minute
+ 53
+ Weekday
+ 1
+
+
+ Hour
+ 0
+ Minute
+ 53
+ Weekday
+ 2
+
+
+ Hour
+ 0
+ Minute
+ 53
+ Weekday
+ 3
+
+
+ Hour
+ 0
+ Minute
+ 53
+ Weekday
+ 4
+
+
+ Hour
+ 0
+ Minute
+ 53
+ Weekday
+ 5
+
+
+ Hour
+ 0
+ Minute
+ 53
+ Weekday
+ 6
+
+
+
+
\ No newline at end of file
diff --git a/tests/modules/programs/git/expected-agent-hourly.plist b/tests/modules/programs/git/expected-agent-hourly.plist
new file mode 100644
index 000000000..99ade743a
--- /dev/null
+++ b/tests/modules/programs/git/expected-agent-hourly.plist
@@ -0,0 +1,159 @@
+
+
+
+
+ Label
+ org.nix-community.home.git-maintenance-hourly
+ ProgramArguments
+
+ @git@/bin/git
+ for-each-repo
+ --keep-going
+ --config=maintenance.repo
+ maintenance
+ run
+ --schedule=hourly
+
+ StartCalendarInterval
+
+
+ Hour
+ 1
+ Minute
+ 53
+
+
+ Hour
+ 2
+ Minute
+ 53
+
+
+ Hour
+ 3
+ Minute
+ 53
+
+
+ Hour
+ 4
+ Minute
+ 53
+
+
+ Hour
+ 5
+ Minute
+ 53
+
+
+ Hour
+ 6
+ Minute
+ 53
+
+
+ Hour
+ 7
+ Minute
+ 53
+
+
+ Hour
+ 8
+ Minute
+ 53
+
+
+ Hour
+ 9
+ Minute
+ 53
+
+
+ Hour
+ 10
+ Minute
+ 53
+
+
+ Hour
+ 11
+ Minute
+ 53
+
+
+ Hour
+ 12
+ Minute
+ 53
+
+
+ Hour
+ 13
+ Minute
+ 53
+
+
+ Hour
+ 14
+ Minute
+ 53
+
+
+ Hour
+ 15
+ Minute
+ 53
+
+
+ Hour
+ 16
+ Minute
+ 53
+
+
+ Hour
+ 17
+ Minute
+ 53
+
+
+ Hour
+ 18
+ Minute
+ 53
+
+
+ Hour
+ 19
+ Minute
+ 53
+
+
+ Hour
+ 20
+ Minute
+ 53
+
+
+ Hour
+ 21
+ Minute
+ 53
+
+
+ Hour
+ 22
+ Minute
+ 53
+
+
+ Hour
+ 23
+ Minute
+ 53
+
+
+
+
\ No newline at end of file
diff --git a/tests/modules/programs/git/expected-agent-weekly.plist b/tests/modules/programs/git/expected-agent-weekly.plist
new file mode 100644
index 000000000..dbcdac9b4
--- /dev/null
+++ b/tests/modules/programs/git/expected-agent-weekly.plist
@@ -0,0 +1,29 @@
+
+
+
+
+ Label
+ org.nix-community.home.git-maintenance-weekly
+ ProgramArguments
+
+ @git@/bin/git
+ for-each-repo
+ --keep-going
+ --config=maintenance.repo
+ maintenance
+ run
+ --schedule=weekly
+
+ StartCalendarInterval
+
+
+ Hour
+ 0
+ Minute
+ 53
+ Weekday
+ 0
+
+
+
+
\ No newline at end of file
diff --git a/tests/modules/programs/git/git-with-maintenance.nix b/tests/modules/programs/git/git-with-maintenance.nix
new file mode 100644
index 000000000..50f42687e
--- /dev/null
+++ b/tests/modules/programs/git/git-with-maintenance.nix
@@ -0,0 +1,26 @@
+{ lib, pkgs, ... }:
+
+lib.mkMerge [
+ {
+ programs.git = {
+ enable = true;
+ maintenance.enable = true;
+ };
+ }
+
+ (lib.mkIf pkgs.stdenv.isDarwin {
+ nmt.script = ''
+ serviceFile=LaunchAgents/org.nix-community.home.git-maintenance-hourly.plist
+ assertFileExists "$serviceFile"
+ assertFileContent "$serviceFile" ${./expected-agent-hourly.plist}
+
+ serviceFile=LaunchAgents/org.nix-community.home.git-maintenance-daily.plist
+ assertFileExists "$serviceFile"
+ assertFileContent "$serviceFile" ${./expected-agent-daily.plist}
+
+ serviceFile=LaunchAgents/org.nix-community.home.git-maintenance-weekly.plist
+ assertFileExists "$serviceFile"
+ assertFileContent "$serviceFile" ${./expected-agent-weekly.plist}
+ '';
+ })
+]