NixOS

NixOS #

General documentation about VR is provided on the NixOS Wiki.

The recommended way to set up NixOS for VR is by using services.monado or services.wivrn. Please see below for specific documentation on these 2 methods.

OpenXR #

Runtimes #

To set a default OpenXR runtime, you can either use services.monado.defaultRuntime (the same option is present for WiVRn) or create/modify ~/.config/openxr/1/active_runtime.json.

OpenXR apps running under Steam (or more generally, under a sandbox) will not be able to find the OpenXR runtime if they cannot access 1/active_runtime.json in any of the paths in XDG_CONFIG_DIRS (such as $HOME/.config/openxr/1/active_runtime.json, /etc/xdg/openxr/1/active_runtime.json).

You need to link the active_runtime.json so that the link target is accessible in the sandbox (make sure /nix is passed through to the container; this is already the case for Steam):

xdg.configFile."openxr/1/active_runtime.json".source = "${pkgs.monado}/share/openxr/1/openxr_monado.json";
# OR
xdg.configFile."openxr/1/active_runtime.json".source = "${pkgs.wivrn}/share/openxr/1/openxr_wivrn.json";

Monado #

Monado is supported natively on NixOS using services.monado since 24.05. You may also want to see the NixOS wiki on Monado.

If you are using the Monado NixOS module, it’s recommended to manage it using the provided systemd user service (systemctl --user start monado & systemctl --user stop monado.service).

Due to the presence of the monado.socket, Monado should also start up automatically whenever an OpenXR app attempts to connect.

If you wish for Monado to also stop when all XR apps close, set systemd.user.services.monado.environment."IPC_EXIT_ON_DISCONNECT" = "1".

If you are having performance issues, you may want to try something below:

  • In case of the headset view stuttering, adding U_PACING_COMP_MIN_TIME_MS = "5"; to systemd.user.services.monado.environment could help. Adjust the value as needed.
  • Similarly, setting the CPU niceness value to a higher priority manually with renice -20 -p $(pgrep monado) could also help. Unfortunately systemd.user.services.monado.serviceConfig.Nice = -20; does not seem to work.

WiVRn #

WiVRn is also supported natively on NixOS using services.wivrn since 24.05.

As WiVRn is built around Monado, most, if not all, settings for Monado are also available for WiVRn, however you may need to change things like process and option names appropriately.

You can find WiVRn on the official NixOS wiki.

Steam games and OpenVR apps #

For running OpenVR apps (such as games intended to work with SteamVR), you may also need to install xrizer or opencomposite for OpenVR compatibility. You are highly recommended to view view Monado’s page for more info.

As you need to set PRESSURE_VESSEL_IMPORT_OPENXR_1_RUNTIMES=1 for games to connect to the OpenXR runtime, it may be easier to set this in the Steam FHS through Nix:

programs.steam = {
  enable = true;
  package = pkgs.steam.override {
    extraProfile = ''
      # Fixes timezones on VRChat
      unset TZ
      # Allows Monado to be used
      export PRESSURE_VESSEL_IMPORT_OPENXR_1_RUNTIMES=1
    '';
  };
};

As on NixOS you’re most likely wanting to do things declaratively, here’s an example of how to set ~/.config/openvr/openvrpaths.vrpath to point to xrizer or OpenComposite using home-manager:

xdg.configFile."openvr/openvrpaths.vrpath".text = let
  steam = "${config.xdg.dataHome}/Steam";
in builtins.toJSON {
  version = 1;
  jsonid = "vrpathreg";

  external_drivers = null;
  config = [ "${steam}/config" ];

  log = [ "${steam}/logs" ];

  "runtime" = [
    "${pkgs.xrizer}/lib/xrizer"
    # OR
    #"${pkgs.opencomposite}/lib/opencomposite"
  ];
};

SteamVR #

SteamVR works like it does on other distros for the most part. Unfortunately, if it doesn’t work out of the box, troubleshooting it on NixOS can be close to impossible due to NixOS’s structure and SteamVR’s proprietary nature.

Asynchronous reprojection does not work without a kernel patch. However, this patch is only applicable for AMD GPUs. There is no way to get SteamVR asynchronous reprojection working on Nvidia.

setcap doesn’t work but can be done manually using sudo setcap CAP_SYS_NICE=eip ~/.local/share/Steam/steamapps/common/SteamVR/bin/linux64/vrcompositor-launcher.

WlxOverlay-S #

WlxOverlay-S will not run under SteamVR by running it normally, instead you need to run steam-run wlx-overlay-s. This is due to the Steam FHS stopping it from accessing certain things on NixOS.

Envision #

On NixOS it is highly recommended to not use Envision. Consider using the config options listed above.

Envision is packaged in nixpkgs but frequently breaks due to updates. It may also mess with your monado.service setup in unexpected ways.

Also, if you try to use Envision with a dedicated PCVR headset (i.e., Monado with an Index, Pimax, etc), asynchronous reprojection will not work without an AMD-only kernel patch, for the same reason as SteamVR.

Removing Envision #

In case you did not follow the above advice, and attempted to use Envision on NixOS, you may want to undo the changes it has made to your home folder, so services.monado, services.wivrn, opencomposite and/or xrizer may work correctly.

If you just want a 1-line command to just remove its stuff (and not read the rest of this section), then run:

rm ~/.config/openxr/1/active_runtime.json ~/.config/openvr/openvrpaths.vrpath

You will want to delete or modify ~/.config/openxr/1/active_runtime.json. Note that this is an override for /etc/xdg/openxr/1/active_runtime.json, so if you are using services.monado.defaultRuntime = true (or the WiVRn equivalent) then you can safely delete this file. Otherwise, you’ll want to point it to your Monado installation, which will be somewhere in /nix/store.

You will also want to modify ~/.config/openvr/openvrpaths.vrpath. Remove any runtimes that point to Envision’s compiled binaries.

It is recommend to use home-manager to automate writing these config files as mentioned above, as these paths will change regularly, due to the nature of NixOS.

VRChat & Resonite #

For some reason on NixOS, you may get lower performance on some social VR platforms than other distros, especially when a video player is present. There is currently no fix for this, and you are just recommended to disable the video player in your world.

Your time zone may not appear correctly, to fix this you can add unset TZ to your launch arguments (i.e. env -u TZ %command%).

Community Overlays #

  • nixpkgs-xr: provides overlays for the existing VR-related nixpkgs to use their git version, as well as adding a few new ones (see their readme for a full list). If the mainline packages are broken for you (whether it be compiling or in function) for any reason, adding this, as described in the readme, might help. It also provides XR-related packages considerably before they are available in NixOS.