nix/config/Syncthing.nix

51 lines
1.2 KiB
Nix
Raw Normal View History

2024-12-08 04:04:34 +03:00
{
config,
lib,
2024-12-08 07:17:06 +03:00
pkgs,
2024-12-08 04:04:34 +03:00
...
}: let
cfg = config.module.syncthing;
in {
2024-12-08 07:17:06 +03:00
config = lib.mkIf cfg.enable {
environment.systemPackages = with pkgs; [ syncthing ];
services.syncthing = {
inherit (cfg) enable dataDir user group openDefaultPorts;
systemService = true;
settings = lib.recursiveUpdate cfg.settings {
devices = {
"desktop" = { id = "767Z675-SOCY4FL-JNYEBB6-5E2RG5O-XTZR6OP-BGOBZ7G-XVRLMD6-DQEB2AT"; };
"home" = { id = "L5A5IPE-2FPJPHP-RJRV2PV-BLMLC3F-QPHSCUQ-4U3NM2I-AFPOE2A-HOPQZQF"; };
"phone" = { id = "6RO5JXW-2XO4S3E-VCDAHPD-4ADK6LL-HQGMZHU-GD6DE2O-6KNHWXJ-BCSBGQ7"; };
};
folders = let
everyone = lib.mapAttrsToList (n: v: n) config.services.syncthing.settings.devices;
in {
"save" = {
path = "${cfg.dataDir}/save";
devices = [
"desktop"
"home"
# "work"
];
};
"photo" = {
path = "${cfg.dataDir}/photo";
devices = [
"home"
"phone"
];
};
"tmp" = {
path = "${cfg.dataDir}/tmp";
devices = everyone;
};
"document" = {
path = "${cfg.dataDir}/document";
devices = everyone;
};
};
};
2024-12-08 04:04:34 +03:00
};
};
}