summary refs log tree commit diff
path: root/modules/syncthing.nix
blob: d301f5a5d8b043814a1d3ff55736ea2975971973 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
pre { line-height: 125%; }
td.linenos .normal { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }
span.linenos { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }
td.linenos .special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
span.linenos.special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
.highlight .hll { background-color: #0000ff }
.highlight .c { color: #0F0 } /* Comment */
.highlight .err { color: #DDD } /* Error */
.highlight .esc { color: #DDD } /* Escape */
.highlight .g { color: #DDD } /* Generic */
.highlight .k { color: #F00 } /* Keyword */
.highlight .l { color: #DDD } /* Literal */
.highlight .n { color: #DDD } /* Name */
.highlight .o { color: #DDD } /* Operator */
.highlight .x { color: #DDD } /* Other */
.highlight .p { color: #DDD } /* Punctuation */
.highlight .ch { color: #0F0 } /* Comment.Hashbang */
.highlight .cm { color: #0F0 } /* Comment.Multiline */
.highlight .cp { color: #E5E5E5 } /* Comment.Preproc */
.highlight .cpf { color: #0F0 } /* Comment.PreprocFile */
.highlight .c1 { color: #0F0 } /* Comment.Single */
.highlight .cs { color: #0F0 } /* Comment.Special */
.highlight .gd { color: #DDD } /* Generic.Deleted */
.highlight .ge { color: #DDD } /* Generic.Emph */
.highlight .ges { color: #DDD } /* Generic.EmphStrong */
.highlight .gr { color: #DDD } /* Generic.Error */
.highlight .gh { color: #DDD } /* Generic.Heading */
.highlight .gi { color: #DDD } /* Generic.Inserted */
.highlight .go { color: #DDD } /* Generic.Ou
{
  lib,
  me,
  config,
  ...
}:

let
  inherit (config.users.users) mel;

  defaultSyncthingPort = "8384";
in
{
  foundation.tailnetServices = [ "syncthing" ];

  # server-side
  services.syncthing = {
    enable = true;
    # do not open any firewall ports,
    # we only want access through the tailnet
    openDefaultPorts = false;
    guiAddress = "${me.tailscale.ip}:${defaultSyncthingPort}";

    user = "mel";
    dataDir = "${mel.home}/sync";
    configDir = "${mel.home}/.config/syncthing";

    # only take declarative configuration below
    overrideDevices = true;
    overrideFolders = true;
    settings = {
      devices = {
        bismuth.id = "MXC4UQG-PRZESJ3-AQYGWNG-EMCI44Q-UC7YFNP-6ZDF3SA-NLZCVUH-FQAK6QK";
        graphite.id = "THWA2HN-BZ4URXS-P5PKAJY-YEBYQSH-2MUDKXC-CL3YQ2A-VHFUPCE-ROHQNQ7";
      };

      # TODO: these are duplciated from the client configuration.
      # maybe we should semi-merge the two??
      folders =
        let
          clientFolders = [
            "desktop"
            "documents"
            "pictures"
            "music"
            "videos"
            "thoughts"
            "code"
            "scripts"
            "projects"
          ];

          commonFolder = name: {
            path = "~/sync/${name}";
            devices = [ "bismuth" "graphite" ];
            versioning = {
              type = "staggered";
              params = {
                cleanInterval = toString (60 * 60);
                maxAge = toString (14 * 24 * 60 * 60);
              };
            };
          };
        in
        lib.genAttrs clientFolders commonFolder;

      # no telemetry
      options.urAccepted = -1;
    };
  };
}