@@ -43,6 +43,10 @@ abort() {
43
43
exit 1
44
44
}
45
45
46
+ step () {
47
+ echo " ### $* ###"
48
+ }
49
+
46
50
default_kexec_url=https://github.com/nix-community/nixos-images/releases/download/nixos-22.11/nixos-kexec-installer-noninteractive-x86_64-linux.tar.gz
47
51
kexec_url=" $default_kexec_url "
48
52
enable_debug=" "
@@ -206,6 +210,7 @@ if [[ -n ${SSH_PRIVATE_KEY-} ]]; then
206
210
ssh_copy_id_args+=(-f)
207
211
fi
208
212
213
+ step Uploading install SSH keys
209
214
until
210
215
ssh-copy-id \
211
216
-i " $ssh_key_dir " /nixos-anywhere.pub \
252
257
export $( echo " $filtered_facts " | xargs)
253
258
}
254
259
260
+ step Gathering machine facts
255
261
import_facts
256
262
257
263
if [[ ${has_tar-n} == " n" ]]; then
@@ -276,6 +282,7 @@ if [[ ${is_arch-n} != "x86_64" ]] && [[ $kexec_url == "$default_kexec_url" ]]; t
276
282
fi
277
283
278
284
if [[ ${is_kexec-n} == " n" ]] && [[ ${is_installer-n} == " n" ]]; then
285
+ step Switching system into kexec
279
286
ssh_ << SSH
280
287
set -efu ${enable_debug}
281
288
$maybe_sudo rm -rf /root/kexec
@@ -306,18 +313,20 @@ SSH
306
313
until ssh_ -o ConnectTimeout=10 -- exit 0; do sleep 5; done
307
314
fi
308
315
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 "
310
317
ssh_ " umask 077; cat > $path " < " ${disk_encryption_keys[$path]} "
311
318
done
312
319
313
320
pubkey=$( ssh-keyscan -t ed25519 " ${ssh_connection//*@/ } " 2> /dev/null | sed -e ' s/^[^ ]* //' | base64 -w0)
314
321
315
322
if [[ -z ${disko_script-} ]] && [[ ${build_on_remote-n} == " y" ]]; then
323
+ step Building disko script
316
324
disko_script=$(
317
325
nix_build " ${flake} #nixosConfigurations.\" ${flakeAttr} \" .config.system.build.disko" \
318
326
--builders " ssh://$ssh_connection ?base64-ssh-public-host-key=$pubkey &ssh-key=$ssh_key_dir /nixos-anywhere $is_arch -linux"
319
327
)
320
328
fi
329
+ step Formatting hard drive with disko
321
330
nix_copy --to " ssh://$ssh_connection " " $disko_script "
322
331
ssh_ " $disko_script "
323
332
@@ -329,20 +338,24 @@ if [[ ${stop_after_disko-n} == "y" ]]; then
329
338
fi
330
339
331
340
if [[ -z ${nixos_system-} ]] && [[ ${build_on_remote-n} == " y" ]]; then
341
+ step Building the system closure
332
342
nixos_system=$(
333
343
nix_build " ${flake} #nixosConfigurations.\" ${flakeAttr} \" .config.system.build.toplevel" \
334
344
--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"
335
345
)
336
346
fi
347
+ step Uploading the system closure
337
348
nix_copy --to " ssh://$ssh_connection ?remote-store=local?root=/mnt" " $nixos_system "
338
349
339
350
if [[ -n ${extra_files-} ]]; then
340
351
if [[ -d $extra_files ]]; then
341
352
extra_files=" $extra_files /"
342
353
fi
354
+ step Copying extra files
343
355
rsync -rlpv -FF -e " ssh -i \" $ssh_key_dir \" /nixos-anywhere -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no" " $extra_files " " ${ssh_connection} :/mnt/"
344
356
fi
345
357
358
+ step Installing NixOS
346
359
ssh_ << SSH
347
360
set -efu ${enable_debug}
348
361
# needed for installation if initrd-secrets are used
@@ -354,7 +367,9 @@ nixos-install --no-root-passwd --no-channel-copy --system "$nixos_system"
354
367
nohup bash -c '${maybe_reboot} ' >/dev/null &
355
368
SSH
356
369
357
- # wait for machine to become unreachable due to reboot
358
370
if [[ -n ${maybe_reboot} ]]; then
371
+ step Waiting for the maching to become reachable again
359
372
while timeout_ssh_ -- exit 0; do sleep 1; done
360
373
fi
374
+
375
+ step " Done!"
0 commit comments