dot

vizie's NixOS desktop: Hyprland, CachyOS kernel and gaming tweaks

60 lines2132 bytesNix
1# The test VM: this exact system in QEMU, built with
2# nixos-rebuild build-vm --flake .#desktop (or ./vm.sh)
3# It shares the host's /nix/store, so it builds in seconds once the real
4# system has. Only what can't work in a VM is changed: no NVIDIA, a virtual GPU,
5# the configs copied in rather than linked to your checkout, and a password to
6# get past the lock screen at login.
7{ lib, ... }:
8{
9 virtualisation.vmVariant = {
10 virtualisation = {
11 memorySize = 8192;
12 cores = 6;
13 diskSize = 16384;
14 resolution = {
15 x = 1920;
16 y = 1080;
17 };
18 # A virtual GPU with OpenGL passed through to the host (virgl); vm.sh
19 # picks how it is displayed.
20 qemu.options = [ "-device virtio-vga-gl" ];
21
22 # ssh -p 2222 vizie@localhost, with the key vm.sh hands in (see there).
23 forwardPorts = [
24 {
25 from = "host";
26 host.address = "127.0.0.1";
27 host.port = 2222;
28 guest.port = 22;
29 }
30 ];
31 };
32
33 # /tmp/xchg is a folder shared with the host; vm.sh puts the public key
34 # there. sshd won't read keys from under /tmp (anyone can write there), so
35 # it is copied somewhere root owns at boot. Only the VM has this; the real
36 # system's SSH logins are unchanged.
37 services.openssh.authorizedKeysFiles = [ "/run/vm-ssh/authorized_keys" ];
38 systemd.services.vm-ssh-key = {
39 wantedBy = [ "sshd.service" ];
40 before = [ "sshd.service" ];
41 serviceConfig.Type = "oneshot";
42 script = ''
43 install -d -m755 /run/vm-ssh
44 if [ -f /tmp/xchg/authorized_keys ]; then
45 install -m644 /tmp/xchg/authorized_keys /run/vm-ssh/authorized_keys
46 fi
47 '';
48 };
49
50 dot.nvidia.enable = false;
51
52 # The VM has no eno1 for systemd-networkd to bring up (NetworkManager does
53 # its network), so don't hold the boot waiting for it.
54 systemd.network.wait-online.enable = false;
55 home-manager.users.vizie.dot.liveConfig = lib.mkForce false;
56
57 # The VM's user has no password of its own to unlock the session with.
58 users.users.vizie.initialPassword = "vizie";
59 };
60}