summaryrefslogtreecommitdiff
path: root/sys/syncthing/default.nix
blob: b87e683d9cc71652277fe5f73b8dcbaa7a0e9a4a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
{ config, lib, ... }:
with lib; let
  cfg = config.local.syncthing;
in
{
  options.local.syncthing = {
    enable = mkEnableOption "syncthing server";
    openFirewall = mkEnableOption "syncthing firewall rules";
  };

  config = mkMerge [
    ({
      networking.firewall = {
        allowedTCPPorts = optional cfg.openFirewall 22000;
        allowedUDPPorts = optional cfg.openFirewall 22000;
      };
    })
    (mkIf cfg.enable {
      local.syncthing.openFirewall = true;

      services.syncthing = {
        enable = true;

        systemService = true;
        overrideFolders = false;
        overrideDevices = false;
        openDefaultPorts = true;

        guiAddress = "127.0.0.1:8384";

        settings.options.urAccepted = -1;

        relay = {
          enable = true;

          pools = [ ];
          providedBy = "${config.networking.hostName}.${config.networking.domain}";
        };
      };
    })
  ];
}