organized into folders
This commit is contained in:
parent
8a8fe8cfc6
commit
84c5dd7422
7 changed files with 5 additions and 9 deletions
43
lib/nixos-module.nix
Normal file
43
lib/nixos-module.nix
Normal file
|
@ -0,0 +1,43 @@
|
|||
{
|
||||
lib,
|
||||
config,
|
||||
...
|
||||
} @ input: {
|
||||
options = {
|
||||
services.syncthing = {
|
||||
configuration = (import ./configuration-type.nix) input;
|
||||
deviceName = lib.mkOption {
|
||||
type = lib.types.string;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = {
|
||||
services.syncthing.settings = {
|
||||
devices =
|
||||
lib.attrsets.mapAttrs (name: deviceConfig: {
|
||||
id = deviceConfig.id;
|
||||
})
|
||||
config.services.syncthing.configuration.devices;
|
||||
folders =
|
||||
lib.attrsets.mapAttrs (folderName: folder: {
|
||||
id = folder.folder.id;
|
||||
label = folder.folder.label;
|
||||
path = folder.path;
|
||||
devices = lib.attrsets.mapAttrsToList (_: device: device.name) (
|
||||
lib.attrsets.filterAttrs (
|
||||
deviceName: device:
|
||||
lib.lists.any
|
||||
(
|
||||
deviceFolder: deviceFolder.folder.id == folder.folder.id
|
||||
) (
|
||||
lib.attrsets.mapAttrsToList (_: deviceFolder: deviceFolder) device.folders
|
||||
)
|
||||
)
|
||||
config.services.syncthing.configuration.devices
|
||||
);
|
||||
})
|
||||
config.services.syncthing.configuration.devices.${config.services.syncthing.deviceName}.folders;
|
||||
};
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue