summaryrefslogtreecommitdiff
path: root/hostnix/weebnix/syncthing.nix
blob: a0a09be913b3865be35b1c41e67276ee66cf5b2e (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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
{ ... }:

let
  staggeredVersioning = {
    type = "staggered";
    params = {
      cleanInterval = "3600";
      maxAge = "31536000";
    };
  };
in
{
  systemd.tmpfiles.rules = [
    "d /var/lib/syncthing 0775 syncthing syncthing"
  ];

  systemd.services.syncthing = {
    serviceConfig.UMask = "0002";
  };

  services.syncthing = {
    enable = true;
    openDefaultPorts = true;
    # Syncthing supports named sockets but the NixOS module assumes network.
    guiAddress = "[::1]:8384";
    settings = {
      devices = {
        "Asus Nexus 7" = {
          id = "BVZARYC-2D56A6I-V6L2VQF-MU7IVCT-ITJTCGQ-IGMZG2W-RZRCTOT-K4GDHAY";
        };
        "DESKTOP-SFVBFBU" = {
          id = "FQEK2MG-2AVMHEM-H6KASQ3-RTA3Z3F-A4R4MUY-YELZVRQ-6QUDSHA-DZZN7AJ";
          autoAcceptFolders = true;
        };
        "Joes-iPhone-6" = {
          id = "F5APH5K-XXO454B-6YU4BTT-YPHF4KT-OD7YF5Y-JTWJRSU-UNJ2KZK-IVJZNQT";
          autoAcceptFolders = true;
        };
        "iPad" = {
          id = "U7D7667-RFEFHXX-TUJGGII-CE62S6P-YC6MWNV-4LBJ4YJ-5ZUZVPT-GBC5PQH";
          autoAcceptFolders = true;
        };
        "maxsettings-C6554E6AF22F" = {
          id = "HO3QQZO-RDWYDB6-U74ZQRC-FP7YPB2-IPB2EBC-KIQ5JII-FD4KBXR-J3GCOQ5";
          autoAcceptFolders = true;
        };
        "penguin" = {
          id = "5BEB6SZ-YAPV3CC-54RZF3V-HQXXP3Y-TTVDWDU-SHHNVCH-IXKZ3O2-6RXG6QL";
          autoAcceptFolders = true;
        };
        "sparky" = {
          id = "FE43LDI-33WS467-LIGFWCC-5PPSKN6-GYODEWJ-KLQZLN7-H3GYGLG-IJ2JGQW";
          autoAcceptFolders = true;
        };
        "steamdeck" = {
          id = "SCUAABL-XU6AS5H-IZZE4PN-LY5J4LH-OYZMXTU-2UMTVUL-I7B7QKE-ZBPSAQ5";
          autoAcceptFolders = true;
        };
        "weeber.mou.fo" = {
          id = "PRE6XCX-7JDMJGJ-6TPMHOS-TP2AT3S-T6CAR3Z-URL5EEU-HVXUDJ4-C5UJ2AV";
          autoAcceptFolders = true;
        };
      };
      folders = {
        "Documents" = {
          id = "bhemx-9nh3v";
          path = "~/Documents";
          versioning = staggeredVersioning;
          devices = [ "sparky" "weeber.mou.fo" ];
        };
        "Downloads" = {
          id = "kvq6q-axjhu";
          path = "~/Downloads";
          versioning = staggeredVersioning;
          devices = [ "sparky" "weeber.mou.fo" ];
        };
        "Game/Documents/Bioshock" = {
          id = "7zhqz-x6uvw";
          path = "~/Game/Documents/Bioshock";
          versioning = staggeredVersioning;
          devices = [ "weeber.mou.fo" ];
        };
        "Game/Epic Games/TheTalosPrinciple/UserData" = {
          id = "vek7u-iausx";
          path = "~/Game/Epic Games/TheTalosPrinciple/UserData";
          versioning = staggeredVersioning;
          devices = [ "DESKTOP-SFVBFBU" "maxsettings-C6554E6AF22F" "weeber.mou.fo" ];
        };
        "Game/PCSX2" = {
          id = "chxsg-hpqgm";
          path = "~/Game/PCSX2";
          versioning = staggeredVersioning;
          devices = [ "maxsettings-C6554E6AF22F" "weeber.mou.fo" ];
        };
        "Pictures" = {
          id = "vfjsd-4fczh";
          path = "~/Pictures";
          versioning = staggeredVersioning;
          devices = [ "sparky" "weeber.mou.fo" ];
        };
        "Sync" = {
          id = "7thks-5badk";
          path = "~/Sync";
          versioning = staggeredVersioning;
          devices = [
            "Asus Nexus 7"
            "DESKTOP-SFVBFBU"
            "Joes-iPhone-6"
            "iPad"
            "penguin"
            "sparky"
            "weeber.mou.fo"
          ];
        };
        "iPad" = {
          id = "qtzmu-fqdrs";
          path = "~/iPad";
          versioning = staggeredVersioning;
          devices = [ "iPad" "weeber.mou.fo" ];
        };
      };
    };
  };

  services.nginx.virtualHosts."st.weebnix.mou.fo" = {
    enableACME = true;
    forceSSL = true;
    locations."/" = {
      proxyPass = "http://[::1]:8384";
      # https://docs.syncthing.net/users/faq.html#why-do-i-get-host-check-error-in-the-gui-api
      recommendedProxySettings = false;
    };
  };

  services.oauth2_proxy.nginx.virtualHosts = [ "st.weebnix.mou.fo" ];
}