2023-01-29 17:44:23 +01:00
|
|
|
#!/usr/bin/env bash
|
2023-11-30 15:57:03 +01:00
|
|
|
|
|
|
|
# SPDX-FileCopyrightText: 2023 The TVL Authors
|
|
|
|
#
|
|
|
|
# SPDX-License-Identifier: MIT
|
|
|
|
|
2023-01-29 17:44:23 +01:00
|
|
|
#
|
|
|
|
# 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.
|
2023-03-01 14:56:14 +01:00
|
|
|
eval "$(jq -r '@sh "ATTRPATH=\(.attrpath) && ENTRYPOINT=\(.entrypoint)"')"
|
2023-01-29 17:44:23 +01:00
|
|
|
|
|
|
|
# Evaluate the system derivation.
|
2023-03-01 14:56:14 +01:00
|
|
|
[[ -z "$ENTRYPOINT" ]] && ENTRYPOINT=$(git rev-parse --show-toplevel)
|
|
|
|
SYSTEM_DRV=$(nix-instantiate -A "${ATTRPATH}" "${ENTRYPOINT}")
|
2023-01-29 17:44:23 +01:00
|
|
|
|
|
|
|
# Return system derivation back to Terraform.
|
|
|
|
jq -n --arg drv "$SYSTEM_DRV" '{"drv":$drv}'
|