54 lines
1.1 KiB
Nix
54 lines
1.1 KiB
Nix
{
|
|
config,
|
|
lib,
|
|
...
|
|
}:
|
|
let
|
|
syncthingMesh = lib.listToAttrs (
|
|
lib.concatMap (
|
|
machine:
|
|
lib.mapAttrsToList (
|
|
userName: user:
|
|
let
|
|
name = "${userName}@${machine.name}";
|
|
in
|
|
{
|
|
inherit name;
|
|
value = {
|
|
inherit name;
|
|
id = user.syncthingId;
|
|
};
|
|
}
|
|
) (lib.filterAttrs (_: user: user.syncthingId != null) machine.users)
|
|
) (builtins.attrValues config.repo.machines)
|
|
);
|
|
in
|
|
{
|
|
flake.modules.homeManager.syncthing =
|
|
{ ... }:
|
|
{
|
|
services.syncthing = {
|
|
enable = true;
|
|
|
|
overrideDevices = true;
|
|
overrideFolders = true;
|
|
|
|
settings = {
|
|
folders = {
|
|
sync = {
|
|
path = "~/sync";
|
|
label = "sync";
|
|
devices = builtins.attrNames syncthingMesh;
|
|
};
|
|
calibre = {
|
|
path = "~/calibre";
|
|
label = "calibre";
|
|
devices = builtins.attrNames syncthingMesh;
|
|
};
|
|
};
|
|
devices = syncthingMesh;
|
|
};
|
|
};
|
|
};
|
|
}
|