nix

configuration files that power my machines
Log | Files | Refs | README | LICENSE

commit ab8bed488096fb7e2a2eb937f1bb5ef669cbfb28
parent d33aad9a815e8f381fa4e45ab577f10806e8a9f6
Author: mtmn <miro@haravara.org>
Date:   Sun, 26 Apr 2026 22:42:22 +0200

void: add 9front qemu helper

Diffstat:
Mhosts/void/overlays/config/shell/rc/void | 0
Amodules/mixins/dotfiles/bin/q9 | 108+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 108 insertions(+), 0 deletions(-)

diff --git a/hosts/void/overlays/config/shell/rc/void b/hosts/void/overlays/config/shell/rc/void Binary files differ. diff --git a/modules/mixins/dotfiles/bin/q9 b/modules/mixins/dotfiles/bin/q9 @@ -0,0 +1,108 @@ +#!/usr/bin/env bash +set -euo pipefail + +DISK="$HOME/misc/random/9front.qcow2" +DISK_SIZE="5G" +RAM="1024" +ISO_PATTERN="$HOME/misc/random/9front-*.iso" + +QEMU_COMMON=( + -m "$RAM" + -hda "$DISK" + -vga std + -net nic + -net user +) + +if [[ "$(uname)" == "Linux" ]] && [[ -e /dev/kvm ]]; then + QEMU_COMMON+=(-enable-kvm) +fi + +cmd_help() { + cat <<EOF +Usage: $(basename "$0") <command> + +Commands: + download Download the latest 9front image + install Boot from ISO to install + run Boot the installed system + help Show this message +EOF +} + +cmd_download() { + if compgen -G "$ISO_PATTERN" >/dev/null 2>&1; then + echo "ISO already present: $(compgen -G "$ISO_PATTERN" | head -1)" + return + fi + + DOWNLOAD_DIR="$(dirname "$DISK")" + mkdir -p "$DOWNLOAD_DIR" + + BASE_URL="https://9front.org/iso" + # Scrape the index page for the latest amd64 .iso.gz link + GZ_FILE=$(curl -s "$BASE_URL/" | + grep -oE '9front-[0-9]+\.amd64\.iso\.gz' | + sort -t- -k2 -rn | + head -1) + + if [[ -z "$GZ_FILE" ]]; then + echo "Could not find ISO. Check $BASE_URL manually." + exit 1 + fi + + TORRENT_URL="$BASE_URL/$GZ_FILE.torrent" + + echo "Downloading via torrent: $TORRENT_URL" + if command -v aria2c &>/dev/null; then + aria2c --seed-time=0 --dir="$DOWNLOAD_DIR" "$TORRENT_URL" + else + comma aria2c --seed-time=0 --dir="$DOWNLOAD_DIR" "$TORRENT_URL" + fi + + echo "Decompressing $GZ_FILE" + gunzip "$DOWNLOAD_DIR/$GZ_FILE" + echo "Done: $(compgen -G "$ISO_PATTERN")" +} + +cmd_install() { + ISO=$(compgen -G "$ISO_PATTERN" 2>/dev/null | head -1) || true + if [[ -z "$ISO" ]]; then + echo "No ISO found. Run: $0 download" + exit 1 + fi + + if [[ ! -f "$DISK" ]]; then + echo "Creating disk image $DISK ($DISK_SIZE)" + if command -v qemu-img &>/dev/null; then + qemu-img create -f qcow2 "$DISK" "$DISK_SIZE" + else + comma qemu-img create -f qcow2 "$DISK" "$DISK_SIZE" + fi + fi + + echo "Booting installer from $ISO" + echo "At the installer prompt run: inst/start" + echo "" + qemu-system-x86_64 \ + "${QEMU_COMMON[@]}" \ + -cdrom "$ISO" \ + -boot d +} + +cmd_run() { + if [[ ! -f "$DISK" ]]; then + echo "Disk image not found. Run: $0 install" + exit 1 + fi + + echo "Booting $DISK" + qemu-system-x86_64 "${QEMU_COMMON[@]}" +} + +case "${1:-help}" in +download) cmd_download ;; +install) cmd_install ;; +run) cmd_run ;; +help | *) cmd_help ;; +esac