Merge pull request #239427 from ncfavier/syncthing-escaping
nixos/syncthing: fix escaping
This commit is contained in:
commit
b7098c1239
|
@ -55,9 +55,9 @@ let
|
||||||
|
|
||||||
# generate the new config by merging with the NixOS config options
|
# generate the new config by merging with the NixOS config options
|
||||||
new_cfg=$(printf '%s\n' "$old_cfg" | ${pkgs.jq}/bin/jq -c '. * {
|
new_cfg=$(printf '%s\n' "$old_cfg" | ${pkgs.jq}/bin/jq -c '. * {
|
||||||
"devices": (${builtins.toJSON devices}${optionalString (cfg.devices == {} || ! cfg.overrideDevices) " + .devices"}),
|
"devices": ('${escapeShellArg (builtins.toJSON devices)}'${optionalString (cfg.devices == {} || ! cfg.overrideDevices) " + .devices"}),
|
||||||
"folders": (${builtins.toJSON folders}${optionalString (cfg.folders == {} || ! cfg.overrideFolders) " + .folders"})
|
"folders": ('${escapeShellArg (builtins.toJSON folders)}'${optionalString (cfg.folders == {} || ! cfg.overrideFolders) " + .folders"})
|
||||||
} * ${builtins.toJSON cfg.extraOptions}')
|
} * '${escapeShellArg (builtins.toJSON cfg.extraOptions)})
|
||||||
|
|
||||||
# send the new config
|
# send the new config
|
||||||
curl -X PUT -d "$new_cfg" ${cfg.guiAddress}/rest/config
|
curl -X PUT -d "$new_cfg" ${cfg.guiAddress}/rest/config
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import ./make-test-python.nix ({ lib, pkgs, ... }: let
|
import ./make-test-python.nix ({ lib, pkgs, ... }: let
|
||||||
|
|
||||||
testId = "7CFNTQM-IMTJBHJ-3UWRDIU-ZGQJFR6-VCXZ3NB-XUH3KZO-N52ITXR-LAIYUAU";
|
testId = "7CFNTQM-IMTJBHJ-3UWRDIU-ZGQJFR6-VCXZ3NB-XUH3KZO-N52ITXR-LAIYUAU";
|
||||||
|
testName = "testDevice foo'bar";
|
||||||
|
|
||||||
in {
|
in {
|
||||||
name = "syncthing-init";
|
name = "syncthing-init";
|
||||||
|
@ -9,12 +10,12 @@ in {
|
||||||
nodes.machine = {
|
nodes.machine = {
|
||||||
services.syncthing = {
|
services.syncthing = {
|
||||||
enable = true;
|
enable = true;
|
||||||
devices.testDevice = {
|
devices.${testName} = {
|
||||||
id = testId;
|
id = testId;
|
||||||
};
|
};
|
||||||
folders.testFolder = {
|
folders.testFolder = {
|
||||||
path = "/tmp/test";
|
path = "/tmp/test";
|
||||||
devices = [ "testDevice" ];
|
devices = [ testName ];
|
||||||
};
|
};
|
||||||
extraOptions.gui.user = "guiUser";
|
extraOptions.gui.user = "guiUser";
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue