Files
lux/modules/capabilities/syncthing.nix
T
2026-05-06 21:57:58 +02:00

67 lines
1.3 KiB
Nix

{
config,
lib,
...
}:
let
syncMachines = lib.listToAttrs (
lib.concatLists (
lib.mapAttrsToList (
machineName: machine:
let
syncthingId = machine.syncthingId or null;
in
lib.optional (syncthingId != null) (
let
name = "${config.repo.account.name}@${machineName}";
in
{
inherit name;
value = {
inherit name;
id = syncthingId;
};
}
)
) config.repo.machines
)
);
syncPhones = {
"pixel-10" = {
name = "pixel-10";
id = "MTJHEHA-UMZDQZ7-BTMRRLQ-Y7BFPUJ-ZTY6LZX-PDXV3IS-XVJCU7B-EPETBQZ";
};
};
syncDevices = syncMachines // syncPhones;
in
{
flake.modules.homeManager.syncthing =
{ ... }:
{
services.syncthing = {
enable = true;
overrideDevices = true;
overrideFolders = true;
settings = {
folders = {
sync = {
path = "~/sync";
label = "sync";
devices = builtins.attrNames syncDevices;
};
calibre = {
path = "~/calibre";
label = "calibre";
devices = builtins.attrNames syncMachines;
};
};
devices = syncDevices;
};
};
};
}