From f7f1a99e89b0a629f64c9074babf3a3f91dd1dba Mon Sep 17 00:00:00 2001 From: mozempk Date: Thu, 23 Apr 2026 14:16:59 +0200 Subject: [PATCH] feat: add live-qemu target with 12GB RAM for nix package headroom MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Live session is a pure-RAM tmpfs overlay. Cinnamon takes ~2.5GB, nix packages take ~4GB — 6GB QEMU was too tight. 12GB gives comfortable headroom. Real XPS 9700 (32GB) already works fine. - tests/launch-live-qemu.sh: dedicated QEMU launcher, RAM_MB=12288 - Makefile: 'make live-qemu' target --- Makefile | 7 ++++- tests/launch-live-qemu.sh | 59 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+), 1 deletion(-) create mode 100755 tests/launch-live-qemu.sh diff --git a/Makefile b/Makefile index 38e7369..a68811f 100644 --- a/Makefile +++ b/Makefile @@ -15,7 +15,7 @@ PROJECT_DIR := $(CURDIR) OUT := $(PROJECT_DIR)/out SECRETS := $(PROJECT_DIR)/secrets.env -.PHONY: all iso live test test-disk test-iso qemu shellcheck clean distclean check-secrets check-docker +.PHONY: all iso live live-qemu test test-disk test-iso qemu shellcheck clean distclean check-secrets check-docker all: iso @@ -32,6 +32,11 @@ iso: check-secrets check-docker live: check-secrets check-docker $(PROJECT_DIR)/iso/build-live-iso.sh +# Launch the live ISO in QEMU with 12 GB RAM so nix packages fit in the tmpfs. +# The live session is a pure-RAM tmpfs overlay; Cinnamon + nix need ~7-8 GB total. +live-qemu: + $(PROJECT_DIR)/tests/launch-live-qemu.sh + test-iso: check-secrets check-docker REBUILD_ISO=1 $(PROJECT_DIR)/tests/run-qemu-test.sh diff --git a/tests/launch-live-qemu.sh b/tests/launch-live-qemu.sh new file mode 100755 index 0000000..b8c330c --- /dev/null +++ b/tests/launch-live-qemu.sh @@ -0,0 +1,59 @@ +#!/bin/bash +# Launch the live desktop ISO under QEMU for interactive testing. +# Uses 12 GB RAM so nix packages (~4 GB) can install into the tmpfs overlay. +# +# Usage: +# bash tests/launch-live-qemu.sh # uses out/void-live-stable.iso +# ISO=out/my.iso bash tests/launch-live-qemu.sh +# RAM_MB=16384 bash tests/launch-live-qemu.sh # override RAM + +set -Eeuo pipefail + +PROJECT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" +OUT_DIR="$PROJECT_DIR/out" + +ISO="${ISO:-$(ls -t "$OUT_DIR"/void-live-stable*.iso 2>/dev/null | head -1 || true)}" +[[ -r "$ISO" ]] || { echo "no ISO found — run 'make live' first"; exit 1; } + +RAM_MB="${RAM_MB:-12288}" # 12 GB: Cinnamon ~2.5GB + nix store ~4GB + headroom +SMP="${SMP:-4}" + +OVMF_CODE="${OVMF_CODE:-}" +OVMF_VARS_TPL="${OVMF_VARS_TPL:-}" +for c in /usr/share/OVMF/OVMF_CODE.fd /usr/share/edk2-ovmf/x64/OVMF_CODE.fd \ + /usr/share/edk2/x64/OVMF_CODE.fd /usr/share/qemu/OVMF_CODE.fd; do + [[ -z "$OVMF_CODE" && -r "$c" ]] && OVMF_CODE="$c" +done +for v in /usr/share/OVMF/OVMF_VARS.fd /usr/share/edk2-ovmf/x64/OVMF_VARS.fd \ + /usr/share/edk2/x64/OVMF_VARS.fd /usr/share/qemu/OVMF_VARS.fd; do + [[ -z "$OVMF_VARS_TPL" && -r "$v" ]] && OVMF_VARS_TPL="$v" +done +[[ -r "$OVMF_CODE" ]] || { echo "OVMF_CODE not found — install ovmf"; exit 1; } +[[ -r "$OVMF_VARS_TPL" ]] || { echo "OVMF_VARS not found — install ovmf"; exit 1; } + +VARS="$OUT_DIR/OVMF_VARS.live.fd" +[[ -f "$VARS" ]] || cp "$OVMF_VARS_TPL" "$VARS" + +mkdir -p "$OUT_DIR" + +echo ">>> launching live ISO: $ISO" +echo " RAM: ${RAM_MB} MB CPUs: $SMP" +echo " serial: $OUT_DIR/live-serial.sock" +echo " monitor: $OUT_DIR/qemu-monitor.sock" + +exec qemu-system-x86_64 \ + -name void-live-test \ + -machine q35,accel=kvm:tcg \ + -cpu max \ + -m "$RAM_MB" \ + -smp "$SMP" \ + -drive "if=pflash,format=raw,readonly=on,file=$OVMF_CODE" \ + -drive "if=pflash,format=raw,file=$VARS" \ + -cdrom "$ISO" \ + -boot order=d,menu=off \ + -netdev user,id=n0 \ + -device virtio-net-pci,netdev=n0 \ + -serial "unix:$OUT_DIR/live-serial.sock,server,nowait" \ + -monitor "unix:$OUT_DIR/qemu-monitor.sock,server,nowait" \ + -device virtio-vga \ + -display gtk,gl=off