The solution is to add extra initrd udev rules:
nix-build --out-link /tmp/vm - <<'EOF'
(import <nixpkgs/nixos> {
configuration = { lib, pkgs, ... }: with lib; {
boot.initrd = {
extraUdevRulesCommands = ''
cp -v ${pkgs.systemd}/lib/udev/rules.d/75-net-description.rules $out
cp -v ${pkgs.path}/nixos/modules/services/hardware/80-net-setup-link.rules $out
'';
preLVMCommands = ''
echo
echo "Yeah, predictable names:"
ls -l /sys/class/net
# Pause stage 1
read
'';
};
};
}).vm
EOF
# Run VM attached to console. To quit, press (Ctrl + A), c, q, <enter>
NIX_DISK_IMAGE=/tmp/vmimg /tmp/vm/bin/run-*-vm -m 1024 -smp 2 -nographic -append 'console=ttyS0'