{ config, lib, pkgs, ... }: with lib; { test.services.syncthing = { guiAddress = "${config.networking.hostName}.private:8384"; declarative = { overrideDevices = true; devices = let device = name: id: { "${name}" = { name = name; id = id; addresses = [ "tcp://${name}.private:22000" "tcp://${name}.private:21027" ]; }; }; in (device "workhorse" "AFSAKB6-JLH4QAS-DSRMPI3-6PVCIHF-IIAVLPC-STPNO3Y-YRDU5NW-QD445QI") // (device "pepe" "SZLXFW3-VTAC7UB-V2Z7CHE-3VZAYPL-6D72AK6-OCDMPZP-G4FPY5P-FL6ZVAG") // (device "kruck" "7NXJTB6-XPQD5AO-Z6LY4GZ-UGCLPJI-3EQSZ4B-YT4OV2F-NWAI2BN-OE3IEQW") // (device "schasch" "FLY7DHI-TJLEQBJ-JZNC4YV-NBX53Z2-ZBRWADL-BKSFXYZ-L4FMDVH-MOSEVAQ") // (device "workout" "DZOOAKG-GI2SVOS-QEVMFL7-TRHVTPQ-ADIJEVH-RH5WV3J-6M7MJHC-C53EOAC") // (device "porani" "6YOIA4E-X52ZD5Z-FPNWPRS-77QIMMU-VDIXVZB-6BPQN7A-FFJDU4W-EXEGFAI") // (device "sterni" "NFQP2DG-IK5SEL3-JTOV3HW-HF2EPAO-JQK3VSW-NKVMPFH-LZE6SEQ-INZ25QC") // { smartphone = { name = "smartphone"; id = "P6MFODE-PO7CRVB-5RL5AMX-HG4D2CE-C2NC7M4-RYHGX2N-VUU2DWL-C6GVPQN"; addresses = [ "dynamic" ]; }; } // { bumba = { name = "windows-bumba"; id = "JS7PWTO-VKFGBUP-GNFLSWP-MGFJ2KH-HLO2LKW-V3RPCR6-PCB5SQC-42FCKQZ"; addresses = [ "dynamic" ]; }; } // { mors = { name = "lassulus-mors"; id = "ZPRS57K-YK32ROQ-7A6MRAV-VOYXQ3I-CQCXISZ-C5PCV2A-GSFLG3I-K7UGGAH"; addresses = [ "tcp://mors.r:22000" ]; }; }; folders = { book = { id = "wwbvs-5lfbh"; watch = false; devices = [ "workout" "pepe" "sterni" ]; }; desktop-encrypted = { id = "ebnth-pfven"; watch = false; devices = [ "workout" "workhorse" "pepe" "sterni" ]; }; fotos-encrypted = { id = "ddkrc-mevxd"; watch = false; devices = [ "workout" "workhorse" "pepe" "sterni" ]; }; finance-encrypted = { id = "gl7rx-sdsnx"; watch = false; devices = [ "workout" "workhorse" "pepe" "sterni" ]; }; movies = { id = "vatmy-c2qf4"; watch = false; devices = [ "workhorse" "porani" ]; }; porn = { id = "vatmy-c2qf4"; watch = false; devices = [ "workhorse" "porani" ]; }; music-library = { id = "gytmq-r2zrx"; watch = false; devices = [ "porani" "workout" "workhorse" "pepe" "sterni" ]; }; music-library-free = { id = "mu9mn-zgvsw"; watch = false; devices = [ "workout" "workhorse" "mors" ]; }; music-projects = { id = "acfhu-r4t4f"; watch = false; devices = [ "workout" "workhorse" "pepe" "sterni" ]; }; podcasts = { id = "yvzmx-hcomd"; watch = false; devices = [ "workhorse" "porani" ]; }; samples = { id = "pcgkj-tjucd"; watch = false; devices = [ "workout" "workhorse" "sterni" ]; }; series = { id = "all-series"; watch = false; devices = [ "workhorse" "porani" ]; }; smartphone-music = { id = "0vjze-xvs8n"; watch = false; devices = [ "workout" "smartphone" ]; }; smartphone-fotos = { id = "e5823_jtbr-photos"; watch = false; devices = [ "sterni" "workout" "pepe" "smartphone" ]; }; video-material = { id = "wgkun-fec5h"; watch = false; devices = [ "workout" "workhorse" ]; }; # one on one porani-workout = { devices = [ "porani" "workout" ]; watch = false; }; porani-pepe = { devices = [ "porani" "pepe" ]; watch = false; }; windows-sync = { id = "hcity-p5ikc"; watch = false; devices = [ "schasch" "bumba" "workout" "kruck" ]; }; workout-pepe = { devices = [ "pepe" "workout" ]; watch = false; }; }; }; }; # convenience script to know which folder needs to be configured environment.systemPackages = let folders = config.test.services.syncthing.declarative.folders; computers = unique (flatten (mapAttrsToList (_: value: value.devices) folders)); isComputerInDeviceList = computer: deviceList: (unique deviceList) == (unique (deviceList ++ [ computer ])); getFolderNames = computer: naturalSort (builtins.attrNames (filterAttrs (_: folder: isComputerInDeviceList computer folder.devices) folders)); computerMap = foldl (acumulator: computer: acumulator // { "${computer}" = getFolderNames computer; } ) {} computers; printTemplate = folder: ''${folder}.path = "";''; in mapAttrsToList (computer: folders: pkgs.writeShellScriptBin "syncthing.${computer}" '' cat <