64 lines
1.6 KiB
Nix
64 lines
1.6 KiB
Nix
{ 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;
|
|
};
|
|
};
|
|
};
|
|
}
|