Skip to content

Commit 87806c9

Browse files
authored
nixos/syncthing: prevent enabling overrideFolders and autoAcceptFolders simultaneously (#321872)
* syncthing: prevent enabling overrideFolders and autoAcceptFolders simultaneously * Fix href in services.syncthing.overrideFolders default text
1 parent 4da35d1 commit 87806c9

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

nixos/modules/services/networking/syncthing.nix

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ let
2929
deviceID = device.id;
3030
}) cfg.settings.devices;
3131

32+
anyAutoAccept = builtins.any (dev: dev.autoAcceptFolders) devices;
33+
3234
folders = mapAttrsToList (_: folder: folder //
3335
throwIf (folder?rescanInterval || folder?watch || folder?watchDelay) ''
3436
The options services.syncthing.settings.folders.<name>.{rescanInterval,watch,watchDelay}
@@ -180,7 +182,12 @@ in {
180182

181183
overrideFolders = mkOption {
182184
type = types.bool;
183-
default = true;
185+
default = !anyAutoAccept;
186+
defaultText = literalMD ''
187+
`true` unless any device has the
188+
[autoAcceptFolders](#opt-services.syncthing.settings.devices._name_.autoAcceptFolders)
189+
option set to `true`.
190+
'';
184191
description = ''
185192
Whether to delete the folders which are not configured via the
186193
[folders](#opt-services.syncthing.settings.folders) option.
@@ -620,6 +627,15 @@ in {
620627
###### implementation
621628

622629
config = mkIf cfg.enable {
630+
assertions = [
631+
{
632+
assertion = !(cfg.overrideFolders && anyAutoAccept);
633+
message = ''
634+
services.syncthing.overrideFolders will delete auto-accepted folders
635+
from the configuration, creating path conflicts.
636+
'';
637+
}
638+
];
623639

624640
networking.firewall = mkIf cfg.openDefaultPorts {
625641
allowedTCPPorts = [ 22000 ];

0 commit comments

Comments
 (0)