Merge pull request #698 from MatthewCroughan/mc/make-builder-kernel-configurable

make-disk-image: make pkgs, qemu and kernelPackages configurable and overridable
This commit is contained in:
lassulus 2024-08-14 23:08:31 +02:00 committed by GitHub
commit f1e929d121
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 31 additions and 2 deletions

View file

@ -1,6 +1,6 @@
{ nixosConfig
, diskoLib
, pkgs ? nixosConfig.pkgs
, pkgs ? nixosConfig.config.disko.imageBuilderPkgs
, lib ? pkgs.lib
, name ? "${nixosConfig.config.networking.hostName}-disko-images"
, extraPostVM ? nixosConfig.config.disko.extraPostVM
@ -9,8 +9,9 @@
let
vmTools = pkgs.vmTools.override {
rootModules = [ "9p" "9pnet_virtio" "virtio_pci" "virtio_blk" ] ++ nixosConfig.config.disko.extraRootModules;
customQemu = nixosConfig.config.disko.imageBuilderQemu;
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,34 @@ let
in
{
options.disko = {
imageBuilderQemu = lib.mkOption {
type = lib.types.nullOr lib.types.str;
description = ''
the qemu emulator string used when building disk images via make-disk-image.nix.
Useful when using binfmt on your build host, and wanting to build disk
images for a foreign architecture
'';
default = null;
example = lib.literalExpression "''${pkgs.qemu_kvm}/bin/qemu-system-aarch64";
};
imageBuilderPkgs = lib.mkOption {
type = lib.types.attrs;
description = ''
the pkgs instance used when building disk images via make-disk-image.nix.
Useful when the config's kernel won't boot in the image-builder.
'';
default = pkgs;
example = lib.literalExpression "pkgs";
};
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 = ''