VR/ja: Difference between revisions
Updating to match new version of source page |
Updating to match new version of source page Tags: Mobile edit Mobile web edit |
||
Line 65: | Line 65: | ||
For further information about available environment variables and tweaks, read the [https://lvra.gitlab.io/docs/fossvr/monado/ Linux VR Adventures wiki] and the [https://monado.freedesktop.org/getting-started.html#environment-variables Monado documentation about environment variables] | For further information about available environment variables and tweaks, read the [https://lvra.gitlab.io/docs/fossvr/monado/ Linux VR Adventures wiki] and the [https://monado.freedesktop.org/getting-started.html#environment-variables Monado documentation about environment variables] | ||
</div> | </div> | ||
== OpenComposite == | == OpenComposite == | ||
Line 77: | Line 76: | ||
</div> | </div> | ||
< | {{Warning|<span lang="en" dir="ltr" class="mw-content-ltr">Older versions of Proton will always query the current OpenVR and OpenXR runtime. If you use OpenComposite, and it fails to initialize an OpenXR context, Proton will fail to launch. A workaround is to delete the ~/.config/openvr/openvrpaths.vrpath file and then retry launching the game.</span>}} | ||
</ | |||
<div lang="en" dir="ltr" class="mw-content-ltr"> | <div lang="en" dir="ltr" class="mw-content-ltr"> | ||
Line 128: | Line 125: | ||
</div> | </div> | ||
< | {{Warning|<span lang="en" dir="ltr" class="mw-content-ltr">As of WiVRn version 0.23, WiVRn now manages the opencomposite paths itself. Only use the above opencomposite configuration when using versions below v0.23.</span>}} | ||
</ | |||
{{File|/etc/nixos/configuration.nix|nix|3=services.wivrn = { | {{File|/etc/nixos/configuration.nix|nix|3=services.wivrn = { | ||
Line 200: | Line 195: | ||
</div> | </div> | ||
< | {{Note|<span lang="en" dir="ltr" class="mw-content-ltr">Steam is run in a bubblewrap-based FHS environment. This environment runs Steam in a user namespace, which prevents it from using any capabilities or setuid binaries. This means that asynchronous reprojection can not be used on NixOS, without patching the kernel to remove these restrictions completely, or modifying the bubblewrap binary used for running Steam to remove these capability protections. Both of these workarounds come with their own security tradeoffs. See this [https://github.com/NixOS/nixpkgs/issues/217119 Nixpkgs issue]</span>}} | ||
</ | |||
<div lang="en" dir="ltr" class="mw-content-ltr"> | <div lang="en" dir="ltr" class="mw-content-ltr"> | ||
Line 212: | Line 205: | ||
</div> | </div> | ||
< | {{Warning|<span lang="en" dir="ltr" class="mw-content-ltr">This removes intentional restrictions from the kernel, and it could cause scheduling issues. While it has not been reported that it does cause issues, this should be considered an unsupported configuration.</span>}} | ||
</ | |||
<div lang="en" dir="ltr" class="mw-content-ltr"> | <div lang="en" dir="ltr" class="mw-content-ltr"> | ||
Line 238: | Line 229: | ||
<div lang="en" dir="ltr" class="mw-content-ltr"> | <div lang="en" dir="ltr" class="mw-content-ltr"> | ||
It is also possible to just patch amdgpu and build it as an out-of-tree module, as described in [[Linux_kernel#Patching_a_single_In-tree_kernel_module]] | It is also possible to just patch amdgpu and build it as an out-of-tree module, as described in [[Linux_kernel#Patching_a_single_In-tree_kernel_module]] | ||
</div> | |||
<div lang="en" dir="ltr" class="mw-content-ltr"> | |||
=== Patching bubblewrap to allow capabilities === | |||
</div> | |||
<div lang="en" dir="ltr" class="mw-content-ltr"> | |||
By modifying the bubblewrap binary used for running Steam, you can allow processes in that FHS environment to acquire capabilities. This removes the need for patching the kernel directly. | |||
</div> | |||
{{Warning|<span lang="en" dir="ltr" class="mw-content-ltr">This circumvents an intended security mechanism in bubblewrap, and allows all other software launched by steam, or running via steam-run to acquire these capabilities as well.</span>}} | |||
{{file|/etc/nixos/configuration.nix|nix|3=programs.steam = let | |||
patchedBwrap = pkgs.bubblewrap.overrideAttrs (o: { | |||
patches = (o.patches or []) ++ [ | |||
./bwrap.patch | |||
]; | |||
}); | |||
in { | |||
enable = true; | |||
package = pkgs.steam.override { | |||
buildFHSEnv = (args: ((pkgs.buildFHSEnv.override { | |||
bubblewrap = patchedBwrap; | |||
}) (args // { | |||
extraBwrapArgs = (args.extraBwrapArgs or []) ++ [ "--cap-add ALL" ]; | |||
}))); | |||
}; | |||
}; | |||
}} | |||
{{file|/etc/nixos/bwrap.patch|diff|3=diff --git a/bubblewrap.c b/bubblewrap.c | |||
index 8322ea0..4e20262 100644 | |||
--- a/bubblewrap.c | |||
+++ b/bubblewrap.c | |||
@@ -868,13 +868,6 @@ acquire_privs (void) | |||
/* Keep only the required capabilities for setup */ | |||
set_required_caps (); | |||
} | |||
- else if (real_uid != 0 && has_caps ()) | |||
- { | |||
- /* We have some capabilities in the non-setuid case, which should not happen. | |||
- Probably caused by the binary being setcap instead of setuid which we | |||
- don't support anymore */ | |||
- die ("Unexpected capabilities but not setuid, old file caps config?"); | |||
- } | |||
else if (real_uid == 0) | |||
{ | |||
/* If our uid is 0, default to inheriting all caps; the caller | |||
}} | |||
<div lang="en" dir="ltr" class="mw-content-ltr"> | |||
as an additional change, you may also need to replace Steam's own bwrap binary with a symbolic link to this modified bwrap binary, found at <code>~/.local/share/Steam/ubuntu12_32/steam-runtime/usr/libexec/steam-runtime-tools-0/srt-bwrap</code>. | |||
</div> | |||
<div lang="en" dir="ltr" class="mw-content-ltr"> | |||
Steam will periodically replace this modification with its own binary when steam-runtime updates, so you may need to re-apply this change if it breaks. | |||
</div> | </div> | ||
Line 253: | Line 299: | ||
<div lang="en" dir="ltr" class="mw-content-ltr"> | <div lang="en" dir="ltr" class="mw-content-ltr"> | ||
When launching wlx-overlay-s in SteamVR (or any OpenVR compositor) it will register an autostart manifest. Currently, this manifest will reference a Nix store path of wlx-overlay-s, which might get garbage collected after rebuilds of your NixOS/Nix profile. A workaround is to regularly run the following command to update the manifest's store path:{{Commands| | When launching wlx-overlay-s in SteamVR (or any OpenVR compositor) it will register an autostart manifest. Currently, this manifest will reference a Nix store path of wlx-overlay-s, which might get garbage collected after rebuilds of your NixOS/Nix profile. A workaround is to regularly run the following command to update the manifest's store path: | ||
# Run wlx-overlay-s and replace any running instance | </div> | ||
{{Commands| | |||
# <span lang="en" dir="ltr" class="mw-content-ltr">Run wlx-overlay-s and replace any running instance</span> | |||
$ wlx-overlay-s --replace}} | $ wlx-overlay-s --replace}} | ||
<span id="See_also"></span> | <span id="See_also"></span> | ||
Line 263: | Line 311: | ||
<div lang="en" dir="ltr" class="mw-content-ltr"> | <div lang="en" dir="ltr" class="mw-content-ltr"> | ||
* [https://lvra.gitlab.io Linux VR Adventures Wiki] | * [https://lvra.gitlab.io Linux VR Adventures Wiki] | ||
</div> | |||
<div lang="en" dir="ltr" class="mw-content-ltr"> | |||
[[Category:Video]] | [[Category:Video]] | ||
[[Category:Hardware]] | [[Category:Hardware]] |
Latest revision as of 14:35, 10 October 2025
Monado
Monado is an open source OpenXR runtime. It offers support for a variety of hardware using its built-in drivers and can be used to run any OpenXR and, with the help of OpenComposite, most OpenVR applications.
MonadoはNixOS 24.05以降、NixOSのオプションを使用して設定できます:
services.monado = {
enable = true;
defaultRuntime = true; # Register as default OpenXR runtime
};
Monadoを設定すると、もしかすると追加の環境変数を設定したくなるかもしれません:
systemd.user.services.monado.environment = {
STEAMVR_LH_ENABLE = "1";
XRT_COMPOSITOR_COMPUTE = "1";
};
Once configured, Monado can be started and stopped in a systemd user session.
For example, the following commands will start Monado and then follow its log output:
$ systemctl --user start monado.service
$ journalctl --user --follow --unit monado.service
ハンドトラッキング
ハンドトラッキング用のデータがないため、monado-services
の実行が失敗することに気づくかもしれません。これを直すためには、ハンドトラッキングを完全に無効にするか、ハンドトラッキング用のデータをダウンロードするかの二つの方法があります。
ハンドトラッキングを無効にするには、WMR_HANDTRACKING = "0";
を含むように環境変数を変更します。つまり以下のようになります。
systemd.user.services.monado.environment = {
STEAMVR_LH_ENABLE = "1";
XRT_COMPOSITOR_COMPUTE = "1";
WMR_HANDTRACKING = "0";
};
ハンドトラッキングを動作させるには、git-lfs
を有効にする必要があります。git-lfs
を有効にする標準的な方法は、以下の設定です
programs.git = {
enable = true;
lfs.enable = true;
};
git-lfs
が有効になっていることを確認した後、以下のコマンドを実行してmonado-service
を再起動します
$ mkdir -p ~/.local/share/monado
$ cd ~/.local/share/monado
$ git clone https://gitlab.freedesktop.org/monado/utilities/hand-tracking-models
For further information about available environment variables and tweaks, read the Linux VR Adventures wiki and the Monado documentation about environment variables
OpenComposite
OpenComposite is a compatibility layer for running OpenVR applications on an OpenXR runtime like Monado. It is comparable to tools like DXVK or vkd3d, but for translating OpenVR calls to OpenXR.
In order to run OpenVR games on anything other than SteamVR, you need to configure the OpenVR runtime path defined in ~/.config/openvr/openvrpaths.vrpath
. A reliable way to do this is to use Home Manager to create this file.
If this file is not set to read-only, SteamVR will add its runtime path back, hence the use for Home Manager.
An example configuration for enabling OpenComposite may look like this:
# For Monado:
xdg.configFile."openxr/1/active_runtime.json".source = "${pkgs.monado}/share/openxr/1/openxr_monado.json";
# For WiVRn v0.22 and below:
xdg.configFile."openxr/1/active_runtime.json".source = "${pkgs.wivrn}/share/openxr/1/openxr_wivrn.json";
xdg.configFile."openvr/openvrpaths.vrpath".text = ''
{
"config" :
[
"${config.xdg.dataHome}/Steam/config"
],
"external_drivers" : null,
"jsonid" : "vrpathreg",
"log" :
[
"${config.xdg.dataHome}/Steam/logs"
],
"runtime" :
[
"${pkgs.opencomposite}/lib/opencomposite"
],
"version" : 1
}
'';
If you are planning to play any OpenVR game on Steam or OpenXR games through Proton, you will have to use OpenComposite in this manner. In most cases you also have to allow access to the socket path of your OpenXR runtime to Steam's runtime, by using the following launch options for XR applications on Steam: env PRESSURE_VESSEL_FILESYSTEMS_RW=$XDG_RUNTIME_DIR/monado_comp_ipc %command%
. This example is for Monado, while other XR runtimes might differ.
WiVRn
WiVRn is an OpenXR streaming application built around Monado. It wirelessly connects a standalone VR headset to a Linux computer. If your headset is not wireless, look at Monado instead. Example usage of the WiVRn module:
services.wivrn = {
enable = true;
openFirewall = true;
# Write information to /etc/xdg/openxr/1/active_runtime.json, VR applications
# will automatically read this and work with WiVRn (Note: This does not currently
# apply for games run in Valve's Proton)
defaultRuntime = true;
# Run WiVRn as a systemd service on startup
autoStart = true;
# Config for WiVRn (https://github.com/WiVRn/WiVRn/blob/master/docs/configuration.md)
config = {
enable = true;
json = {
# 1.0x foveation scaling
scale = 1.0;
# 100 Mb/s
bitrate = 100000000;
encoders = [
{
encoder = "vaapi";
codec = "h265";
# 1.0 x 1.0 scaling
width = 1.0;
height = 1.0;
offset_x = 0.0;
offset_y = 0.0;
}
];
};
};
};
Like Monado, you will also have to add the launch argument for WiVRn to allow access to the socket: PRESSURE_VESSEL_FILESYSTEMS_RW=$XDG_RUNTIME_DIR/wivrn/comp_ipc %command%
Envision
Envision is an orchestrator for the FOSS VR stack. It handles the building and configuration of Monado, WiVRn, OpenComposite, and other utilities of the FOSS VR stack such as the Lighthouse driver, OpenHMD, Survive, and WMR. You can enable it with the Envision module:
programs.envision = {
enable = true;
openFirewall = true; # This is set true by default
};
SteamVR
SteamVR is a proprietary OpenVR runtime with compatibility for OpenXR. It is part of Steam and doesn't need any additional setup on NixOS apart from enabling Steam.
After installing SteamVR through Steam and plugging in a SteamVR-compatible headset, SteamVR should work for the most part.
On initial setup, SteamVR will ask for elevated permissions, to set up a file capability for one of its binaries. This is needed to allow asynchronous reprojection to work. Clients need the CAP_SYS_NICE
capability to acquire a high-priority context, which is a requirement for asynchronous reprojection.
Patching AMDGPU to allow high priority queues
By applying this patch, the AMDGPU kernel driver will ignore process privileges and allow any application to create high priority contexts.
Applying as a NixOS kernel patch
To workaround the CAP_SYS_NICE
requirement, we can apply a kernel patch using the following NixOS configuration snippet:
boot.kernelPatches = [
{
name = "amdgpu-ignore-ctx-privileges";
patch = 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=";
};
}
];
It is also possible to just patch amdgpu and build it as an out-of-tree module, as described in Linux_kernel#Patching_a_single_In-tree_kernel_module
Patching bubblewrap to allow capabilities
By modifying the bubblewrap binary used for running Steam, you can allow processes in that FHS environment to acquire capabilities. This removes the need for patching the kernel directly.
programs.steam = let
patchedBwrap = pkgs.bubblewrap.overrideAttrs (o: {
patches = (o.patches or []) ++ [
./bwrap.patch
];
});
in {
enable = true;
package = pkgs.steam.override {
buildFHSEnv = (args: ((pkgs.buildFHSEnv.override {
bubblewrap = patchedBwrap;
}) (args // {
extraBwrapArgs = (args.extraBwrapArgs or []) ++ [ "--cap-add ALL" ];
})));
};
};
diff --git a/bubblewrap.c b/bubblewrap.c
index 8322ea0..4e20262 100644
--- a/bubblewrap.c
+++ b/bubblewrap.c
@@ -868,13 +868,6 @@ acquire_privs (void)
/* Keep only the required capabilities for setup */
set_required_caps ();
}
- else if (real_uid != 0 && has_caps ())
- {
- /* We have some capabilities in the non-setuid case, which should not happen.
- Probably caused by the binary being setcap instead of setuid which we
- don't support anymore */
- die ("Unexpected capabilities but not setuid, old file caps config?");
- }
else if (real_uid == 0)
{
/* If our uid is 0, default to inheriting all caps; the caller
as an additional change, you may also need to replace Steam's own bwrap binary with a symbolic link to this modified bwrap binary, found at ~/.local/share/Steam/ubuntu12_32/steam-runtime/usr/libexec/steam-runtime-tools-0/srt-bwrap
.
Steam will periodically replace this modification with its own binary when steam-runtime updates, so you may need to re-apply this change if it breaks.
wlx-overlay-s
wlx-overlay-s is a lightweight OpenXR/OpenVR overlay for Wayland and X11 desktops. It works with SteamVR as well as Monado/WiVRn natively.
SteamVR autostart
When launching wlx-overlay-s in SteamVR (or any OpenVR compositor) it will register an autostart manifest. Currently, this manifest will reference a Nix store path of wlx-overlay-s, which might get garbage collected after rebuilds of your NixOS/Nix profile. A workaround is to regularly run the following command to update the manifest's store path:
{{{1}}}