From a6ec7bd0206642537596ffdf11049af8312ca6c6 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Wed, 15 Jan 2020 18:19:34 -0500 Subject: [PATCH] Set up syncthing declaratively --- modules/services/syncthing.nix | 37 ++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/modules/services/syncthing.nix b/modules/services/syncthing.nix index 0986e3c4..766ff0d2 100644 --- a/modules/services/syncthing.nix +++ b/modules/services/syncthing.nix @@ -5,7 +5,40 @@ enable = true; openDefaultPorts = true; user = config.my.username; - configDir = "/home/hlissner/.config/syncthing"; - dataDir = "/home/hlissner/sync"; + configDir = "/home/${config.my.username}/.config/syncthing"; + dataDir = "/home/${config.my.username}/.local/share/syncthing"; + declarative = { + devices = { + kuro.id = "4UJSUBN-V7LCISG-6ZE7SBN-YPXM5FQ-CE7CD2U-W4KZC7O-4HUZZSW-6DXAGQQ"; + shiro.id = "G4DUO25-AMQQIWS-SRZE5TJ-43CCQZJ-5ULEZBS-P2LMZZU-V5JA5CS-6X7RLQK"; + aka.id = "4UJSUBN-V7LCISG-6ZE7SBN-YPXM5FQ-CE7CD2U-W4KZC7O-4HUZZSW-6DXAGQQ"; + ao.id = "PXKRUR4-EVTXROW-NHSEXBZ-H2NTNL7-EWOUDXF-P3AATC7-KATI37N-3YNQAQD"; + # Windows machine; set up the other end yourself! + niji.id = "BOFH5JP-A3MPTJA-EGIZVWV-URHUTSJ-2ZXCAA2-XMZPPSR-GLMOQFL-ZX7DGQP"; + }; + folders = + let ifEnabledDevice = devices: lib.elem config.networking.hostName devices; + in { + archive = rec { + devices = [ "kuro" "ao" "niji" ]; + path = "/home/${config.my.username}/archive"; + watch = false; + rescanInterval = 7200; + enable = ifEnabledDevice devices; + }; + projects = rec { + devices = [ "kuro" "shiro" "ao" "niji" ]; + path = "/home/${config.my.username}/projects"; + watch = false; + rescanInterval = 7200; + enable = ifEnabledDevice devices; + }; + secrets = rec { + devices = [ "kuro" "shiro" "ao" "aka" ]; + path = "/home/${config.my.username}/.secrets"; + enable = ifEnabledDevice devices; + }; + }; + }; }; }