Syncthing, HM and Nixos Module

This commit is contained in:
Julia Lange 2025-08-04 18:19:58 -07:00
parent bdb1ba2249
commit 863101b6f6
Signed by: Julia
SSH key fingerprint: SHA256:50XUMcOFYPUs9/1j7p9SPnwASZ7QnxXm7THF7HkbqzQ
4 changed files with 152 additions and 2 deletions

View file

@ -0,0 +1,64 @@
{ config, lib, ... }:
{
options.syncthing = {
enable = lib.mkEnableOption "Enables Syncthing service";
devices = lib.mkOption {
type = lib.types.attrsOf (lib.types.submodule {
options = {
id = lib.mkOption {
type = lib.types.str;
description = "Device ID";
};
addresses = lib.mkOption {
type = lib.types.listOf lib.types.str;
default = [ "dynamic" ];
description = "List of device addresses";
};
};
});
default = {};
description = "Syncthing devices";
};
folders = lib.mkOption {
type = lib.types.attrsOf (lib.types.submodule {
options = {
path = lib.mkOption {
type = lib.types.path;
description = "Path to folder";
};
devices = lib.mkOption {
type = lib.types.listOf lib.types.str;
default = [];
description = "List of device names to share with";
};
};
});
default = {};
description = "Syncthing folders";
};
};
config = lib.mkIf config.syncthing.enable {
services.syncthing = {
enable = true;
openDefaultPorts = true;
overrideDevices = true;
overrideFolders = true;
settings = {
devices = lib.mapAttrs (name: device: {
id = device.id;
addresses = device.addresses;
}) config.syncthing.devices;
folders = lib.mapAttrs (name: folder: {
path = folder.path;
devices = folder.devices;
}) config.syncthing.folders;
};
};
};
}