62 lines
1.5 KiB
Nix
62 lines
1.5 KiB
Nix
{
|
|
config,
|
|
lib,
|
|
...
|
|
}:
|
|
let
|
|
account = config.facts.account;
|
|
syncMachines = lib.mapAttrs' (
|
|
machineName: machine:
|
|
let
|
|
name = "${account.name}@${machineName}";
|
|
in
|
|
lib.nameValuePair name {
|
|
inherit name;
|
|
id = machine.syncthingId;
|
|
}
|
|
) (lib.filterAttrs (_: machine: machine.syncthingId != null) config.facts.machines);
|
|
|
|
syncExternalDevices = lib.mapAttrs (name: device: {
|
|
inherit name;
|
|
id = device.syncthingId;
|
|
}) (lib.filterAttrs (_: device: device.syncthingId != null) config.facts.externalDevices);
|
|
|
|
syncDevices = syncMachines // syncExternalDevices;
|
|
in
|
|
{
|
|
flake.modules.homeManager.syncthing =
|
|
{ config, ... }:
|
|
{
|
|
services.syncthing = {
|
|
enable = true;
|
|
|
|
overrideDevices = true;
|
|
overrideFolders = true;
|
|
|
|
settings = {
|
|
folders = {
|
|
sync = {
|
|
path = "${config.home.homeDirectory}/sync";
|
|
label = "sync";
|
|
devices = builtins.attrNames syncDevices;
|
|
ignorePatterns = [
|
|
"**/.devenv"
|
|
"**/.zk"
|
|
];
|
|
};
|
|
bruno = {
|
|
path =
|
|
if config.facts.machine.name == "orion" then
|
|
"${config.home.homeDirectory}/bruno"
|
|
else
|
|
"${config.xdg.userDirs.projects}/bruno";
|
|
label = "bruno";
|
|
devices = builtins.attrNames syncDevices;
|
|
};
|
|
};
|
|
devices = syncDevices;
|
|
};
|
|
};
|
|
};
|
|
}
|