Skip to content

Commit 2abd3fe

Browse files
committed
terraform: only set SSHPASS and SSH_PRIVATE_KEY if values are not null
1 parent 0ec8f05 commit 2abd3fe

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

terraform/install/run-nixos-anywhere.sh

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,14 @@ if [[ -n ${input[flake]} ]]; then
2727
else
2828
args+=("--store-paths" "${input[nixos_partitioner]}" "${input[nixos_system]}")
2929
fi
30-
if [[ -n ${SSHPASS-} ]]; then
30+
args+=(--phases "${input[phases]}")
31+
if [[ ${input[ssh_private_key]} != null ]]; then
32+
export SSH_PRIVATE_KEY="${input[ssh_private_key]}"
33+
fi
34+
if [[ ${input[target_pass]} != null ]]; then
35+
export SSHPASS=${input[target_pass]}
3136
args+=("--env-password")
3237
fi
33-
args+=(--phases "${input[phases]}")
3438

3539
tmpdir=$(mktemp -d)
3640
cleanup() {
@@ -76,4 +80,4 @@ while [[ $# -gt 0 ]]; do
7680
keyIdx=$((keyIdx + 1))
7781
done
7882

79-
SSHPASS=${input[target_pass]} SSH_PRIVATE_KEY="${input[ssh_private_key]}" nix run --extra-experimental-features 'nix-command flakes' "path:${SCRIPT_DIR}/../..#nixos-anywhere" -- "${args[@]}"
83+
nix run --extra-experimental-features 'nix-command flakes' "path:${SCRIPT_DIR}/../..#nixos-anywhere" -- "${args[@]}"

0 commit comments

Comments
 (0)