From 33ffe942525d57310ef64b34e95fb55c1535a7dc Mon Sep 17 00:00:00 2001 From: Peter Kling <1018801+pitkling@users.noreply.github.com> Date: Thu, 29 Aug 2024 20:36:07 +0200 Subject: [PATCH] move curl shell function into string variable Allows us to reuse the function in different scripts. --- modules/services/syncthing.nix | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/modules/services/syncthing.nix b/modules/services/syncthing.nix index 75569589..f4fe6acd 100644 --- a/modules/services/syncthing.nix +++ b/modules/services/syncthing.nix @@ -66,12 +66,7 @@ let ''} ''; - updateConfig = pkgs.writers.writeBash "merge-syncthing-config" ('' - set -efu - - # be careful not to leak secrets in the filesystem or in process listings - umask 0077 - + curlShellFunction = '' curl() { # get the api key by parsing the config.xml while @@ -85,6 +80,15 @@ let --retry 1000 --retry-delay 1 --retry-all-errors \ "$@" } + ''; + + updateConfig = pkgs.writers.writeBash "merge-syncthing-config" ('' + set -efu + + # be careful not to leak secrets in the filesystem or in process listings + umask 0077 + + ${curlShellFunction} '' + /* Syncthing's rest API for the folders and devices is almost identical.