mirror of
https://github.com/nix-community/home-manager.git
synced 2025-12-15 13:31:07 +01:00
syncthing: add Darwin support
This commit is contained in:
parent
2f8d24b7f5
commit
885a504f80
10 changed files with 85 additions and 27 deletions
|
|
@ -6,6 +6,15 @@ let
|
|||
|
||||
cfg = config.services.syncthing;
|
||||
|
||||
defaultSyncthingArgs = [
|
||||
"${pkgs.syncthing}/bin/syncthing"
|
||||
"-no-browser"
|
||||
"-no-restart"
|
||||
"-logflags=0"
|
||||
];
|
||||
|
||||
syncthingArgs = defaultSyncthingArgs ++ cfg.extraOptions;
|
||||
|
||||
in {
|
||||
meta.maintainers = [ maintainers.rycee ];
|
||||
|
||||
|
|
@ -57,11 +66,6 @@ in {
|
|||
|
||||
config = mkMerge [
|
||||
(mkIf cfg.enable {
|
||||
assertions = [
|
||||
(lib.hm.assertions.assertPlatform "services.syncthing" pkgs
|
||||
lib.platforms.linux)
|
||||
];
|
||||
|
||||
home.packages = [ (getOutput "man" pkgs.syncthing) ];
|
||||
|
||||
systemd.user.services = {
|
||||
|
|
@ -74,10 +78,7 @@ in {
|
|||
};
|
||||
|
||||
Service = {
|
||||
ExecStart =
|
||||
"${pkgs.syncthing}/bin/syncthing -no-browser -no-restart -logflags=0"
|
||||
+ optionalString (cfg.extraOptions != [ ])
|
||||
(" " + escapeShellArgs cfg.extraOptions);
|
||||
ExecStart = escapeShellArgs syncthingArgs;
|
||||
Restart = "on-failure";
|
||||
SuccessExitStatus = [ 3 4 ];
|
||||
RestartForceExitStatus = [ 3 4 ];
|
||||
|
|
@ -95,6 +96,18 @@ in {
|
|||
Install = { WantedBy = [ "default.target" ]; };
|
||||
};
|
||||
};
|
||||
|
||||
launchd.agents.syncthing = {
|
||||
enable = true;
|
||||
config = {
|
||||
ProgramArguments = syncthingArgs;
|
||||
KeepAlive = {
|
||||
Crashed = true;
|
||||
SuccessfulExit = false;
|
||||
};
|
||||
ProcessType = "Background";
|
||||
};
|
||||
};
|
||||
})
|
||||
|
||||
(mkIf (isAttrs cfg.tray && cfg.tray.enable) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue