make-disk-image: inherit kernel from nixosConfiguration

This commit is contained in:
matthewcroughan 2023-12-14 12:01:52 +00:00 committed by mergify[bot]
parent d5cf2e3d61
commit bb75ad0b1d
2 changed files with 14 additions and 2 deletions

View file

@ -7,6 +7,11 @@
, checked ? false
}:
let
vmTools = pkgs.vmTools.override {
rootModules = ["9p" "9pnet_virtio" "virtio_pci" "virtio_blk"] ++ nixosConfig.config.disko.extraRootModules;
kernel = pkgs.aggregateModules
(with nixosConfig.config.boot.kernelPackages; [ kernel ]);
};
cleanedConfig = diskoLib.testLib.prepareDiskoConfig nixosConfig.config diskoLib.testLib.devices;
systemToInstall = nixosConfig.extendModules {
modules = [{
@ -61,7 +66,7 @@ let
QEMU_OPTS = lib.concatMapStringsSep " " (disk: "-drive file=${disk.name}.raw,if=virtio,cache=unsafe,werror=report") (lib.attrValues nixosConfig.config.disko.devices.disk);
in
{
pure = pkgs.vmTools.runInLinuxVM (pkgs.runCommand name
pure = vmTools.runInLinuxVM (pkgs.runCommand name
{
buildInputs = dependencies;
inherit preVM postVM QEMU_OPTS;
@ -160,7 +165,7 @@ in
QEMU_OPTS+=" -m $build_memory"
export QEMU_OPTS
${pkgs.bash}/bin/sh -e ${pkgs.vmTools.vmRunCommand pkgs.vmTools.qemuCommandLinux}
${pkgs.bash}/bin/sh -e ${vmTools.vmRunCommand vmTools.qemuCommandLinux}
cd /
'';
}

View file

@ -10,6 +10,13 @@ let
in
{
options.disko = {
extraRootModules = lib.mkOption {
type = lib.types.listOf lib.types.str ;
description = ''
extra modules to pass to the vmTools.runCommand invocation in the make-disk-image.nix builder
'';
default = [];
};
memSize = lib.mkOption {
type = lib.types.int;
description = ''