{ config, lib, ... }: let cfg = config.custom.services.syncthing; in { options.custom.services.syncthing.enable = lib.mkOption { type = lib.types.bool; default = false; }; config = lib.mkIf cfg.enable { boot.kernel.sysctl."fs.inotify.max_user_watches" = 204800; services.syncthing = { enable = true; user = "vili"; dataDir = config.users.users.${config.services.syncthing.user}.home; settings = { defaults.ignores = [ "/Projects/Programming" ]; options = { urAccepted = -1; localAnnounceEnabled = false; globalAnnounceEnabled = false; natEnabled = false; relaysEnabled = false; }; devices = lib.mkMerge [ { "syncthing" = { id = "J6GNM4Z-2TWASPT-3P3EW4V-KZEQYFF-TXL22QX-4YTZ3WO-WLM7GQ7-NUP66A4"; addresses = [ "tcp://syncthing.vsinerva.fi:22000" ]; }; } (lib.mkIf (config.networking.hostName == "syncthing") { "helium" = { id = "2MRUBSY-NHXYMAW-SY22RHP-CNNMHKR-DPDKMM4-2XV5F6M-6KSNLQI-DD4EOAM"; addresses = [ "tcp://helium.vsinerva.fi:22000" ]; }; }) ]; folders = let default = { devices = lib.mkMerge [ [ "syncthing" ] (lib.mkIf (config.networking.hostName == "syncthing") [ "helium" ]) ]; versioning = { type = "trashcan"; params.cleanoutDays = "30"; }; fsWatcherDelayS = 1; }; in { "~/Documents" = default; "~/Music" = default; "~/Pictures" = default; "~/Projects" = default; "~/School" = default; "~/Videos" = default; "~/Zotero" = default; }; }; #TCP/UDP 22000 for transfers and UDP 21027 for discovery openDefaultPorts = true; }; }; }