Files
nix/modules/system/syncthing/default.nix
2025-11-01 21:06:11 -05:00

75 lines
2.0 KiB
Nix

{
pkgs,
config,
lib,
...
}: let
service = "syncthing";
cfg = config.system.${service};
sec = config.sops.secrets;
in {
options.system.${service} = {
enable = lib.mkEnableOption "enables syncthing";
host = lib.mkOption {
type = lib.types.nullOr lib.types.str;
default = config.networking.hostName;
};
};
config = lib.mkIf cfg.enable {
services.syncthing = {
enable = true;
user = "blake";
group = "blake";
guiAddress = "0.0.0.0:2222";
openDefaultPorts = true;
dataDir = "/home/blake/.config/syncthing";
#extraFlags = ["--no-default-folder"];
overrideFolders = false;
overrideDevices = false;
key = sec."${service}/${cfg.host}/key".path;
cert = sec."${service}/${cfg.host}/cert".path;
settings = {
devices = {
"snowbelle" = {id = "6WQ6ATA-5AT4RUM-NW67PAL-N62CPNV-ALRFG3P-5BDRO22-HWFC2Q4-5S5BDA5";};
"lugia" = {id = "BKKSFPH-YEOVVAB-DTT7KK3-UDKAEJ2-PC6ECG7-Y76ZIVP-JRYMMXS-RTZYVQ3";};
"zygarde" = {id = "UYLTF52-VVKUR7F-JN33HQZ-RFNWGL3-JER52LA-GZD2LPJ-QIFEE7K-MNMZRQ5";};
"yveltal" = {id = "ZVSQ4WJ-7OICYOZ-3ECES4X-KH37IPB-TKHKUJG-BSEGXVM-AHYY5C3-VKG44AX";};
"CEN-IT-07" = {id = "DPYKA4Z-3PX7JB2-FBEOXXX-SC7TLT2-QC5P2IR-SXOPJGX-QO3DMII-5B7UCA4";};
};
folders = {
"holocron" = {
path = "/home/blake/holocron";
devices = ["lugia" "zygarde" "CEN-IT-07"];
id = "5voxg-c3he2";
versioning = {
type = "staggered";
fsPath = "/home/blake/holocron/.stversions";
params = {
cleanInterval = "3600";
maxAge = "0";
};
};
};
};
options = {
urAccepted = -1;
};
};
};
sops.secrets = {
"${service}/${cfg.host}/key" = {
owner = "blake";
group = "blake";
};
"${service}/${cfg.host}/cert" = {
owner = "blake";
group = "blake";
};
};
};
}