virtualisation/qemu: Respect virtualisation.diskSize with useBootLoader (#449945)

This commit is contained in:
Paul Haerle
2025-10-27 14:13:34 +01:00
committed by GitHub
+9 -3
View File
@@ -136,14 +136,20 @@ let
''
# Create a writable qcow2 image using the systemImage as a backing
# image.
BACKING_SIZE_MB=$(( $(${lib.getExe' qemu "qemu-img"} info ${systemImage}/nixos.qcow2 --output=json | ${lib.getExe hostPkgs.jq} -r '."virtual-size"') / 1024 / 1024 ))
DISK_SIZE_MB=${toString cfg.diskSize}
if (( DISK_SIZE_MB < BACKING_SIZE_MB )); then
OVERLAY_SIZE_MB=$BACKING_SIZE_MB
else
OVERLAY_SIZE_MB=$DISK_SIZE_MB
fi
# CoW prevent size to be attributed to an image.
# FIXME: raise this issue to upstream.
${qemu}/bin/qemu-img create \
-f qcow2 \
-b ${systemImage}/nixos.qcow2 \
-F qcow2 \
"$NIX_DISK_IMAGE"
"$NIX_DISK_IMAGE" \
''${OVERLAY_SIZE_MB}M
''
else if cfg.useDefaultFilesystems then
''