mirror of
https://github.com/nix-community/home-manager
synced 2025-01-07 09:39:49 +01:00
syncthing: expand declarative config to Darwin
This extends the recently merged PR #5616, which expanded the Synching config to allow declarative settings under Linux, such that it also works under Darwin. Changes: * Update the module's `syncthing` launchd agent to copy the synching key/certificate before starting syncthing, analogously to the systemd service from the above mentioned PR #5616. * Adds an `syncthing-init`launchd agent (analogously to the systemd service `synching-init` from the above mentioned PR #5616) that updates the configuration files. Since this must be run after the syncthing service started, we use a `WatchPath` to coordinate both launchd agents.
This commit is contained in:
parent
a2289723f9
commit
e091fe38a9
1 changed files with 19 additions and 3 deletions
|
@ -202,7 +202,6 @@ in {
|
|||
services.syncthing = {
|
||||
enable = mkEnableOption ''
|
||||
Syncthing, a self-hosted open-source alternative to Dropbox and Bittorrent Sync.
|
||||
Further declarative configuration options only supported on Linux devices.
|
||||
'';
|
||||
|
||||
cert = mkOption {
|
||||
|
@ -686,11 +685,20 @@ in {
|
|||
};
|
||||
};
|
||||
|
||||
launchd.agents = {
|
||||
launchd.agents = let
|
||||
# agent `syncthing` uses `${syncthing_dir}/${watch_file}` to notify agent `syncthing-init`
|
||||
watch_file = ".launchd_update_config";
|
||||
in {
|
||||
syncthing = {
|
||||
enable = true;
|
||||
config = {
|
||||
ProgramArguments = syncthingArgs;
|
||||
ProgramArguments = [ "${
|
||||
pkgs.writers.writeBash "syncthing-wrapper" ''
|
||||
${copyKeys} # simulate systemd's `syncthing-init.Service.ExecStartPre`
|
||||
touch "${syncthing_dir}/${watch_file}" # notify syncthing-init agent
|
||||
exec ${lib.escapeShellArgs syncthingArgs}
|
||||
''
|
||||
}" ];
|
||||
KeepAlive = {
|
||||
Crashed = true;
|
||||
SuccessfulExit = false;
|
||||
|
@ -698,6 +706,14 @@ in {
|
|||
ProcessType = "Background";
|
||||
};
|
||||
};
|
||||
|
||||
syncthing-init = {
|
||||
enable = true;
|
||||
config = {
|
||||
ProgramArguments = [ "${updateConfig}" ];
|
||||
WatchPaths = [ "${config.home.homeDirectory}/Library/Application Support/Syncthing/${watch_file}" ];
|
||||
};
|
||||
};
|
||||
};
|
||||
})
|
||||
|
||||
|
|
Loading…
Reference in a new issue