|
34 | 34 | The options services.syncthing.settings.folders.<name>.{rescanInterval,watch,watchDelay}
|
35 | 35 | were removed. Please use, respectively, {rescanIntervalS,fsWatcherEnabled,fsWatcherDelayS} instead.
|
36 | 36 | '' {
|
37 |
| - devices = map (device: |
38 |
| - if builtins.isString device then |
39 |
| - { deviceId = cfg.settings.devices.${device}.id; } |
| 37 | + devices = let |
| 38 | + folderDevices = folder.devices; |
| 39 | + in |
| 40 | + if builtins.isList folderDevices then |
| 41 | + map (device: |
| 42 | + if builtins.isString device then |
| 43 | + { deviceId = cfg.settings.devices.${device}.id; } |
| 44 | + else |
| 45 | + device |
| 46 | + ) folderDevices |
| 47 | + else if builtins.isAttrs folderDevices then |
| 48 | + mapAttrsToList (deviceName: deviceValue: |
| 49 | + deviceValue // { deviceId = cfg.settings.devices.${deviceName}.id; } |
| 50 | + ) folderDevices |
40 | 51 | else
|
41 |
| - device |
42 |
| - ) folder.devices; |
| 52 | + throw "Invalid type for devices in folder '${folderName}'; expected list or attrset."; |
43 | 53 | }) (filterAttrs (_: folder:
|
44 | 54 | folder.enable
|
45 | 55 | ) cfg.settings.folders);
|
@@ -435,11 +445,30 @@ in {
|
435 | 445 | };
|
436 | 446 |
|
437 | 447 | devices = mkOption {
|
438 |
| - type = types.listOf types.str; |
| 448 | + type = types.oneOf [ |
| 449 | + (types.listOf types.str) |
| 450 | + (types.attrsOf (types.submodule ({ name, ... }: { |
| 451 | + freeformType = settingsFormat.type; |
| 452 | + options = { |
| 453 | + encryptionPassword = mkOption { |
| 454 | + type = types.nullOr types.str; |
| 455 | + default = null; |
| 456 | + description = '' |
| 457 | + Path to encryption password. If set, the file will be read during |
| 458 | + service activation, without being embedded in derivation. |
| 459 | + ''; |
| 460 | + }; |
| 461 | + }; |
| 462 | + })) |
| 463 | + )]; |
439 | 464 | default = [];
|
440 | 465 | description = ''
|
441 | 466 | The devices this folder should be shared with. Each device must
|
442 | 467 | be defined in the [devices](#opt-services.syncthing.settings.devices) option.
|
| 468 | +
|
| 469 | + Either a list of strings, or an attribute set, where keys are defined in the |
| 470 | + [devices](#opt-services.syncthing.settings.devices) option, and values are |
| 471 | + device configurations. |
443 | 472 | '';
|
444 | 473 | };
|
445 | 474 |
|
|
0 commit comments