Skip to content

Commit

Permalink
terraform/install: support build_on_remote
Browse files Browse the repository at this point in the history
  • Loading branch information
Enzime committed Dec 27, 2023
1 parent 3a87ed3 commit e9b062d
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
2 changes: 2 additions & 0 deletions terraform/install/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 8 additions & 1 deletion terraform/install/run-nixos-anywhere.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
14 changes: 14 additions & 0 deletions terraform/install/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand Down Expand Up @@ -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 = ""
}

0 comments on commit e9b062d

Please sign in to comment.