Skip to content

Commit 3458298

Browse files
KiaraGrouwstramergify[bot]
authored andcommitted
terraform/nix-build.sh: prevent error on empty nix_options
currently, when `var.nix_options` is not set, the jq map action yields `null`, which ends up missing up. using a conditional here, we may instead account for this case such as to set it to empty string and avoid the issue.
1 parent d6869b0 commit 3458298

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

terraform/nix-build/nix-build.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@ set -efu
33

44
declare file attribute nix_options
55
eval "$(jq -r '@sh "attribute=\(.attribute) file=\(.file) nix_options=\(.nix_options)"')"
6-
options=$(echo "${nix_options}" | jq -r '.options | to_entries | map("--option \(.key) \(.value)") | join(" ")')
6+
if [ "${nix_options}" != '{"options":{}}' ]; then
7+
options=$(echo "${nix_options}" | jq -r '.options | to_entries | map("--option \(.key) \(.value)") | join(" ")')
8+
else
9+
options=""
10+
fi
711
if [[ -n ${file-} ]] && [[ -e ${file-} ]]; then
812
# shellcheck disable=SC2086
913
out=$(nix build --no-link --json $options -f "$file" "$attribute")

0 commit comments

Comments
 (0)