From 295a580ca7f59d14179e56943bfefe7ddb9950be Mon Sep 17 00:00:00 2001 From: Peter Kling 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 da88215e4..a87f5c3e7 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.