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