How to ssh to qemu emulated aarch64 NixOS?

I agree it looks like an odd error!

I don’t think it’s the host though; the below very similar script works fine for a recent (2022-04) Raspberry Pi OS image; with a copy of the dtb and kernel8 from the /boot partition, I’m able to use the keyboard as well as SSH into the guest without difficulty:

#!/usr/bin/env bash

# $ qemu-system-aarch64 --version
# QEMU emulator version 7.0.0
# Copyright (c) 2003-2022 Fabrice Bellard and the QEMU Project developers
 
# Working fine for Raspberry Pi OS 2022-04

set -Eeuf -o pipefail
set -x

main() {
  local img=${1:-./2022-04-04-rpios.img}
  qemu-system-aarch64 \
    -M raspi3b \
    -dtb ./rpios/bcm2710-rpi-3-b.dtb \
    -m 1G \
    -smp 4 \
    -drive "format=raw,file=${img}" \
    -kernel ./rpios/kernel8.img \
    -device usb-net,netdev=net0 \
    -netdev user,id=net0,hostfwd=tcp::2222-:22 \
    -append "console=ttyAMA0 root=/dev/mmcblk0p2 rw rootwait" \
    -nographic
}

main "$@"

I’ve tried virtually all combinations of these options I could find! None seem to work, and as noted above it seems like these work fine with an official RPi image, so I’m not sure where the issue lies.

Perhaps as you suggest I need to enable a few more kernel modules in my image?

Is there anyone that is using qemu to access an aarch64 NixOS guest?