nixos/qemu-vm: allow booting VM with the custom kernel

While doing kernel development with the nixos testing infrastructure, it
is useful to quickly compile the kernel on the side and boot it in the testing VM.

This patch allows overriding the kernel through the environment
variable. For example, the following:

$ NIXPKGS_QEMU_KERNEL_testvm=$LINUX_SRC/arch/x86/boot/bzImage $VM/bin/nixos-test-driver

runs testvm testing VM with the fresh kernel compiled in $LINUX_SRC.

Co-authored-by: Robert Hensing <roberth@users.noreply.github.com>
This commit is contained in:
Boris Sukholitko 2022-03-24 10:56:35 +02:00
parent 5ff499b854
commit 6af3e61632

View file

@ -854,7 +854,7 @@ in
"-device virtio-gpu-pci" "-device usb-ehci,id=usb0" "-device usb-kbd" "-device usb-tablet"
])
(mkIf (!cfg.useBootLoader) [
"-kernel ${config.system.build.toplevel}/kernel"
"-kernel \${NIXPKGS_QEMU_KERNEL_${config.system.name}:-${config.system.build.toplevel}/kernel}"
"-initrd ${config.system.build.toplevel}/initrd"
''-append "$(cat ${config.system.build.toplevel}/kernel-params) init=${config.system.build.toplevel}/init regInfo=${regInfo}/registration ${consoles} $QEMU_KERNEL_PARAMS"''
])