From b6fb19891f65506b973964c2387bdde32a3faea0 Mon Sep 17 00:00:00 2001 From: Janik H Date: Sun, 24 Sep 2023 01:17:16 +0200 Subject: [PATCH] make-disk-image: add --build-memory --- lib/make-disk-image.nix | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/lib/make-disk-image.nix b/lib/make-disk-image.nix index d2e9df6..1699079 100644 --- a/lib/make-disk-image.nix +++ b/lib/make-disk-image.nix @@ -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 + 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 / '';