nixos-anywhere/terraform/nixos-rebuild/main.tf
Jean-François Roche 4371932193 fix(rebuild): use sudo if rebuild with another user than root
In order to switch the NixOS configuration, we must have root access.
If we are connecting to the target host with a non-root user, we use the "sudo" command.

We could instead use `nixos-rebuild --use-remote-sudo --target-host` but it
would evaluate the nixos system again.
2023-03-31 21:33:05 +02:00

13 lines
312 B
HCL

resource "null_resource" "nixos-rebuild" {
triggers = {
store_path = var.nixos_system
}
provisioner "local-exec" {
environment = {
SSH_KEY = var.ssh_private_key
}
command = "${path.module}/deploy.sh ${var.nixos_system} ${var.target_user} ${var.target_host} ${var.target_port}"
}
}