about summary refs log tree commit diff
path: root/ops
diff options
context:
space:
mode:
authorFlorian Klink <flokli@flokli.de>2024-03-13T16·39+0200
committerclbot <clbot@tvl.fyi>2024-03-14T07·14+0000
commit35f636b68482d8c84939b4707514a48416557bb4 (patch)
tree73f3ef6ff0608f3d7d5ebd68e0c3955e4fe014fd /ops
parenta9db1455f57a5848fa3aa58e3891d3083252700f (diff)
feat(ops/terraform/deploy-nixos): support argstr map r/7690
This allows setting argstr to a map of keys and values.
We use jq to construct "--argstr k v" arguments, which are passed to
nix-instantiate.

Change-Id: I720a597ca2276364bc7005c156064d938f143041
Reviewed-on: https://cl.tvl.fyi/c/depot/+/11141
Tested-by: BuildkiteCI
Autosubmit: flokli <flokli@flokli.de>
Reviewed-by: tazjin <tazjin@tvl.su>
Diffstat (limited to 'ops')
-rwxr-xr-xops/terraform/deploy-nixos/nixos-eval.sh6
1 files changed, 3 insertions, 3 deletions
diff --git a/ops/terraform/deploy-nixos/nixos-eval.sh b/ops/terraform/deploy-nixos/nixos-eval.sh
index dbc03d2fecf5..f206fe7f6875 100755
--- a/ops/terraform/deploy-nixos/nixos-eval.sh
+++ b/ops/terraform/deploy-nixos/nixos-eval.sh
@@ -10,12 +10,12 @@ set -ueo pipefail
 
 # Load input variables from Terraform. jq's @sh format takes care of
 # escaping.
-eval "$(jq -r '@sh "attrpath=\(.attrpath) && entrypoint=\(.entrypoint)"')"
+eval "$(jq -r '@sh "attrpath=\(.attrpath) && entrypoint=\(.entrypoint) && argstr=\((.argstr // {}) | to_entries | map ("--argstr", .key, .value) | join(" "))"')"
 
 # Evaluate the system derivation.
 [[ -z "$entrypoint" ]] && entrypoint=$(git rev-parse --show-toplevel)
-# shellcheck disable=SC2154
-system_drv=$(nix-instantiate -A "${attrpath}" "${entrypoint}")
+# shellcheck disable=SC2086,SC2154
+system_drv=$(nix-instantiate -A "${attrpath}" "${entrypoint}" ${argstr})
 
 # Return system derivation back to Terraform.
 jq -n --arg drv "$system_drv" '{"drv":$drv}'