Syncthing: Difference between revisions

imported>Brentscott
m added the user parameter to the declarative example
imported>Skylark
Syncthing moved away from /var/lib/syncthing a long time ago; add detail to firewall ports
Line 1: Line 1:
Syncthing is available as a standalone package: <code>nix-env -iA nixos.syncthing</code>
Syncthing is available as a standalone package: <code>nix-env -iA nixos.syncthing</code>


 
It can also be enabled as a service. Example:
It can also be enabled as a service. You'll typically want to configure the user and the path to the configuration directory, as with the default values ("syncthing" for the user, "/var/lib/syncthing" for the dir) you won't be able to access the files:


<syntaxHighlight lang="nix">
<syntaxHighlight lang="nix">
Line 15: Line 14:
</syntaxHighlight>
</syntaxHighlight>


You can confirm Syncthing runs by visiting http://127.0.0.1:8384/ and follow the official Getting Started guide: https://docs.syncthing.net/intro/getting-started.html
You can confirm Syncthing runs by visiting http://127.0.0.1:8384/ and following the official Getting Started guide: https://docs.syncthing.net/intro/getting-started.html


 
== Declarative configuration ==
== Declarative Configuration ==


You can declaratively set your Syncthing folders by using the <code>services.syncthing.devices</code> and  <code>services.syncthing.folders</code> options:
You can declaratively set your Syncthing folders by using the <code>services.syncthing.devices</code> and  <code>services.syncthing.folders</code> options:
Line 53: Line 51:


If running a headless server, you should also change guiAddress to a publicly visible one (or just 0.0.0.0:8384, for example).
If running a headless server, you should also change guiAddress to a publicly visible one (or just 0.0.0.0:8384, for example).
You will also probaly have to open a few ports in the firewall:
 
You will also probably have to open a few ports in the firewall:
<syntaxHighlight lang="nix">
<syntaxHighlight lang="nix">
   # Syncthing ports
   # Syncthing ports: 8384 for remote access to GUI
  # 22000 TCP and/or UDP for sync traffic
  # 21027/UDP for discovery
  # source: https://docs.syncthing.net/users/firewall.html
   networking.firewall.allowedTCPPorts = [ 8384 22000 ];
   networking.firewall.allowedTCPPorts = [ 8384 22000 ];
   networking.firewall.allowedUDPPorts = [ 22000 21027 ];
   networking.firewall.allowedUDPPorts = [ 22000 21027 ];
Line 68: Line 70:
</syntaxHighlight>
</syntaxHighlight>


== home-manager service ==
== Home-manager service ==


https://github.com/nix-community/home-manager/blob/master/modules/services/syncthing.nix
https://github.com/nix-community/home-manager/blob/master/modules/services/syncthing.nix