mirror of
https://github.com/nix-community/nixos-anywhere.git
synced 2024-09-11 16:45:28 +03:00
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.
13 lines
312 B
HCL
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}"
|
|
}
|
|
}
|