diff --git a/options/custom/desktops/hyprland/plugins.nix b/options/custom/desktops/hyprland/plugins.nix index df3033f..3c332da 100644 --- a/options/custom/desktops/hyprland/plugins.nix +++ b/options/custom/desktops/hyprland/plugins.nix @@ -29,6 +29,7 @@ in { "plugin:hyprbars:nobar, class:^dev\\.benz\\.walker$" "plugin:hyprbars:nobar, class:^discord$, title:^Discord Updater$" "plugin:hyprbars:nobar, class:^dropdown$" + "plugin:hyprbars:nobar, class:^looking-glass-client$" "plugin:hyprbars:nobar, class:^moe\\.launcher\\..+$" "plugin:hyprbars:nobar, class:^org\\.gnome\\.Nautilus$, title:^New Folder$" "plugin:hyprbars:nobar, class:^org\\.gnome\\.NautilusPreviewer$" diff --git a/options/custom/desktops/hyprland/rules.nix b/options/custom/desktops/hyprland/rules.nix index b4d5d1e..130f1f5 100644 --- a/options/custom/desktops/hyprland/rules.nix +++ b/options/custom/desktops/hyprland/rules.nix @@ -246,6 +246,7 @@ in { ]; vm = rules: [ (class "(sdl-|wl|x)freerdp" (rules ++ ["nomaxsize" "tile"])) + (class "looking-glass-client" rules) (class "org\\.remmina\\.Remmina" (rules ++ ["tile"])) (class "virt-manager" rules) ]; diff --git a/options/custom/programs/looking-glass.nix b/options/custom/programs/looking-glass.nix new file mode 100644 index 0000000..86886b4 --- /dev/null +++ b/options/custom/programs/looking-glass.nix @@ -0,0 +1,107 @@ +{ + config, + lib, + ... +}: +with lib; let + cfg = config.custom.programs.looking-glass; +in { + options.custom.programs.looking-glass = { + enable = mkOption {default = false;}; + kvmfr = mkOption {default = true;}; + }; + + config = mkIf cfg.enable { + #!! Imperative libvirt xml configuration + # https://looking-glass.io/ + # https://looking-glass.io/docs/B6/install/ + # BUG: CPU host-passthrough causes error on VM start + # https://github.com/tianocore/edk2/discussions/4662 + #?? + + # https://looking-glass.io/docs/B6/module/#kernel-module + boot = mkIf cfg.kvmfr { + extraModulePackages = [config.boot.kernelPackages.kvmfr]; + extraModprobeConfig = "options kvmfr static_size_mb=128"; + kernelModules = ["kvmfr"]; + }; + + systemd = { + tmpfiles.settings."10-looking-glass" = { + ${ + if cfg.kvmfr + then "/dev/kvmfr0" + else "/dev/shm/looking-glass" + } = { + ${ + if cfg.kvmfr + then "z" + else "f" + } = { + mode = "0660"; + user = config.custom.username; + group = "qemu-libvirtd"; + }; + }; + }; + + # HACK: Remove exclusion of /dev prefix from service so rules take effect for devices + # https://github.com/NixOS/nixpkgs/blob/master/nixos/modules/system/boot/systemd/tmpfiles.nix + # https://github.com/NixOS/nixpkgs/commit/e6b66f08a53261cf825817df59d3ccd75ed0eead + services.systemd-tmpfiles-setup.serviceConfig = { + ExecStart = mkForce "systemd-tmpfiles --create --remove --boot --exclude-prefix=/sysroot"; + }; + }; + + # https://looking-glass.io/docs/B6/module/#libvirt + virtualisation.libvirtd.qemu.verbatimConfig = mkIf cfg.kvmfr '' + cgroup_device_acl = [ + "/dev/null", "/dev/full", "/dev/zero", + "/dev/random", "/dev/urandom", + "/dev/ptmx", "/dev/kvm", "/dev/kqemu", + "/dev/rtc", "/dev/hpet", "/dev/vfio/vfio", + "/dev/kvmfr0" + ] + + # Default configuration + namespaces = [] + ''; + + home-manager.users.${config.custom.username} = { + # BUG: Crashes when reconnecting to spice channel + programs.looking-glass-client = { + enable = true; + + # https://looking-glass.io/docs/B6/usage/#all-command-line-options + settings = { + app = { + shmFile = + if cfg.kvmfr + then "/dev/kvmfr0" + else "/dev/shm/looking-glass"; + }; + + input = { + grabKeyboard = false; + ignoreWindowsKeys = true; + }; + + spice = { + # BUG: SPICE audio causes disconnections, remove with QEMU >= 9.1.2 + # https://gitlab.com/qemu-project/qemu/-/commit/8d9c6f6fa9eebd09ad8d0b4b4de4a0ec57e756d1 + audio = false; + }; + + win = { + borderless = true; + fullScreen = true; + quickSplash = true; + size = "${toString (config.custom.width / 2)}x${toString (config.custom.height / 2)}"; + uiFont = config.custom.font.monospace; + uiSize = 24; + }; + }; + }; + }; + }; +} diff --git a/profiles/desktop/default.nix b/profiles/desktop/default.nix index 1224e98..6a2fe8e 100644 --- a/profiles/desktop/default.nix +++ b/profiles/desktop/default.nix @@ -3,11 +3,7 @@ full = true; profile = "desktop"; wallpaper = true; + programs.looking-glass.enable = true; services.power-profiles-daemon.enable = true; - - programs.anime-game-launcher = { - enable = true; - genshin-impact = true; - }; }; }