From 43bc09e03794f3aa4585a1a39925dca5e90a2c14 Mon Sep 17 00:00:00 2001 From: Andrew Barchuk Date: Sat, 29 Oct 2022 14:22:45 +0200 Subject: [PATCH] nixos/syncthing: keep manually added dirs/devices If folders and devices are not configured explicitly, do not wipe the changes done via the web GUI. Currently the list of devices or folders will be reset unless overrideFolders/overrideDevices is disabled. --- nixos/modules/services/networking/syncthing.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nixos/modules/services/networking/syncthing.nix b/nixos/modules/services/networking/syncthing.nix index 0876007a6e73..ea87e5695f87 100644 --- a/nixos/modules/services/networking/syncthing.nix +++ b/nixos/modules/services/networking/syncthing.nix @@ -55,8 +55,8 @@ let # generate the new config by merging with the NixOS config options new_cfg=$(printf '%s\n' "$old_cfg" | ${pkgs.jq}/bin/jq -c '. * { - "devices": (${builtins.toJSON devices}${optionalString (! cfg.overrideDevices) " + .devices"}), - "folders": (${builtins.toJSON folders}${optionalString (! cfg.overrideFolders) " + .folders"}) + "devices": (${builtins.toJSON devices}${optionalString (cfg.devices == {} || ! cfg.overrideDevices) " + .devices"}), + "folders": (${builtins.toJSON folders}${optionalString (cfg.folders == {} || ! cfg.overrideFolders) " + .folders"}) } * ${builtins.toJSON cfg.extraOptions}') # send the new config