diff --git a/lib/make-disk-image.nix b/lib/make-disk-image.nix index a61e937..c03676e 100644 --- a/lib/make-disk-image.nix +++ b/lib/make-disk-image.nix @@ -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; diff --git a/module.nix b/module.nix index 8c8fbc3..d58f6ef 100644 --- a/module.nix +++ b/module.nix @@ -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 = ''