Syncthing: Difference between revisions

From NixOS Wiki
imported>Thu
Add link to the Getting Started guide.
imported>Klaymore
Added section for declarative folder configuration
Line 17: Line 17:
</nowiki>
</nowiki>


You can confirm Syncthing runs by visiting http://127.0.0.1:8384/ and follow the offical 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 follow the official Getting Started guide: https://docs.syncthing.net/intro/getting-started.html
 
 
== Declarative Configuration ==
 
You can declaratively set your Syncthing folders by using the <code>services.syncthing.declarative</code> options:
 
<nowiki>
services = {
  syncthing = {
    enable = true;
    declarative = {
      overrideDevices = true;    # overrides any devices added or deleted through the WebUI
      overrideFolders = true;    # overrides any folders added or deleted through the WebUI
      devices = {
        "device1" = { id = "DEVICE-ID-GOES-HERE"; };
        "device2" = { id = "DEVICE-ID-GOES-HERE"; };
      };
      folders = {
        "Documents" = {        # Name of folder in Syncthing, also the folder ID
          path = "/home/myusername/Documents";    # Which folder to add to Syncthing
          devices = [ "device1" "device2" ];      # Which devices to share the folder with
        };
        "Example" = {
          path = "/home/myusername/Example";
          devices = [ "device1" ];
          ignorePerms = false;    # By default, Syncthing doesn't sync file permissions. This line enables it for this folder.
        };
      };
    };
  };
};
</nowiki>
 


== 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

Revision as of 01:22, 24 November 2021

Syncthing is available as a standalone package:

nix-env -iA nixos.syncthing

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:

services = {
    syncthing = {
        enable = true;
        user = "myusername";
        dataDir = "/home/myusername/Documents";
        configDir = "/home/myusername/Documents/.config/syncthing";
    };
};

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


Declarative Configuration

You can declaratively set your Syncthing folders by using the services.syncthing.declarative options:

services = {
  syncthing = {
    enable = true;
    declarative = {
      overrideDevices = true;     # overrides any devices added or deleted through the WebUI
      overrideFolders = true;     # overrides any folders added or deleted through the WebUI
      devices = {
        "device1" = { id = "DEVICE-ID-GOES-HERE"; };
        "device2" = { id = "DEVICE-ID-GOES-HERE"; };
      };
      folders = {
        "Documents" = {        # Name of folder in Syncthing, also the folder ID
          path = "/home/myusername/Documents";    # Which folder to add to Syncthing
          devices = [ "device1" "device2" ];      # Which devices to share the folder with
        };
        "Example" = {
          path = "/home/myusername/Example";
          devices = [ "device1" ];
          ignorePerms = false;     # By default, Syncthing doesn't sync file permissions. This line enables it for this folder.
        };
      };
    };
  };
};


home-manager service

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