nixos/syncthing: fix escaping

This commit is contained in:
Naïm Favier 2023-06-23 20:12:19 +02:00
parent 1fa8dad8e7
commit 9a9ded1675
No known key found for this signature in database
GPG Key ID: 95AFCE8211908325
2 changed files with 6 additions and 5 deletions

View File

@ -55,9 +55,9 @@ 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.devices == {} || ! cfg.overrideDevices) " + .devices"}),
"folders": (${builtins.toJSON folders}${optionalString (cfg.folders == {} || ! cfg.overrideFolders) " + .folders"})
} * ${builtins.toJSON cfg.extraOptions}')
"devices": ('${escapeShellArg (builtins.toJSON devices)}'${optionalString (cfg.devices == {} || ! cfg.overrideDevices) " + .devices"}),
"folders": ('${escapeShellArg (builtins.toJSON folders)}'${optionalString (cfg.folders == {} || ! cfg.overrideFolders) " + .folders"})
} * '${escapeShellArg (builtins.toJSON cfg.extraOptions)})
# send the new config
curl -X PUT -d "$new_cfg" ${cfg.guiAddress}/rest/config

View File

@ -1,6 +1,7 @@
import ./make-test-python.nix ({ lib, pkgs, ... }: let
testId = "7CFNTQM-IMTJBHJ-3UWRDIU-ZGQJFR6-VCXZ3NB-XUH3KZO-N52ITXR-LAIYUAU";
testName = "testDevice foo'bar";
in {
name = "syncthing-init";
@ -9,12 +10,12 @@ in {
nodes.machine = {
services.syncthing = {
enable = true;
devices.testDevice = {
devices.${testName} = {
id = testId;
};
folders.testFolder = {
path = "/tmp/test";
devices = [ "testDevice" ];
devices = [ testName ];
};
extraOptions.gui.user = "guiUser";
};