Allocate virtualisation.diskSize with useBootLoader

This commit is contained in:
Peter Bynum
2025-10-14 10:02:27 -04:00
parent 1f296ad58a
commit da2060bdc1

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
''