From 6af3e61632c651db2dc1fe55ae48460006eda0ad Mon Sep 17 00:00:00 2001 From: Boris Sukholitko Date: Thu, 24 Mar 2022 10:56:35 +0200 Subject: [PATCH] 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 --- nixos/modules/virtualisation/qemu-vm.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nixos/modules/virtualisation/qemu-vm.nix b/nixos/modules/virtualisation/qemu-vm.nix index 514389358947..653bdc8f3016 100644 --- a/nixos/modules/virtualisation/qemu-vm.nix +++ b/nixos/modules/virtualisation/qemu-vm.nix @@ -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"'' ])