feat: nb add epicenter-vm

This commit is contained in:
Dominik Polakovics Polakovics 2026-03-28 14:21:32 +01:00
parent c2e70e2a26
commit 3568719372

View file

@ -1,5 +1,45 @@
{ lib, pkgs, ... }:
{ lib, pkgs, ... }:
let
epicenter-vm = pkgs.writeShellScriptBin "epicenter-vm" ''
set -euo pipefail
VM_DIR="$HOME/epicenter-vm"
DISK="$VM_DIR/disk.qcow2"
ISO=""
while [[ $# -gt 0 ]]; do
case "$1" in
--iso) ISO="$2"; shift 2 ;;
*) echo "Usage: epicenter-vm [--iso /path/to/file.iso]"; exit 1 ;;
esac
done
# Create disk if it doesn't exist
if [ ! -f "$DISK" ]; then
mkdir -p "$VM_DIR"
${pkgs.qemu}/bin/qemu-img create -f qcow2 "$DISK" 60G
fi
QEMU_ARGS=(
-enable-kvm
-m 4G
-smp 2
-drive "file=$DISK,format=qcow2,if=virtio"
-bios ${pkgs.OVMF.fd}/FV/OVMF.fd
-display gtk,gl=on
-device virtio-vga-gl
-device virtio-net-pci,netdev=net0
-netdev user,id=net0,hostfwd=tcp::2222-:22
)
# Attach ISO if provided
if [ -n "$ISO" ]; then
QEMU_ARGS+=(-cdrom "$ISO" -boot d)
fi
exec ${pkgs.qemu}/bin/qemu-system-x86_64 "''${QEMU_ARGS[@]}"
'';
wrapperScript = pkgs.writeShellScriptBin "rustdesk-epicenter-wrapper" ''
# Grant epicenter user access to the Wayland socket
${pkgs.acl}/bin/setfacl -m u:epicenter:x "$XDG_RUNTIME_DIR"
@ -22,6 +62,7 @@ let
};
in {
environment.systemPackages = [
epicenter-vm
rustdeskEpicenterDesktopItem
];