make-disk-image: add --build-memory

This commit is contained in:
Janik H 2023-09-24 01:17:16 +02:00 committed by Jörg Thalheim
parent da38eb67aa
commit b6fb19891f

View File

@ -83,6 +83,10 @@ in
copies the src to the dst on the finished image
These end up in the images later and is useful if you want to add some extra stateful files
They will have the same permissions but will be owned by root:root
* --build-memory <amt>
specify the ammount of memory that gets allocated to the build vm (in mb)
This can be usefull if you want to build images with a more involed NixOS config
By default the vm will get 1024M/1GB
USAGE
}
@ -107,6 +111,15 @@ in
cp --reflink=auto -r "$src" copy_after_disko/"$(echo "$dst" | base64)"
shift 2
;;
--build-memory)
regex="^[0-9]+$"
if ! [[ $2 =~ $regex ]]; then
echo "'$2' is not a number"
exit 1
fi
build_memory=$2
shift 1
;;
*)
showUsage
exit 1
@ -141,7 +154,12 @@ in
done
${installer}
''}
export QEMU_OPTS=${lib.escapeShellArg "${QEMU_OPTS} -m 1024"}
build_memory=''${build_memory:-1024}
QEMU_OPTS=${lib.escapeShellArg QEMU_OPTS}
QEMU_OPTS+=" -m $build_memory"
export QEMU_OPTS
${pkgs.bash}/bin/sh -e ${pkgs.vmTools.vmRunCommand pkgs.vmTools.qemuCommandLinux}
cd /
'';