terraform/install: support build_on_remote

This commit is contained in:
Michael Hoang 2023-12-28 09:02:05 +11:00 committed by mergify[bot]
parent b20ded671e
commit 38d8eea71f
3 changed files with 24 additions and 1 deletions

View File

@ -18,6 +18,8 @@ resource "null_resource" "nixos-remote" {
target_host = var.target_host
extra_files_script = var.extra_files_script
no_reboot = var.no_reboot
build_on_remote = var.build_on_remote
flake = var.flake
}, var.extra_environment)
command = "${path.module}/run-nixos-anywhere.sh ${join(" ", local.disk_encryption_key_scripts)}"
quiet = var.debug_logging

View File

@ -17,7 +17,14 @@ fi
if [[ ${no_reboot-} == "true" ]]; then
args+=("--no-reboot")
fi
args+=("--store-paths" "${nixos_partitioner}" "${nixos_system}")
if [[ ${build_on_remote-} == "true" ]]; then
args+=("--build-on-remote")
fi
if [[ -n ${flake-} ]]; then
args+=("--flake" "${flake}")
else
args+=("--store-paths" "${nixos_partitioner}" "${nixos_system}")
fi
tmpdir=$(mktemp -d)
cleanup() {

View File

@ -8,12 +8,14 @@ variable "kexec_tarball_url" {
variable "nixos_partitioner" {
type = string
description = "nixos partitioner and mount script"
default = ""
}
# To make this re-usable we maybe should accept a store path here?
variable "nixos_system" {
type = string
description = "The nixos system to deploy"
default = ""
}
variable "target_host" {
@ -83,3 +85,15 @@ variable "no_reboot" {
description = "Do not reboot the machine after installation"
default = false
}
variable "build_on_remote" {
type = bool
description = "Build the closure on the remote machine instead of building it locally and copying it over"
default = false
}
variable "flake" {
type = string
description = "The flake to install the system from"
default = ""
}