lifetracker/modules/apps/syncthing/default.nix
2025-02-02 19:06:55 -08:00

77 lines
2.1 KiB
Nix

{
lib,
config,
pkgs,
username,
...
}:
let
cfg = config.syncthing;
in
{
options = {
syncthing = {
enable = lib.mkEnableOption "Enable syncthing in NixOS and home-manager";
};
};
config = lib.mkIf cfg.enable {
services.syncthing = {
enable = true;
key = "${config.sops.secrets."syncthing/${config.networking.hostName}_key".path }";
cert = "${config.sops.secrets."syncthing/${config.networking.hostName}_cert".path}";
user = "${username}";
group = "users";
dataDir = "/home/${username}";
configDir = "/home/${username}/.config/syncthing";
overrideDevices = true; # overrides any devices added or deleted through the WebUI
overrideFolders = true; # overrides any folders added or deleted through the WebUI
settings = {
urAccepted = -1;
gui = {
user = username;
password = config.sops.secrets.password_insecure;
};
devices = {
"luna" = {
id = "TM4RJVL-W2CJ32S-ZF3VN2K-DYOUT5Z-DJPAK4R-DMB4B7X-L35KLEP-NAM7QQJ";
};
"thalia" = {
id = "XECYWXP-KSBKPKA-MLW3ITR-2GDF75P-PEX3GBR-MP5XHJS-BGJEAGZ-ZNBD7QJ";
};
"synology" = {
id = "GZEXPNR-3VXONBW-64I4C27-YMMGYH7-GL65LXT-AL7OJEQ-PHRGQST-ZY5APQK";
};
};
folders = {
"Notes" = {
id = "erz9x-lv3ww";
label = "Notes";
path = "~/Notes";
devices = [
"luna"
"thalia"
"synology"
]; # Which devices to share the folder with
};
"Sync" = {
id = "ye1o9-0c6bd";
label = "Sync";
path = "~/Sync";
devices = [
"luna"
"thalia"
"synology"
];
};
};
};
};
networking.firewall.allowedTCPPorts = [ 22000 ];
networking.firewall.allowedUDPPorts = [
22000
21027
];
systemd.services.syncthing.environment.STNODEFAULTFOLDER = "true";
};
}