I’m trying to set up Syncthing, but I can’t find any reference to how I can accept incoming shares. I can accept them in the WebUI, but I’d rather want to do this declaratively, cause that’s the new thang;)
Well, if you know the IDs of the folders and the machines you want to share with, you can add them to your config before you get the invite. But then you would send out the invite instead of waiting for it.
There is no “auto accept from machine xyz” when you want to do things purely declarative, as this would have to update your config and trigger a rebuild + activation.
It does, and you could get a JSON description of the incoming request which (probably) contains enough info to then generate the corresponding nix.
Another idea would be a more general conversion tool… Parse the syncthing config.xml and emit the corresponding nix data (that would then regenerate to ~the same config).
Also, from the OP, note that this attribute … doesn’t exist; all that stuff just goes directly under services.syncthing…
Not sure I understand. I already have defined a share on one system and I want to put that share in the config of another system, so that I don’t have to do anything interactive;)
the …folders.<name>.devices list is the list of other servers to share with. You need to set that to [ "serverA" ] on serverB, and vice-versa (in the simplest case, there might of course be additional devices participating in the share).
All of this is regular syncthing configuration, expressed in nix and wrapping the rest api to set config on startup.
In the GUI, when you “accept an incoming share” what you’re doing is adding a new share, with some of the values pre-filled from the incoming discovery data. If it’s an existing share, you just add the additional device to it. That’s all.
What matters across the network is the share id and the set of devices it’s shared with. You can create shares locally with the same id on multiple hosts, connect them together, and the folders will sync. If there were existing contents, they’ll get merged (or generate conflicts if the same filenames are in use). In current versions of syncthing, the GUI generates a random folder id by default, so this doesn’t happen unless you edit it to a user-chosen matching value.
The declarative version is the same, you choose all the values and syncthing runs with those settings: all the folders you declare are “accepted” already and will sync with any matching shares on the devices listed.