From 9a75f0b57ba8f42a78741e3500d9eca6ac477db1 Mon Sep 17 00:00:00 2001 From: Kopatz <7265381+Kropatz@users.noreply.github.com> Date: Tue, 12 Aug 2025 21:46:19 +0200 Subject: [PATCH] make vr work yippie --- flake.lock | 112 ++++++++++++++++++++++++++++++++++- flake.nix | 2 + home-manager/vr.nix | 44 +++++++------- modules/hardware/default.nix | 1 + modules/hardware/vr.nix | 74 +++++++++++++---------- systems/pc/configuration.nix | 2 +- 6 files changed, 181 insertions(+), 54 deletions(-) diff --git a/flake.lock b/flake.lock index 4ee214f..9ad12ab 100644 --- a/flake.lock +++ b/flake.lock @@ -150,6 +150,20 @@ "type": "github" } }, + "flake-compat": { + "locked": { + "lastModified": 1733328505, + "narHash": "sha256-NeCCThCEP3eCl2l/+27kNNK7QrwZB1IJCrXfrbv5oqU=", + "rev": "ff81ac966bb2cae68946d5ed5fc4994f96d0ffec", + "revCount": 69, + "type": "tarball", + "url": "https://api.flakehub.com/f/pinned/edolstra/flake-compat/1.1.0/01948eb7-9cba-704f-bbf3-3fa956735b52/source.tar.gz" + }, + "original": { + "type": "tarball", + "url": "https://flakehub.com/f/edolstra/flake-compat/1.tar.gz" + } + }, "flake-parts": { "inputs": { "nixpkgs-lib": [ @@ -249,6 +263,24 @@ "type": "github" } }, + "flake-utils_3": { + "inputs": { + "systems": "systems_4" + }, + "locked": { + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, "fromYaml": { "flake": false, "locked": { @@ -416,6 +448,43 @@ "type": "github" } }, + "nixpkgs-xr": { + "inputs": { + "flake-compat": "flake-compat", + "flake-utils": "flake-utils_2", + "nixpkgs": "nixpkgs_2", + "treefmt-nix": "treefmt-nix" + }, + "locked": { + "lastModified": 1754962187, + "narHash": "sha256-KnYuOGLgvpmFrd32Xs3NIvVHgVI7BS8xbw5z04ojDyI=", + "owner": "nix-community", + "repo": "nixpkgs-xr", + "rev": "a3ac1310d4c1f728d5cf53e75ea829ccf7ef11b9", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixpkgs-xr", + "type": "github" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1754725699, + "narHash": "sha256-iAcj9T/Y+3DBy2J0N+yF9XQQQ8IEb5swLFzs23CdP88=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "85dbfc7aaf52ecb755f87e577ddbe6dbbdbc1054", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, "nixvim": { "inputs": { "flake-parts": "flake-parts", @@ -423,7 +492,7 @@ "nixpkgs-unstable" ], "nuschtosSearch": "nuschtosSearch", - "systems": "systems_4" + "systems": "systems_5" }, "locked": { "lastModified": 1754682350, @@ -487,7 +556,7 @@ }, "nuschtosSearch": { "inputs": { - "flake-utils": "flake-utils_2", + "flake-utils": "flake-utils_3", "ixx": "ixx", "nixpkgs": [ "nixvim", @@ -519,6 +588,7 @@ "nixpkgs": "nixpkgs", "nixpkgs-unstable": "nixpkgs-unstable", "nixpkgs-working-xrdp": "nixpkgs-working-xrdp", + "nixpkgs-xr": "nixpkgs-xr", "nixvim": "nixvim", "nur": "nur", "stylix": "stylix" @@ -537,7 +607,7 @@ "nixpkgs-unstable" ], "nur": "nur_2", - "systems": "systems_5", + "systems": "systems_6", "tinted-foot": "tinted-foot", "tinted-kitty": "tinted-kitty", "tinted-schemes": "tinted-schemes", @@ -633,6 +703,21 @@ "type": "github" } }, + "systems_6": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, "tinted-foot": { "flake": false, "locked": { @@ -713,6 +798,27 @@ "repo": "base16-zed", "type": "github" } + }, + "treefmt-nix": { + "inputs": { + "nixpkgs": [ + "nixpkgs-xr", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1754847726, + "narHash": "sha256-2vX8QjO5lRsDbNYvN9hVHXLU6oMl+V/PsmIiJREG4rE=", + "owner": "numtide", + "repo": "treefmt-nix", + "rev": "7d81f6fb2e19bf84f1c65135d1060d829fae2408", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "treefmt-nix", + "type": "github" + } } }, "root": "root", diff --git a/flake.nix b/flake.nix index c1da5f3..bfee6c2 100644 --- a/flake.nix +++ b/flake.nix @@ -22,6 +22,7 @@ }; ## unstable nixpkgs-unstable.url = "github:nixos/nixpkgs/nixos-unstable"; + nixpkgs-xr.url = "github:nix-community/nixpkgs-xr"; home-manager-unstable = { url = "github:nix-community/home-manager/master"; inputs.nixpkgs.follows = "nixpkgs-unstable"; @@ -104,6 +105,7 @@ [ specialArgs.home-manager-version.nixosModules.home-manager ] ++ lib.lists.optionals (!minimal && graphical) [ stylix.nixosModules.stylix + inputs.nixpkgs-xr.nixosModules.nixpkgs-xr ./modules/graphical/stylix.nix #nixos-cosmic.nixosModules.default #./modules/graphical/cosmic.nix diff --git a/home-manager/vr.nix b/home-manager/vr.nix index b75e01a..d979323 100644 --- a/home-manager/vr.nix +++ b/home-manager/vr.nix @@ -1,22 +1,26 @@ -{ pkgs, config, ... }: +{ pkgs, config, osConfig, lib, ... }: { - #xdg.configFile."openvr/openvrpaths.vrpath".text = '' - # { - # "config" : - # [ - # "~/.local/share/Steam/config" - # ], - # "external_drivers" : null, - # "jsonid" : "vrpathreg", - # "log" : - # [ - # "~/.local/share/Steam/logs" - # ], - # "runtime" : - # [ - # "${pkgs.opencomposite}/lib/opencomposite" - # ], - # "version" : 1 - # } - #''; + config = lib.mkIf osConfig.custom.hardware.vr.enable + { + xdg.configFile."openxr/1/active_runtime.json".source = "${pkgs.monado}/share/openxr/1/openxr_monado.json"; + xdg.configFile."openvr/openvrpaths.vrpath".text = '' + { + "config" : + [ + "~/.local/share/Steam/config" + ], + "external_drivers" : null, + "jsonid" : "vrpathreg", + "log" : + [ + "~/.local/share/Steam/logs" + ], + "runtime" : + [ + "${pkgs.opencomposite}/lib/opencomposite" + ], + "version" : 1 + } + ''; + }; } diff --git a/modules/hardware/default.nix b/modules/hardware/default.nix index 64fd1c4..66619ff 100644 --- a/modules/hardware/default.nix +++ b/modules/hardware/default.nix @@ -11,5 +11,6 @@ ./tpm.nix ./tablet.nix ./fingerprint.nix + ./vr.nix ]; } diff --git a/modules/hardware/vr.nix b/modules/hardware/vr.nix index b15c293..aa701eb 100644 --- a/modules/hardware/vr.nix +++ b/modules/hardware/vr.nix @@ -1,5 +1,6 @@ -{ pkgs, config, ... }: +{ pkgs, config, lib, ... }: let + cfg = config.custom.hardware.vr; # https://wiki.nixos.org/wiki/VR#Patching_AMDGPU_to_allow_high_priority_queues amdgpu = { pkgs @@ -46,38 +47,51 @@ let }; in { + + options.custom.hardware.vr = { + enable = lib.mkEnableOption "Enables amd gpus"; + overdrive = lib.mkEnableOption "Enables overdrive"; + rocm.enable = lib.mkEnableOption "Enables rocm"; + }; #programs.envision = { # enable = true; # openFirewall = true; #}; - # systemctl --user start monado.service - #services.monado = { - # enable = true; - # defaultRuntime = true; # Register as default OpenXR runtime - #}; - #environment.systemPackages = with pkgs; [ - # monado - #]; - #systemd.user.services.monado.environment = { - # STEAMVR_LH_ENABLE = "1"; - # XRT_COMPOSITOR_COMPUTE = "1"; - # WMR_HANDTRACKING = "0"; - #}; - #programs.git = { - # enable = true; - # lfs.enable = true; - #}; - hardware.steam-hardware.enable = true; - boot.extraModulePackages = [ - (amdgpu-kernel-module.overrideAttrs (_: { - patches = [ - (pkgs.fetchpatch { - name = "cap_sys_nice_begone.patch"; - url = "https://github.com/Frogging-Family/community-patches/raw/master/linux61-tkg/cap_sys_nice_begone.mypatch"; - hash = "sha256-Y3a0+x2xvHsfLax/uwycdJf3xLxvVfkfDVqjkxNaYEo="; - }) - ]; - })) - ]; + # systemctl --user start monado.service + # make sure ~/.config/openxr/1/active_runtime.json doesn't block it + # and ~/.config/openvr/openvrpaths.vrpath + config = lib.mkIf cfg.enable { + services.monado = { + enable = true; + defaultRuntime = true; # Register as default OpenXR runtime + }; + environment.systemPackages = with pkgs; [ + monado + wlx-overlay-s + wayvr-dashboard + ]; + systemd.user.services.monado.environment = { + STEAMVR_LH_ENABLE = "1"; + XRT_COMPOSITOR_COMPUTE = "1"; + WMR_HANDTRACKING = "0"; + }; + programs.git = { + enable = true; + lfs.enable = true; + }; + + hardware.steam-hardware.enable = true; + boot.extraModulePackages = [ + (amdgpu-kernel-module.overrideAttrs (_: { + patches = [ + (pkgs.fetchpatch { + name = "cap_sys_nice_begone.patch"; + url = "https://github.com/Frogging-Family/community-patches/raw/master/linux61-tkg/cap_sys_nice_begone.mypatch"; + hash = "sha256-Y3a0+x2xvHsfLax/uwycdJf3xLxvVfkfDVqjkxNaYEo="; + }) + ]; + })) + ]; + }; } diff --git a/systems/pc/configuration.nix b/systems/pc/configuration.nix index a517e93..7c5398d 100644 --- a/systems/pc/configuration.nix +++ b/systems/pc/configuration.nix @@ -18,7 +18,6 @@ ../../modules/misc/faster-boot-time.nix #../../modules/hardware/ryzenmonitor.nix ../../modules/networkmanager.nix - ../../modules/hardware/vr.nix ]; custom = { @@ -50,6 +49,7 @@ rocm.enable = true; overdrive = true; }; + vr.enable = true; nvidia = { enable = false; clock = {