Syncthing, HM and Nixos Module
This commit is contained in:
parent
bdb1ba2249
commit
863101b6f6
4 changed files with 152 additions and 2 deletions
64
nixosModules/services/syncthing/service.nix
Normal file
64
nixosModules/services/syncthing/service.nix
Normal 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;
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue