Skip to content

Commit c196258

Browse files
bors[bot]zimbatm
andauthored
Merge #100
100: print the various steps r=zimbatm a=zimbatm Co-authored-by: zimbatm <zimbatm@zimbatm.com>
2 parents cfd9d36 + 0997908 commit c196258

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

src/nixos-anywhere.sh

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ abort() {
4343
exit 1
4444
}
4545

46+
step() {
47+
echo "### $* ###"
48+
}
49+
4650
default_kexec_url=https://github.com/nix-community/nixos-images/releases/download/nixos-22.11/nixos-kexec-installer-noninteractive-x86_64-linux.tar.gz
4751
kexec_url="$default_kexec_url"
4852
enable_debug=""
@@ -206,6 +210,7 @@ if [[ -n ${SSH_PRIVATE_KEY-} ]]; then
206210
ssh_copy_id_args+=(-f)
207211
fi
208212

213+
step Uploading install SSH keys
209214
until
210215
ssh-copy-id \
211216
-i "$ssh_key_dir"/nixos-anywhere.pub \
@@ -252,6 +257,7 @@ SSH
252257
export $(echo "$filtered_facts" | xargs)
253258
}
254259

260+
step Gathering machine facts
255261
import_facts
256262

257263
if [[ ${has_tar-n} == "n" ]]; then
@@ -276,6 +282,7 @@ if [[ ${is_arch-n} != "x86_64" ]] && [[ $kexec_url == "$default_kexec_url" ]]; t
276282
fi
277283

278284
if [[ ${is_kexec-n} == "n" ]] && [[ ${is_installer-n} == "n" ]]; then
285+
step Switching system into kexec
279286
ssh_ <<SSH
280287
set -efu ${enable_debug}
281288
$maybe_sudo rm -rf /root/kexec
@@ -306,18 +313,20 @@ SSH
306313
until ssh_ -o ConnectTimeout=10 -- exit 0; do sleep 5; done
307314
fi
308315
for path in "${!disk_encryption_keys[@]}"; do
309-
echo "Uploading ${disk_encryption_keys[$path]} to $path"
316+
step "Uploading ${disk_encryption_keys[$path]} to $path"
310317
ssh_ "umask 077; cat > $path" <"${disk_encryption_keys[$path]}"
311318
done
312319

313320
pubkey=$(ssh-keyscan -t ed25519 "${ssh_connection//*@/}" 2>/dev/null | sed -e 's/^[^ ]* //' | base64 -w0)
314321

315322
if [[ -z ${disko_script-} ]] && [[ ${build_on_remote-n} == "y" ]]; then
323+
step Building disko script
316324
disko_script=$(
317325
nix_build "${flake}#nixosConfigurations.\"${flakeAttr}\".config.system.build.disko" \
318326
--builders "ssh://$ssh_connection?base64-ssh-public-host-key=$pubkey&ssh-key=$ssh_key_dir/nixos-anywhere $is_arch-linux"
319327
)
320328
fi
329+
step Formatting hard drive with disko
321330
nix_copy --to "ssh://$ssh_connection" "$disko_script"
322331
ssh_ "$disko_script"
323332

@@ -329,20 +338,24 @@ if [[ ${stop_after_disko-n} == "y" ]]; then
329338
fi
330339

331340
if [[ -z ${nixos_system-} ]] && [[ ${build_on_remote-n} == "y" ]]; then
341+
step Building the system closure
332342
nixos_system=$(
333343
nix_build "${flake}#nixosConfigurations.\"${flakeAttr}\".config.system.build.toplevel" \
334344
--builders "ssh://$ssh_connection?remote-store=local?root=/mnt&base64-ssh-public-host-key=$pubkey&ssh-key=$ssh_key_dir/nixos-anywhere $is_arch-linux"
335345
)
336346
fi
347+
step Uploading the system closure
337348
nix_copy --to "ssh://$ssh_connection?remote-store=local?root=/mnt" "$nixos_system"
338349

339350
if [[ -n ${extra_files-} ]]; then
340351
if [[ -d $extra_files ]]; then
341352
extra_files="$extra_files/"
342353
fi
354+
step Copying extra files
343355
rsync -rlpv -FF -e "ssh -i \"$ssh_key_dir\"/nixos-anywhere -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no" "$extra_files" "${ssh_connection}:/mnt/"
344356
fi
345357

358+
step Installing NixOS
346359
ssh_ <<SSH
347360
set -efu ${enable_debug}
348361
# needed for installation if initrd-secrets are used
@@ -354,7 +367,9 @@ nixos-install --no-root-passwd --no-channel-copy --system "$nixos_system"
354367
nohup bash -c '${maybe_reboot}' >/dev/null &
355368
SSH
356369

357-
# wait for machine to become unreachable due to reboot
358370
if [[ -n ${maybe_reboot} ]]; then
371+
step Waiting for the maching to become reachable again
359372
while timeout_ssh_ -- exit 0; do sleep 1; done
360373
fi
374+
375+
step "Done!"

0 commit comments

Comments
 (0)