feat: nb add epicenter-vm
This commit is contained in:
parent
c2e70e2a26
commit
3568719372
1 changed files with 42 additions and 1 deletions
|
|
@ -1,5 +1,45 @@
|
||||||
{ lib, pkgs, ... }:
|
{ lib, pkgs, ... }:
|
||||||
let
|
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" ''
|
wrapperScript = pkgs.writeShellScriptBin "rustdesk-epicenter-wrapper" ''
|
||||||
# Grant epicenter user access to the Wayland socket
|
# Grant epicenter user access to the Wayland socket
|
||||||
${pkgs.acl}/bin/setfacl -m u:epicenter:x "$XDG_RUNTIME_DIR"
|
${pkgs.acl}/bin/setfacl -m u:epicenter:x "$XDG_RUNTIME_DIR"
|
||||||
|
|
@ -22,6 +62,7 @@ let
|
||||||
};
|
};
|
||||||
in {
|
in {
|
||||||
environment.systemPackages = [
|
environment.systemPackages = [
|
||||||
|
epicenter-vm
|
||||||
rustdeskEpicenterDesktopItem
|
rustdeskEpicenterDesktopItem
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue