@@ -29,6 +29,8 @@ Options:
29
29
use another kexec tarball to bootstrap NixOS
30
30
* --post-kexec-ssh-port <ssh_port>
31
31
after kexec is executed, use a custom ssh port to connect. Defaults to 22
32
+ * --copy-host-keys
33
+ copy over existing /etc/ssh/ssh_host_* host keys to the installation
32
34
* --stop-after-disko
33
35
exit after disko formatting, you can then proceed to install manually or some other way
34
36
* --extra-files <file...>
@@ -119,6 +121,10 @@ while [[ $# -gt 0 ]]; do
119
121
post_kexec_ssh_port=$2
120
122
shift
121
123
;;
124
+ --copy-host-keys)
125
+ copy_host_keys=y
126
+ shift
127
+ ;;
122
128
--debug)
123
129
enable_debug=" -x"
124
130
print_build_logs=y
450
456
451
457
step Installing NixOS
452
458
ssh_ bash << SSH
453
- set -efu ${enable_debug}
459
+ set -eu ${enable_debug}
454
460
# when running not in nixos we might miss this directory, but it's needed in the nixos chroot during installation
455
- export PATH=\$ PATH:/run/current-system/sw/bin
461
+ export PATH=" \$ PATH:/run/current-system/sw/bin"
456
462
457
463
# needed for installation if initrd-secrets are used
458
464
mkdir -p /mnt/tmp
459
465
chmod 777 /mnt/tmp
466
+ if [[ ${copy_host_keys-n} == "y" ]]; then
467
+ # NB we copy host keys that are in turn copied by kexec installer.
468
+ mkdir -m 755 -p /mnt/etc/ssh
469
+ for p in /etc/ssh/ssh_host_*; do
470
+ # Skip if the source file does not exist (i.e. glob did not match any files)
471
+ # or the destination already exists (e.g. copied with --extra-files).
472
+ if [ ! -e "\$ p" -o -e "/mnt/\$ p" ]; then
473
+ continue
474
+ end
475
+ cp -a "\$ p" "/mnt/\$ p"
476
+ done
477
+ fi
460
478
nixos-install --no-root-passwd --no-channel-copy --system "$nixos_system "
461
479
if command -v zpool >/dev/null; then
462
480
zpool export -a || : # we always want to export the zfs pools so people can boot from it without force import
0 commit comments