From 1453037212790d7f3c91fbc36bd6e37f915d8754 Mon Sep 17 00:00:00 2001 From: turtlebasket Date: Sun, 1 Oct 2023 08:43:11 -0700 Subject: [PATCH] add nixhost vm scripts --- .gitignore | 4 ++++ thonkpad/nixhost/grun.sh | 11 +++++++++++ thonkpad/nixhost/run.sh | 11 +++++++++++ thonkpad/nixhost/setup.sh | 26 ++++++++++++++++++++++++++ 4 files changed, 52 insertions(+) create mode 100755 thonkpad/nixhost/grun.sh create mode 100755 thonkpad/nixhost/run.sh create mode 100755 thonkpad/nixhost/setup.sh diff --git a/.gitignore b/.gitignore index ec6ca16..9f6b4cf 100644 --- a/.gitignore +++ b/.gitignore @@ -91,3 +91,7 @@ Temporary Items *.tar.gz *.tar.gz.enc *.tar.gz.age + +# OS images & QEMU drives +*.iso +*.qcow2 diff --git a/thonkpad/nixhost/grun.sh b/thonkpad/nixhost/grun.sh new file mode 100755 index 0000000..7e8bd69 --- /dev/null +++ b/thonkpad/nixhost/grun.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +# Graphical runner for desktop + +ISO=nixos +DRIVENAME=nixhost +MEM_GB=1 + +qemu-system-x86_64 -enable-kvm \ + -m $(expr 1024 \* $MEM_GB) -drive file=./$DRIVENAME.qcow2,format=qcow2 + diff --git a/thonkpad/nixhost/run.sh b/thonkpad/nixhost/run.sh new file mode 100755 index 0000000..7e321a3 --- /dev/null +++ b/thonkpad/nixhost/run.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +ISO=nixos +DRIVENAME=nixhost +MEM_GB=1 +SSH_PORT=2022 + +qemu-system-x86_64 -enable-kvm -nographic -vga none \ + -net user,hostfwd=tcp::2022-:22 -net nic \ + -m $(expr 1024 \* $MEM_GB) -drive file=./$DRIVENAME.qcow2,format=qcow2 + diff --git a/thonkpad/nixhost/setup.sh b/thonkpad/nixhost/setup.sh new file mode 100755 index 0000000..ae04191 --- /dev/null +++ b/thonkpad/nixhost/setup.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +ISO=nixos +DRIVENAME=nixhost +DRIVE_GB=50 +MEM_GB=1 + +if [ -f $ISO.iso ]; then + echo "Found $ISO.iso" +else + wget -O $ISO.iso https://channels.nixos.org/nixos-23.05/latest-nixos-minimal-x86_64-linux.iso +fi + +if [ -f $DRIVENAME.qcow2 ]; then + echo "Found $DRIVENAME.qcow2." +else + qemu-img create -f qcow2 $DRIVENAME.qcow2 ${DRIVE_GB}G +fi + +# try headless-esque flags: +# -display curses +# -nographic + +qemu-system-x86_64 -enable-kvm -display curses -nographic -cdrom $ISO.iso \ + -m $(expr 1024 \* $MEM_GB) -drive file=./$DRIVENAME.qcow2,format=qcow2 +