From 515fb48312f6cb8e51bf0f24438b0faf92790afd Mon Sep 17 00:00:00 2001 From: talyz Date: Thu, 15 Apr 2021 13:20:22 +0200 Subject: [PATCH] nixos/discourse: Fail on file errors Bash doesn't handle subshell errors properly if the result is used as input to a command. To cause the services to fail when the files can't be read, we need to assign the value to a variable, then export it separately. --- nixos/modules/services/web-apps/discourse.nix | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/nixos/modules/services/web-apps/discourse.nix b/nixos/modules/services/web-apps/discourse.nix index 03ea002c9de..38ca08c4759 100644 --- a/nixos/modules/services/web-apps/discourse.nix +++ b/nixos/modules/services/web-apps/discourse.nix @@ -726,7 +726,8 @@ in export ADMIN_EMAIL="${cfg.admin.email}" export ADMIN_NAME="${cfg.admin.fullName}" export ADMIN_USERNAME="${cfg.admin.username}" - export ADMIN_PASSWORD="$(<${cfg.admin.passwordFile})" + ADMIN_PASSWORD="$(<${cfg.admin.passwordFile})" + export ADMIN_PASSWORD discourse-rake admin:create_noninteractively discourse-rake themes:update @@ -938,7 +939,8 @@ in set -o errexit -o pipefail -o nounset -o errtrace shopt -s inherit_errexit - export api_key=$(<'${apiKeyPath}') + api_key=$(<'${apiKeyPath}') + export api_key jq <${mail-receiver-json} \ '.DISCOURSE_API_KEY = $ENV.api_key' \