summaryrefslogtreecommitdiff
path: root/nixos/modules/homelab/cloud/syncthing.nix
blob: 7a1d3de9dcd3e16f96e37b78a5091c7e79a33f07 (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
{config, pkgs, lib, ...}: let
  cfg = config.homelab.cloud.syncthing;
in {
  options.homelab.cloud.syncthing = {
    enable = lib.mkEnableOption "syncthing";
    user = lib.mkOption {
      type = lib.types.str;
      description = "The username of syncthing's user";
    };
  };
  config = lib.mkIf cfg.enable {
    services.syncthing = {
      enable = true;
      user = cfg.user;
      dataDir = "/home/${cfg.user}/Sync";
      configDir = "/home/${cfg.user}/.config/syncthing";
      overrideDevices = true;
      overrideFolders = true;
      settings = {
        devices = {
          "thinkpad-laptop" = { 
  	        id = "3Q4DMGC-SMMRYXG-UNQMGLK-74ST7NF-KVBAFXB-6D2LM2D-UEHBLVW-J2C2CAB"; 
  	      };
          "nzxt-desktop" = {
            id = "2TPKPXD-LO7OL7V-GP5HOUM-2P5SUEQ-XST4UYJ-S2Z56PP-IM66IIT-GLUNLAX";
          };
          "iphone-mobile" = {
            id = "OOOREXG-WLZUDL4-FPK44E5-CDAVS7Z-GK2LMW6-E643GPK-3FIQVFW-FIU5XQG";
          };
          "samsung-tablet" = {
            id = "ZKL25GJ-TKM2E6Y-VQSBAW5-TVG7RWM-RRAUEVA-ZOJZNCM-F3ARZUU-TPK7CA6";
          };
        };
        folders = {
          "Main" = {
            path = "/home/${cfg.user}/Sync";
  	        devices = [ "thinkpad-laptop" "nzxt-desktop" "iphone-mobile" "samsung-tablet" ];
  	      };
        };
      };
    };
    environment.systemPackages = [ pkgs.syncthing ];
    # Use this command to get id: syncthing cli show system | from json | get myID
  };
}