nixvimConfig/modules/nixOS/services/syncthing/default.nix

61 lines
2 KiB
Nix
Raw Normal View History

2024-05-16 15:09:24 +02:00
{
pkgs,
config,
lib,
inputs,
...
2024-07-03 00:38:20 +02:00
}: let
webGuiPort = [8384];
cfg = config;
secretsFile = "../../../secrets/secrets.json";
secretsSet = builtins.fromJSON (builtins.readFile ./${secretsFile});
devices = builtins.attrNames secretsSet.syncthing.devices;
in {
options.myNixOS.services.syncthing = {
2024-05-16 15:09:24 +02:00
rootDir = lib.mkOption {
type = lib.types.path;
default = "/home/${cfg.myNixOS.sharedSettings.mainUser}/sync";
};
remoteGui = lib.mkEnableOption "Enable port for remote WebGUI";
};
services.syncthing = {
enable = true;
user = cfg.myNixOS.sharedSettings.mainUser;
dataDir = config.rootDir;
configDir = "/home/${cfg.myNixOS.sharedSettings.mainUser}/.config/syncthing";
overrideDevices = true;
overrideFolders = true;
settings = {
devices = {
2024-07-03 00:38:20 +02:00
"saintAlphonso" = {id = "LHASNUO-CXALARH-XI3TU4U-OCULV72-HS3HQ35-P4FECIT-UZ5VMSZ-PMCEPQH";};
"littleUmbrella" = {id = "BH3OHYP-TGGOSZO-EM6MXRY-YHSBOUO-CQHE7DL-N2LOUFY-TF3LEJ7-FHTGTQI";};
"pixelRoot" = {id = "PO7U5SE-DYKTOM2-TFDS3BM-A25VK7V-MQ3VPFM-EFX3J4D-B3UDCX4-3XQAIAC";};
"pixelDefault" = {id = "HC3CKC7-OUZBLU3-JIKTRYG-DPJE6EC-7POCWNS-6VNOPDU-L7OWYWO-PL332AY";};
"pixelGooglor" = {id = "OWDM4I2-O6STMIS-H3EXF65-FSM26K3-5FLQXRN-VOK7JGC-T6H76IR-QAVO3QK";};
"remus" = {id = "XATHQZF-XO27XG2-65BT5EO-PZQWGMG-BDOYXID-AI5YPDU-ZACUPB4-UTXLPA3";};
2024-05-16 15:09:24 +02:00
};
folders = {
"/home/${cfg.myNixOS.sharedSettings.mainUser}/KeepassXC" = {
label = "KeepassXC";
id = "xd4de-mjfcq";
devices = ["littleUmbrella" "pixelRoot" "pixelDefault" "pixelGooglor" "saintAlphonso"];
2024-07-03 00:38:20 +02:00
versioning = {
type = "simple";
params.keep = "5";
};
2024-05-16 15:09:24 +02:00
};
};
};
};
# Syncthing ports: 8384 for remote access to GUI
# 22000 TCP and/or UDP for sync traffic
# 21027/UDP for discovery
# source: https://docs.syncthing.net/users/firewall.html
2024-07-03 00:38:20 +02:00
networking.firewall.allowedTCPPorts = [8384 22000];
networking.firewall.allowedUDPPorts = [22000 21027];
2024-05-16 15:09:24 +02:00
}