Skip to content

nixos/x11/nvidia: screen tearing when using Vulkan on XWayland with Nvidia Prime Offloading #457588

Description

@PaulGrandperrin

Nixpkgs version

  • Unstable (25.11)

Describe the bug

I have a laptop with an intel iGPU and an NVidia dGPU in a muxless primus configuration.
I'm using the proprietary drivers and Wayland (cosmic).

Offloading OpenGL games to the nvidia card works flawlessly but causes terrible tearing when the game is using Vulkan.

It is not an issue with VSync but an issue with the synchronization between the nvidia card and the intel display controller (AFAIU): the tearing happens on a diagonal line from top left to bottom right and is much more jarring than vsync tearing. The tearing happens in windowed mode and fullscreen.

I didn't try using another distro but looking at internet forums it really seemed like an issue specific to NixOS or my configuration.

Long story short, after a long day debugging this issue, I found a solution and I want to share it for people encountering the same problem and potentially fixing it in NixOS itself.

Here's the solution:

services.xserver.exportConfiguration = true;

Here's my understanding of the issue:
When Xorg is used as the main display server, on NixOS, it does not use /etc/X11/xorg.conf but takes its conf directly from the launch arguments. This meant that /etc/X11/xorg.conf was unused and was removed to avoid confusing people about were Xorg was reading its conf from.
Now in the Wayland world, XWayland is launched by the wayland compositor and does not gives it the xorg.conf file as an argument, and since there's no /etc/X11/xorg.conf either, it means it doesn't have access to any config setup by "configuration.nix".
Enabling services.xserver.exportConfiguration restores /etc/X11/xorg.conf, which then fixes XWayland config which then fixes my tearing issues.

I think it was very much not obvious to find and fix this issue on my system and I think a solution should be made directly in NixOS.

Steps to reproduce

launch a vulkan program using xwayland using the nvidia driver

Expected behaviour

no tearing

Screenshots

No response

Relevant log output

Additional context

I had this issue for as long as I remember, this is not dependent on any particular version of linux, nvidia, wayland, cosmic or anything else.

System metadata

  • system: "x86_64-linux"
  • host os: Linux 6.16.12, NixOS, 25.11 (Xantusia), 25.11.20251028.08dacfc
  • multi-user?: yes
  • sandbox: yes
  • version: nix-env (Lix, like Nix) 2.93.3 System type: x86_64-linux Additional system types: aarch64-linux, i686-linux Features: gc, signed-caches System configuration file: /etc/nix/nix.conf User configuration files: /run/secrets/github-public-access-token Store directory: /nix/store State directory: /nix/var/nix Data directory: /nix/store/jsm35mkk7kp6yd268rfwhp4f1bs0h397-lix-2.93.3/share
  • channels(root): ""
  • nixpkgs: /nix/store/p6gvrb36n5dh0cdg6d77rkpapy5kc0gq-source

Notify maintainers

I haven't found a maintainer list so I'm pinging a few people who worked on nvidia.nix and xserver.nix: @edwtjo @Kiskae @getchoo @SuperSandro2000


Note for maintainers: Please tag this issue in your pull request description. (i.e. Resolves #ISSUE.)

I assert that this issue is relevant for Nixpkgs

Is this issue important to you?

Add a 👍 reaction to issues you find important.

Metadata

Metadata

Assignees

No one assigned

    Labels

    0.kind: bugSomething is broken2.status: stalehttps://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md6.topic: nixosIssues or PRs affecting NixOS modules, or package usability issues specific to NixOS

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions