Syncthing: Difference between revisions

From NixOS Wiki
imported>Klaymore
m Typo fix
imported>Klaymore
Added syntax highlighting
Line 1: Line 1:
Syncthing is available as a standalone package:
Syncthing is available as a standalone package: <code>nix-env -iA nixos.syncthing</code>


<nowiki>nix-env -iA nixos.syncthing</nowiki>


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


<nowiki>
<syntaxHighlight lang="nix">
services = {
services = {
     syncthing = {
     syncthing = {
Line 14: Line 13:
     };
     };
};
};
</nowiki>
</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 follow the official Getting Started guide: https://docs.syncthing.net/intro/getting-started.html
Line 25: Line 24:
(Note: Before NixOS 21.11, declarative configuration was done in the <code>services.syncthing.declarative</code> option, such as <code>services.syncthing.declarative.folders = {};</code>)
(Note: Before NixOS 21.11, declarative configuration was done in the <code>services.syncthing.declarative</code> option, such as <code>services.syncthing.declarative.folders = {};</code>)


<nowiki>
<syntaxHighlight lang="nix">
services = {
services = {
   syncthing = {
   syncthing = {
Line 48: Line 47:
   };
   };
};
};
</nowiki>
</syntaxHighlight>





Revision as of 04:59, 13 February 2022

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";    # Default folder for new synced folders
        configDir = "/home/myusername/Documents/.config/syncthing";   # Folder for Syncthing's settings and keys
    };
};

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.devices and services.syncthing.folders options:

(Note: Before NixOS 21.11, declarative configuration was done in the services.syncthing.declarative option, such as services.syncthing.declarative.folders = {};)

services = {
  syncthing = {
    enable = true;
    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