Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

syncthing: expand declarative config to Darwin #6104

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

pitkling
Copy link
Contributor

Description

This PRs extends the recently merged PR #5616, which expanded the Synching config to allow declarative settings under Linux, such that it also works under Darwin.

To simplify the review process, I left split the PR into several commits for now:

  • The first five commits perform some minor refactoring tasks of the module code such that parts of it can be reused in the Darwin specific changes.
  • Commit six implements the actual Darwin specific changes. It does the following:
    • 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 syncthing: expand declarative config #5616.
    • Adds an syncthing-initlaunchd agent (analogously to the systemd service synching-init from the above mentioned PR syncthing: expand declarative config #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.
  • The last commit just fixes the formatting according to HM's format tool.

There might be better ways to coordinate the two launchd agents I'm not aware of. But I have had this running flawlessly for over two months now (on four Darwin and two Linux machines sharing various folders).

Fixes #4049 for Darwin systems.

Checklist

  • Change is backwards compatible.

  • Code formatted with ./format.

  • Code tested through nix-shell --pure tests -A run.all or nix develop --ignore-environment .#all using Flakes.

  • Test cases updated/added. See example.

  • Commit messages are formatted (see commit 6; I'll squash the other commits into it after the review process)

Maintainer CC

@karaolidis (pinging as author of the original (linux-specific) PR #5616)
@rycee (maintainer)

This makes it possible to reuse the script in launchd setup.
Allows us to reuse the function in different scripts.
Make launchd.agents an explicit attribute set, since we're going to add another agent.
This extends the recently merged PR nix-community#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 nix-community#5616.
* Adds an `syncthing-init`launchd agent (analogously to the systemd service `synching-init` from the above mentioned PR nix-community#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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add declarative config options for Syncthing
2 participants