Switch to qcow2 in the interactive VM.

This commit is contained in:
zerox committed 2024-08-31 09:57:41 +05:00
1 parent 511388d837
commit 70a22d25a2
3 files changed
+8 -6

No files matched your search

+3 -2
View File
@@ -30,6 +30,7 @@ let
disko.devices = cfg_.disko.devices; disko.devices = cfg_.disko.devices;
}; };
testMode = true; testMode = true;
imageFormat = "qcow2";
}; };
rootDisk = { rootDisk = {
name = "root"; name = "root";
@@ -79,8 +80,8 @@ in
trap 'rm -rf "$tmp"' EXIT trap 'rm -rf "$tmp"' EXIT
${lib.concatMapStringsSep "\n" (disk: '' ${lib.concatMapStringsSep "\n" (disk: ''
${pkgs.qemu}/bin/qemu-img create -f qcow2 \ ${pkgs.qemu}/bin/qemu-img create -f qcow2 \
-b ${diskoImages}/${disk.name}.raw \ -b ${diskoImages}/${disk.name}.qcow2 \
-F raw "$tmp"/${disk.name}.qcow2 -F qcow2 "$tmp"/${disk.name}.qcow2
'') disks} '') disks}
set +f set +f
${vm}/bin/run-*-vm ${vm}/bin/run-*-vm
+4 -3
View File
@@ -8,6 +8,7 @@
, copyNixStore ? true , copyNixStore ? true
, testMode ? false , testMode ? false
, extraConfig ? { } , extraConfig ? { }
, imageFormat ? "raw"
}: }:
let let
vmTools = pkgs.vmTools.override { vmTools = pkgs.vmTools.override {
@@ -39,7 +40,7 @@ let
findutils findutils
] ++ nixosConfig.config.disko.extraDependencies; ] ++ nixosConfig.config.disko.extraDependencies;
preVM = '' preVM = ''
${lib.concatMapStringsSep "\n" (disk: "truncate -s ${disk.imageSize} ${disk.name}.raw") (lib.attrValues nixosConfig.config.disko.devices.disk)} ${lib.concatMapStringsSep "\n" (disk: "${pkgs.qemu}/bin/qemu-img create -f ${imageFormat} ${disk.name}.${imageFormat} ${disk.imageSize}") (lib.attrValues nixosConfig.config.disko.devices.disk)}
# This makes disko work, when canTouchEfiVariables is set to true. # This makes disko work, when canTouchEfiVariables is set to true.
# Technically these boot entries will no be persisted this way, but # Technically these boot entries will no be persisted this way, but
# in most cases this is OK, because we can rely on the standard location for UEFI executables. # in most cases this is OK, because we can rely on the standard location for UEFI executables.
@@ -48,7 +49,7 @@ let
postVM = '' postVM = ''
# shellcheck disable=SC2154 # shellcheck disable=SC2154
mkdir -p "$out" mkdir -p "$out"
${lib.concatMapStringsSep "\n" (disk: "mv ${disk.name}.raw \"$out\"/${disk.name}.raw") (lib.attrValues nixosConfig.config.disko.devices.disk)} ${lib.concatMapStringsSep "\n" (disk: "mv ${disk.name}.${imageFormat} \"$out\"/${disk.name}.${imageFormat}") (lib.attrValues nixosConfig.config.disko.devices.disk)}
${extraPostVM} ${extraPostVM}
''; '';
@@ -96,7 +97,7 @@ let
"-drive if=pflash,format=raw,unit=1,file=efivars.fd" "-drive if=pflash,format=raw,unit=1,file=efivars.fd"
] ++ builtins.map ] ++ builtins.map
(disk: (disk:
"-drive file=${disk.name}.raw,if=virtio,cache=unsafe,werror=report,format=raw" "-drive file=${disk.name}.${imageFormat},if=virtio,cache=unsafe,werror=report,format=${imageFormat}"
) )
(lib.attrValues nixosConfig.config.disko.devices.disk)); (lib.attrValues nixosConfig.config.disko.devices.disk));
in in
+1 -1
View File
@@ -20,7 +20,7 @@
type = lib.types.strMatching "[0-9]+[KMGTP]?"; type = lib.types.strMatching "[0-9]+[KMGTP]?";
description = '' description = ''
size of the image if the makeDiskImages function from diksoLib is used. size of the image if the makeDiskImages function from diksoLib is used.
is used as an argument to truncate -s is used as an argument to "qemu-img create ..."
''; '';
default = "2G"; default = "2G";
}; };