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

services.borgmatic: add initial support for darwin

This commit is contained in:
Damien Cassou 2025-05-15 07:48:19 +02:00 committed by Austin Horstman
parent 34d44d7f1b
commit c09ccd7d39
6 changed files with 81 additions and 0 deletions

View file

@ -81,6 +81,27 @@ in
};
};
})
(lib.mkIf pkgs.stdenv.isDarwin {
assertions = [
(lib.hm.darwin.assertInterval "services.borgmatic.frequency" serviceConfig.frequency pkgs)
];
launchd.agents.borgmatic = {
enable = true;
config = {
ProgramArguments = [
(lib.getExe programConfig.package)
"--stats"
"--list"
];
ProcessType = "Background";
StartCalendarInterval = lib.hm.darwin.mkCalendarInterval serviceConfig.frequency;
StandardOutPath = "${config.home.homeDirectory}/Library/Logs/borgmatic/launchd-stdout.log";
StandardErrorPath = "${config.home.homeDirectory}/Library/Logs/borgmatic/launchd-stderr.log";
};
};
})
]
);
}

View file

@ -330,6 +330,7 @@ import nmtSrc {
./modules/launchd
./modules/programs/aerospace
./modules/programs/element-desktop/darwin.nix
./modules/services/borgmatic-darwin
./modules/services/emacs-darwin
./modules/services/espanso-darwin
./modules/services/git-sync-darwin

View file

@ -0,0 +1,14 @@
{
services.borgmatic = {
enable = true;
frequency = "weekly";
};
nmt.script = ''
serviceFile=LaunchAgents/org.nix-community.home.borgmatic.plist
assertFileExists "$serviceFile"
assertFileContent "$serviceFile" ${./expected-agent.plist}
'';
}

View file

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

View file

@ -0,0 +1,31 @@
<?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.borgmatic</string>
<key>ProcessType</key>
<string>Background</string>
<key>ProgramArguments</key>
<array>
<string>@borgmatic@/bin/borgmatic</string>
<string>--stats</string>
<string>--list</string>
</array>
<key>StandardErrorPath</key>
<string>/home/hm-user/Library/Logs/borgmatic/launchd-stderr.log</string>
<key>StandardOutPath</key>
<string>/home/hm-user/Library/Logs/borgmatic/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.borgmatic = {
enable = true;
frequency = "00:02:00";
};
test.asserts.assertions.expected = [
"On Darwin services.borgmatic.frequency must be one of: hourly, daily, weekly, monthly, semiannually, annually."
];
}