diff options
Diffstat (limited to 'ops/terraform/deploy-nixos')
-rw-r--r-- | ops/terraform/deploy-nixos/main.tf | 13 | ||||
-rwxr-xr-x | ops/terraform/deploy-nixos/nixos-eval.sh | 7 |
2 files changed, 15 insertions, 5 deletions
diff --git a/ops/terraform/deploy-nixos/main.tf b/ops/terraform/deploy-nixos/main.tf index 3ff7bfc3f30a..d39610327a0e 100644 --- a/ops/terraform/deploy-nixos/main.tf +++ b/ops/terraform/deploy-nixos/main.tf @@ -24,6 +24,16 @@ variable "target_host" { type = string } +variable "entrypoint" { + description = <<EOT + Path to a .nix file (or directory containing `default.nix` file) + that provides the attrset specified in `closure`. + If unset, asks git for the root of the repository. + EOT + type = string + default = "" +} + variable "target_user" { description = "username on the target machine" type = string @@ -40,7 +50,8 @@ data "external" "nixos_system" { program = ["${path.module}/nixos-eval.sh"] query = { - attrpath = var.attrpath + attrpath = var.attrpath + entrypoint = var.entrypoint } } diff --git a/ops/terraform/deploy-nixos/nixos-eval.sh b/ops/terraform/deploy-nixos/nixos-eval.sh index dd15784b1b49..38f036bba936 100755 --- a/ops/terraform/deploy-nixos/nixos-eval.sh +++ b/ops/terraform/deploy-nixos/nixos-eval.sh @@ -5,12 +5,11 @@ set -ueo pipefail # Load input variables from Terraform. jq's @sh format takes care of # escaping. -eval "$(jq -r '@sh "ATTRPATH=\(.attrpath)"')" +eval "$(jq -r '@sh "ATTRPATH=\(.attrpath) && ENTRYPOINT=\(.entrypoint)"')" # Evaluate the system derivation. -# TODO: configurable REPO_ROOT -REPO_ROOT=$(git rev-parse --show-toplevel) -SYSTEM_DRV=$(nix-instantiate -A "${ATTRPATH}" "${REPO_ROOT}") +[[ -z "$ENTRYPOINT" ]] && ENTRYPOINT=$(git rev-parse --show-toplevel) +SYSTEM_DRV=$(nix-instantiate -A "${ATTRPATH}" "${ENTRYPOINT}") # Return system derivation back to Terraform. jq -n --arg drv "$SYSTEM_DRV" '{"drv":$drv}' |