Merge pull request #851 from nix-community/fix-eval-error-unexpected-argument-customQemu

disk-image: Fix "unexpected argument 'customQemu'" eval error
This commit is contained in:
Paul Haerle authored and GitHub committed 2024-10-28 15:17:58 +01:00
commit 3163b2724c
3 files changed
+45 -18

No files matched your search

+15 -6
View File
@@ -105,12 +105,13 @@ let
hexEscapeUdevSymlink "all0these@char#acters+_are-allow.ed" hexEscapeUdevSymlink "all0these@char#acters+_are-allow.ed"
=> "all0these@char#acters+_are-allow.ed" => "all0these@char#acters+_are-allow.ed"
*/ */
hexEscapeUdevSymlink = let hexEscapeUdevSymlink =
allowedChars = "[0-9A-Za-z#+-.:=@_/]"; let
charToHex = c: lib.toHexString (lib.strings.charToInt c); allowedChars = "[0-9A-Za-z#+-.:=@_/]";
in charToHex = c: lib.toHexString (lib.strings.charToInt c);
lib.stringAsChars in
(c: if lib.match allowedChars c != null || c == "" then c else "\\x" + charToHex c); lib.stringAsChars
(c: if lib.match allowedChars c != null || c == "" then c else "\\x" + charToHex c);
/* get the index an item in a list /* get the index an item in a list
@@ -334,6 +335,14 @@ let
*/ */
packages = toplevel: toplevel._packages; packages = toplevel: toplevel._packages;
/* Checks whether nixpkgs is recent enough for vmTools to support the customQemu argument.
Returns false, which is technically incorrect, for a few commits on 2024-07-08, but we can't be more accurate.
vmToolsSupportsCustomQemu :: pkgs -> bool
*/
vmToolsSupportsCustomQemu = pkgs: lib.versionAtLeast pkgs.lib.version "24.11.20240709";
optionTypes = rec { optionTypes = rec {
filename = lib.mkOptionType { filename = lib.mkOptionType {
name = "filename"; name = "filename";
+13 -9
View File
@@ -12,15 +12,19 @@ let
checked = diskoCfg.checkScripts; checked = diskoCfg.checkScripts;
configSupportsZfs = config.boot.supportedFilesystems.zfs or false; configSupportsZfs = config.boot.supportedFilesystems.zfs or false;
vmTools = pkgs.vmTools.override { vmTools = pkgs.vmTools.override
rootModules = [ "9p" "9pnet_virtio" "virtio_pci" "virtio_blk" ] {
++ (lib.optional configSupportsZfs "zfs") rootModules = [ "9p" "9pnet_virtio" "virtio_pci" "virtio_blk" ]
++ cfg.extraRootModules; ++ (lib.optional configSupportsZfs "zfs")
customQemu = cfg.qemu; ++ cfg.extraRootModules;
kernel = pkgs.aggregateModules kernel = pkgs.aggregateModules
(with cfg.kernelPackages; [ kernel ] (with cfg.kernelPackages; [ kernel ]
++ lib.optional (lib.elem "zfs" cfg.extraRootModules || configSupportsZfs) zfs); ++ lib.optional (lib.elem "zfs" cfg.extraRootModules || configSupportsZfs) zfs);
}; }
// lib.optionalAttrs (diskoLib.vmToolsSupportsCustomQemu pkgs)
{
customQemu = cfg.qemu;
};
cleanedConfig = diskoLib.testLib.prepareDiskoConfig config diskoLib.testLib.devices; cleanedConfig = diskoLib.testLib.prepareDiskoConfig config diskoLib.testLib.devices;
systemToInstall = extendModules { systemToInstall = extendModules {
modules = [ modules = [
+17 -3
View File
@@ -194,6 +194,17 @@ in
}; };
config = { config = {
assertions = [
{
assertion = config.disko.imageBuilder.qemu != null -> diskoLib.vmToolsSupportsCustomQemu pkgs;
message = ''
You have set config.disko.imageBuild.qemu, but vmTools in your nixpkgs version "${lib.version}"
does not support overriding the qemu package with the customQemu option yet.
Please upgrade nixpkgs so that `lib.version` is at least "24.11.20240709".
'';
}
];
_module.args.diskoLib = import ./lib { _module.args.diskoLib = import ./lib {
inherit lib; inherit lib;
rootMountPoint = config.disko.rootMountPoint; rootMountPoint = config.disko.rootMountPoint;
@@ -226,8 +237,11 @@ in
# we need to specify the keys here, so we don't get an infinite recursion error # we need to specify the keys here, so we don't get an infinite recursion error
# Remember to add config keys here if they are added to types # Remember to add config keys here if they are added to types
fileSystems = lib.mkIf cfg.enableConfig cfg.devices._config.fileSystems or { }; fileSystems = lib.mkIf
boot = lib.mkIf cfg.enableConfig cfg.devices._config.boot or { }; cfg.enableConfig cfg.devices._config.fileSystems or { };
swapDevices = lib.mkIf cfg.enableConfig cfg.devices._config.swapDevices or [ ]; boot = lib.mkIf
cfg.enableConfig cfg.devices._config.boot or { };
swapDevices = lib.mkIf
cfg.enableConfig cfg.devices._config.swapDevices or [ ];
}; };
} }