2025-10-09 23:49:09 -05:00
|
|
|
{ flake, config, ... }:
|
2025-10-01 19:51:55 -05:00
|
|
|
let
|
|
|
|
|
inherit (flake.config.machines.devices)
|
|
|
|
|
synology
|
|
|
|
|
phone
|
2025-10-09 23:49:09 -05:00
|
|
|
mars
|
|
|
|
|
ceres
|
2025-10-01 19:51:55 -05:00
|
|
|
;
|
2025-10-10 02:03:44 -05:00
|
|
|
inherit (flake.config.services)
|
|
|
|
|
instances
|
2025-10-01 19:51:55 -05:00
|
|
|
;
|
2025-10-10 16:02:03 -05:00
|
|
|
service = instances.syncthing;
|
|
|
|
|
|
2025-10-09 23:49:09 -05:00
|
|
|
hostname = config.networking.hostName;
|
2025-10-10 02:03:44 -05:00
|
|
|
localhost = instances.web.localhost.address1;
|
|
|
|
|
postgres = instances.postgresql;
|
|
|
|
|
forgejo = instances.forgejo;
|
|
|
|
|
backupPath = "${service.paths.path1}";
|
2025-10-09 23:49:09 -05:00
|
|
|
|
|
|
|
|
syncDevices = {
|
|
|
|
|
synologySync = {
|
|
|
|
|
${synology.name} = {
|
|
|
|
|
autoAcceptFolders = true;
|
|
|
|
|
name = synology.name;
|
|
|
|
|
addresses = [
|
|
|
|
|
"tcp://${synology.ip.address0}:${toString service.ports.port2}"
|
|
|
|
|
];
|
|
|
|
|
id = synology.sync.address0;
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
phoneSync = {
|
|
|
|
|
${phone.name} = {
|
|
|
|
|
autoAcceptFolders = true;
|
|
|
|
|
name = phone.name;
|
|
|
|
|
addresses = [
|
|
|
|
|
"tcp://${phone.ip.address0}:${toString service.ports.port2}"
|
|
|
|
|
];
|
|
|
|
|
id = phone.sync.address0;
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
};
|
2025-10-01 19:51:55 -05:00
|
|
|
in
|
|
|
|
|
{
|
|
|
|
|
services = {
|
|
|
|
|
syncthing = {
|
|
|
|
|
enable = true;
|
|
|
|
|
overrideDevices = false;
|
|
|
|
|
overrideFolders = false;
|
|
|
|
|
openDefaultPorts = true;
|
|
|
|
|
systemService = true;
|
|
|
|
|
guiAddress = "${localhost}:${toString service.ports.port0}";
|
|
|
|
|
settings = {
|
2025-10-09 23:49:09 -05:00
|
|
|
devices =
|
|
|
|
|
if hostname == mars.name then
|
2025-10-09 23:50:51 -05:00
|
|
|
syncDevices.phoneSync // syncDevices.synologySync
|
2025-10-09 23:49:09 -05:00
|
|
|
else if hostname == ceres.name then
|
2025-10-09 23:50:51 -05:00
|
|
|
syncDevices.synologySync
|
2025-10-09 23:49:09 -05:00
|
|
|
else
|
|
|
|
|
{ };
|
2025-10-01 19:51:55 -05:00
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
2025-10-10 02:03:44 -05:00
|
|
|
systemd.tmpfiles.rules = [
|
|
|
|
|
# Main syncthing directory
|
|
|
|
|
"d ${service.paths.path0} 0755 ${service.name} ${service.name} -"
|
|
|
|
|
|
|
|
|
|
# Backup directories
|
|
|
|
|
"d ${backupPath} 0755 ${service.name} ${service.name} -"
|
|
|
|
|
"d ${backupPath}/${postgres.name} 0755 ${postgres.name} ${service.name} -"
|
|
|
|
|
"d ${backupPath}/${forgejo.name} 0750 ${forgejo.name} ${service.name} -"
|
|
|
|
|
];
|
|
|
|
|
|
2025-10-01 19:51:55 -05:00
|
|
|
networking = {
|
|
|
|
|
firewall = {
|
|
|
|
|
allowedTCPPorts = [
|
|
|
|
|
service.ports.port0
|
|
|
|
|
service.ports.port1
|
|
|
|
|
service.ports.port2
|
|
|
|
|
];
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
}
|