From 3faf4a15072006f684dcce8ca95d198aeaf2c2f4 Mon Sep 17 00:00:00 2001 From: Maximilian Dietrich Date: Mon, 30 Jun 2025 01:11:18 +0200 Subject: [PATCH] syncthing: add guiAddress to configuration (#7281) We have a configuration option services.syncthing.guiAddress which is an explicit option because we need it in the syncthing-init service, but why not also set it in the actual syncthing config as well as (or instead of?) the current CLI override? This way other software that parses the config file / REST API like syncthingtray just works with it instead of erroring out and unexpectedly requesting user interaction. I guess we could actually also scrap the explicit services.syncthing.guiAddress option in favor of the syncthing-native services.syncthing.settings.gui.address because these two (valid!) options conflict otherwise. Also, a next PR (or addition to this one) could be to make sure the syncthing-init service treats services.syncthing.settings.gui differently by not PUTting but PATCHing the configuration as PUTting triggers an API key regeneration, again breaking REST API access for other tools. --- modules/services/syncthing.nix | 3 +++ 1 file changed, 3 insertions(+) diff --git a/modules/services/syncthing.nix b/modules/services/syncthing.nix index 3fb60535..f5cdf016 100644 --- a/modules/services/syncthing.nix +++ b/modules/services/syncthing.nix @@ -199,6 +199,9 @@ let syncthing_password=$(${cat} ${cfg.passwordFile}) curl -X PATCH -d '{"password": "'$syncthing_password'"}' ${curlAddressArgs "/rest/config/gui"} '' + + lib.optionalString (cfg.guiAddress != null) '' + curl -X PATCH -d '{"address": "'${cfg.guiAddress}'"}' ${curlAddressArgs "/rest/config/gui"} + '' + '' # restart Syncthing if required if curl ${curlAddressArgs "/rest/config/restart-required"} |