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
|
|
|
;
|
|
|
|
|
inherit (flake.config.services.instances)
|
|
|
|
|
syncthing
|
|
|
|
|
web
|
|
|
|
|
;
|
2025-10-09 23:49:09 -05:00
|
|
|
hostname = config.networking.hostName;
|
|
|
|
|
localhost = web.localhost.address1;
|
2025-10-01 19:51:55 -05:00
|
|
|
service = syncthing;
|
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
|
|
|
|
|
builtins.attrValues {
|
|
|
|
|
inherit (syncDevices)
|
|
|
|
|
phoneSync
|
|
|
|
|
synologySync
|
|
|
|
|
;
|
|
|
|
|
}
|
|
|
|
|
else if hostname == ceres.name then
|
|
|
|
|
builtins.attrValues {
|
|
|
|
|
inherit (syncDevices)
|
|
|
|
|
synologySync
|
|
|
|
|
;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{ };
|
2025-10-01 19:51:55 -05:00
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
networking = {
|
|
|
|
|
firewall = {
|
|
|
|
|
allowedTCPPorts = [
|
|
|
|
|
service.ports.port0
|
|
|
|
|
service.ports.port1
|
|
|
|
|
service.ports.port2
|
|
|
|
|
];
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
}
|