diff options
Diffstat (limited to 'ops/terraform/deploy-nixos/nixos-eval.sh')
-rwxr-xr-x | ops/terraform/deploy-nixos/nixos-eval.sh | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/ops/terraform/deploy-nixos/nixos-eval.sh b/ops/terraform/deploy-nixos/nixos-eval.sh new file mode 100755 index 000000000000..dd15784b1b49 --- /dev/null +++ b/ops/terraform/deploy-nixos/nixos-eval.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash +# +# Builds a NixOS system configuration at the given attribute path. +set -ueo pipefail + +# Load input variables from Terraform. jq's @sh format takes care of +# escaping. +eval "$(jq -r '@sh "ATTRPATH=\(.attrpath)"')" + +# Evaluate the system derivation. +# TODO: configurable REPO_ROOT +REPO_ROOT=$(git rev-parse --show-toplevel) +SYSTEM_DRV=$(nix-instantiate -A "${ATTRPATH}" "${REPO_ROOT}") + +# Return system derivation back to Terraform. +jq -n --arg drv "$SYSTEM_DRV" '{"drv":$drv}' |