dot
vizie's NixOS desktop: Hyprland, CachyOS kernel and gaming tweaks
| 1 | #!/usr/bin/env bash |
| 2 | # Build and boot the desktop configuration in a QEMU VM (see modules/nixos/vm.nix). |
| 3 | # |
| 4 | # ./vm.sh build and start the VM |
| 5 | # ./vm.sh --fresh the same, but start from an empty VM disk |
| 6 | # |
| 7 | # The VM renders on the host GPU through virgl. QEMU's own window can't get a GL |
| 8 | # context on the NVIDIA driver, so it renders headless on a Mesa GPU (the |
| 9 | # Ryzen's integrated Radeon here) and is shown over VNC on this machine only: |
| 10 | # vncviewer localhost:5905 (e.g. nix run nixpkgs#tigervnc -- localhost:5905) |
| 11 | # |
| 12 | # The VM's disk is desktop.qcow2 in this directory (git ignores it). A QEMU |
| 13 | # monitor socket, vm-monitor.sock, takes screenshots and key presses from |
| 14 | # scripts, e.g.: echo 'screendump shot.ppm' | socat - UNIX-CONNECT:vm-monitor.sock |
| 15 | # The VM's console (boot messages, then a login prompt) goes to vm-serial.log. |
| 16 | # |
| 17 | # SSH: ssh -p 2222 vizie@localhost, with the key in $VM_SSH_KEY (a .pub file, |
| 18 | # default ~/.ssh/id_ed25519.pub). The key is shared with this VM only. |
| 19 | |
| 20 | |
| 21 | here= |
| 22 | |
| 23 | if [; then |
| 24 | |
| 25 | fi |
| 26 | |
| 27 | # The first render node whose driver isn't nvidia. |
| 28 | rendernode= |
| 29 | for; do |
| 30 | driver= |
| 31 | if [; then rendernode=; break; fi |
| 32 | done |
| 33 | if [; then |
| 34 | |
| 35 | |
| 36 | fi |
| 37 | |
| 38 | vm= |
| 39 | |
| 40 | # Outside NixOS (e.g. on CachyOS, before the switch) there is no |
| 41 | # /run/opengl-driver for the Nix-built QEMU to find GPU drivers in; give it the |
| 42 | # Mesa from the same nixpkgs. |
| 43 | if [; then |
| 44 | mesa= |
| 45 | |
| 46 | |
| 47 | |
| 48 | fi |
| 49 | |
| 50 | |
| 51 | # A temporary folder for the VM's sockets and /tmp/xchg, with the SSH key in it. |
| 52 | vmtmp= |
| 53 | |
| 54 | |
| 55 | |
| 56 | key= |
| 57 | if [; then ; fi |
| 58 | |
| 59 | |
| 60 | |