make-disk-image: allow kernel to be overriden by disko configuration

This is especially useful when trying to build images for embedded systems such as the pi, which have a vendor kernel that can't be booted as part of the disko image builder process
This commit is contained in:
matthewcroughan 2024-07-03 19:53:13 +01:00
parent 0d510fe40b
commit f5cc4b55e5
2 changed files with 12 additions and 1 deletions

View file

@ -10,7 +10,7 @@ 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 ]
(with nixosConfig.config.disko.imageBuilderKernelPackages; [ kernel ]
++ lib.optional (lib.elem "zfs" nixosConfig.config.disko.extraRootModules) zfs);
};
cleanedConfig = diskoLib.testLib.prepareDiskoConfig nixosConfig.config diskoLib.testLib.devices;

View file

@ -10,6 +10,17 @@ let
in
{
options.disko = {
imageBuilderKernel = lib.mkOption {
type = lib.types.package;
imageBuilderKernelPackages = lib.mkOption {
type = lib.types.attrs;
description = ''
the kernel used when building disk images via make-disk-image.nix.
Useful when the config's kernel won't boot in the image-builder.
'';
default = config.boot.kernelPackages;
example = lib.literalExpression "pkgs.linuxPackages_testing";
};
extraRootModules = lib.mkOption {
type = lib.types.listOf lib.types.str;
description = ''