From e8232ab89a5a8903cd9702c180bb027a60ac2e8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20Partheym=C3=BCller?= Date: Thu, 25 Feb 2021 10:06:54 +0100 Subject: [PATCH] win: Allow for selection specific image This is useful if the install.wim contains multiple Windows versions (e.g., Home, Pro, ..), because the autounattend file will always select index 1. With this mechanism, a variant different from the first one can be automatically selected. imageSelection can be either an index (1-N) or the image name wiminfo can list all images contained in a given WIM file. The default case is index 1, which has the same effect as before, with the possibility of having a slightly smaller install.wim file because all unwanted variants are discarded. --- wfvm/win.nix | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/wfvm/win.nix b/wfvm/win.nix index 0a3193c..4cc8884 100644 --- a/wfvm/win.nix +++ b/wfvm/win.nix @@ -5,6 +5,8 @@ , impureMode ? false , installCommands ? [] , users ? {} +# autounattend always installs index 1, so this default is backward-compatible +, imageSelection ? "1" , ... }@attrs: @@ -106,10 +108,20 @@ let mkdir -p win/nix-win 7z x -y ${windowsIso} -owin - # Split image so it fits in FAT32 partition - wimsplit win/sources/install.wim win/sources/install.swm 3072 + # Extract desired variant from install.wim + # This is useful if the install.wim contains multiple Windows + # versions (e.g., Home, Pro, ..), because the autounattend file + # will always select index 1. With this mechanism, a variant different + # from the first one can be automatically selected. + # imageSelection can be either an index (1-N) or the image name + # wiminfo can list all images contained in a given WIM file + wimexport win/sources/install.wim "${imageSelection}" win/sources/install_selected.wim rm win/sources/install.wim + # Split image so it fits in FAT32 partition + wimsplit win/sources/install_selected.wim win/sources/install.swm 3072 + rm win/sources/install_selected.wim + cp ${autounattend.autounattendXML} win/autounattend.xml virt-make-fs --partition --type=fat win/ usbimage.img