From 35f636b68482d8c84939b4707514a48416557bb4 Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Wed, 13 Mar 2024 18:39:23 +0200 Subject: feat(ops/terraform/deploy-nixos): support argstr map 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 Reviewed-by: tazjin --- ops/terraform/deploy-nixos/nixos-eval.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'ops') diff --git a/ops/terraform/deploy-nixos/nixos-eval.sh b/ops/terraform/deploy-nixos/nixos-eval.sh index dbc03d2fec..f206fe7f68 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}' -- cgit 1.4.1