feat(syncthing): set up LAN-only sync for 'readings'

This commit is contained in:
2026-07-23 19:17:29 +02:00
parent 254f9c2577
commit 696dffcbfb
3 changed files with 69 additions and 2 deletions
+49 -1
View File
@@ -3,9 +3,42 @@
let
cfg = config.syncthing;
inherit (config.host) username;
deviceRegistry = import ./devices.nix;
deviceName = lib.types.enum (builtins.attrNames deviceRegistry);
referencedDevices = lib.unique (
lib.concatMap (folder: folder.devices) (lib.attrValues cfg.folders)
);
in
{
options.syncthing.enable = lib.mkEnableOption "syncthing";
options.syncthing = {
enable = lib.mkEnableOption "syncthing";
folders = lib.mkOption {
default = { };
type = lib.types.attrsOf (
lib.types.submodule {
options = {
path = lib.mkOption {
type = lib.types.str;
};
type = lib.mkOption {
type = lib.types.enum [
"sendreceive"
"sendonly"
"receiveonly"
"receiveencrypted"
];
default = "sendreceive";
};
devices = lib.mkOption {
type = lib.types.listOf deviceName;
default = [ ];
};
};
}
);
};
};
config = lib.mkIf cfg.enable {
users.groups.${username} = { };
@@ -17,6 +50,21 @@ in
group = username;
configDir = "/home/${username}/.local/state/syncthing";
openDefaultPorts = true;
settings = {
devices = lib.getAttrs referencedDevices deviceRegistry;
folders = lib.mapAttrs (_: folder: {
inherit (folder)
path
type
devices
;
}) cfg.folders;
options = {
globalAnnounceEnabled = false;
localAnnounceEnabled = true;
relaysEnabled = false;
};
};
};
};
}