diff --git a/modules/services/syncthing.nix b/modules/services/syncthing.nix index a924caaf..1de24029 100644 --- a/modules/services/syncthing.nix +++ b/modules/services/syncthing.nix @@ -825,40 +825,33 @@ in }; }; - 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 = [ - "${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; - }; - ProcessType = "Background"; - }; - }; - - syncthing-init = { - enable = cleanedConfig != { }; - config = { - ProgramArguments = [ "${updateConfig}" ]; - WatchPaths = [ - "${config.home.homeDirectory}/Library/Application Support/Syncthing/${watch_file}" - ]; + launchd.agents = { + syncthing = { + enable = true; + config = { + ProgramArguments = [ + "${pkgs.writers.writeBash "syncthing-wrapper" '' + ${copyKeys} # simulate systemd's `syncthing-init.Service.ExecStartPre` + exec ${lib.escapeShellArgs syncthingArgs} + ''}" + ]; + KeepAlive = { + Crashed = true; + SuccessfulExit = false; }; + ProcessType = "Background"; }; }; + + syncthing-init = { + enable = cleanedConfig != { }; + config = { + ProgramArguments = [ "${updateConfig}" ]; + ProcessType = "Background"; + RunAtLoad = true; + }; + }; + }; }) (lib.mkIf cfg.tray.enable {