Skip to content

Commit a5982ad

Browse files
authored
Merge pull request #487 from r-vdp/rvdp/install_bootloader
feat: add a flag to reinstall the bootloader
2 parents 76b6890 + 1556c0d commit a5982ad

File tree

5 files changed

+26
-4
lines changed

5 files changed

+26
-4
lines changed

terraform/all-in-one/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ module "nixos-rebuild" {
5656
target_host = var.target_host
5757
target_user = var.target_user
5858
target_port = var.target_port
59+
install_bootloader = var.install_bootloader
5960
}
6061

6162
output "result" {

terraform/all-in-one/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,3 +143,9 @@ variable "build_on_remote" {
143143
description = "Build the closure on the remote machine instead of building it locally and copying it over"
144144
default = false
145145
}
146+
147+
variable "install_bootloader" {
148+
type = bool
149+
description = "Install/re-install the bootloader"
150+
default = false
151+
}

terraform/nixos-rebuild/deploy.sh

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
set -uex -o pipefail
44

55
if [ "$#" -ne 5 ]; then
6-
echo "USAGE: $0 NIXOS_SYSTEM TARGET_USER TARGET_HOST TARGET_PORT IGNORE_SYSTEMD_ERRORS" >&2
6+
echo "USAGE: $0 NIXOS_SYSTEM TARGET_USER TARGET_HOST TARGET_PORT IGNORE_SYSTEMD_ERRORS INSTALL_BOOTLOADER" >&2
77
exit 1
88
fi
99

@@ -12,7 +12,9 @@ TARGET_USER=$2
1212
TARGET_HOST=$3
1313
TARGET_PORT=$4
1414
IGNORE_SYSTEMD_ERRORS=$5
15-
shift 3
15+
INSTALL_BOOTLOADER=$6
16+
17+
shift 6
1618

1719
TARGET="${TARGET_USER}@${TARGET_HOST}"
1820

@@ -46,7 +48,14 @@ until NIX_SSHOPTS="${sshOpts[*]}" nix copy -s --experimental-features nix-comman
4648
try=$((try + 1))
4749
done
4850

49-
switchCommand="nix-env -p /nix/var/nix/profiles/system --set $(printf "%q" "$NIXOS_SYSTEM"); /nix/var/nix/profiles/system/bin/switch-to-configuration switch"
51+
if [[ $INSTALL_BOOTLOADER == "true" ]]; then
52+
extra_env='NIXOS_INSTALL_BOOTLOADER=1'
53+
else
54+
extra_env=''
55+
fi
56+
57+
switchCommand="nix-env -p /nix/var/nix/profiles/system --set $(printf "%q" "$NIXOS_SYSTEM"); $extra_env /nix/var/nix/profiles/system/bin/switch-to-configuration switch"
58+
5059
if [[ $TARGET_USER != "root" ]]; then
5160
switchCommand="sudo bash -c '$switchCommand'"
5261
fi

terraform/nixos-rebuild/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ resource "null_resource" "nixos-rebuild" {
66
environment = {
77
SSH_KEY = var.ssh_private_key
88
}
9-
command = "${path.module}/deploy.sh ${var.nixos_system} ${var.target_user} ${var.target_host} ${var.target_port} ${var.ignore_systemd_errors}"
9+
command = "${path.module}/deploy.sh ${var.nixos_system} ${var.target_user} ${var.target_host} ${var.target_port} ${var.ignore_systemd_errors} ${var.install_bootloader}"
1010
}
1111
}

terraform/nixos-rebuild/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,9 @@ variable "ignore_systemd_errors" {
3131
description = "Ignore systemd errors happening during deploy"
3232
default = false
3333
}
34+
35+
variable "install_bootloader" {
36+
type = bool
37+
description = "Install/re-install the bootloader"
38+
default = false
39+
}

0 commit comments

Comments
 (0)