NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
17.98k stars 13.98k forks source link

Documentation: VirtualGL has no working examples #340636

Open meteokr opened 1 month ago

meteokr commented 1 month ago

Problem

I cannot find any examples of how to get VirtualGL to run with TurboVNC. The steps to reproduce my issue is that I have these relevent settings added in my configuration.nix.


    environment.systemPackages = with pkgs; [
      turbovnc
      virtualgl
    ];

    hardware.opengl.enable = true;
    hardware.opengl.driSupport32Bit = true;

    services.xserver.enable = true;

    services.xserver.displayManager.lightdm.enable = true;
    services.xserver.desktopManager.xfce.enable = true;

    networking.firewall.allowedTCPPorts = [ 5901 ];

This is the command used to start the server. vncserver -fg -geometry 800x600 -vgl -securitytypes none Results in output:

Desktop 'TurboVNC: hostname:1 (username)' started on display username:1

Starting applications specified in /nix/store/ag2k6m8dr633i0dhxl02810j3pqizzqx-turbovnc-3.1/bin/xstartup.turbovnc
(Enabling VirtualGL)
Log file is /home/username/.vnc/username:1.log

From another machine I connect to the VNC instance, and within the xterm window I run vglrun glxinfo.

vglrun glxinfo
name of display: :1
Authorization required, but no authorization protocol specified

[VGL] ERROR: Could not open display :0.

Here https://github.com/NixOS/nixpkgs/pull/195608 it seems to be that others are able to test VirtuaGL no problem, but what commands are they using to test this or how are their test configured? I can't seem to find any literature describing how to use this either from https://search.nixos.org/options?channel=24.05&from=0&size=50&sort=relevance&type=packages&query=virtualgl or https://nixos.wiki/index.php?search=virtualgl&go=Go

Upstream documentation doesn't support NixOS, and I unfortunately can't find anyone else attempting to use this with an actual GPU and not just using software rendering. I'm using a server with an AMD GPU so there's no Nvidia driver issues that should be affecting this.

Proposal

Document an example of how to use VirtualGL with some VNC server service with hardware acceleration.

Checklist


Add a :+1: reaction to issues you find important.

meteokr commented 1 week ago

I've managed to get this working, and I've done a write up on how here: https://discourse.nixos.org/t/looking-for-help-setting-up-virtualgl-with-turbovnc/51875/3

Basically the needed config is this:

    environment.systemPackages = with pkgs; [
      turbovnc
      virtualgl
      pkgsi686Linux.virtualgl
    ];

    environment.sessionVariables = {
      LD_LIBRARY_PATH="/run/opengl-driver/lib/:/run/opengl-driver-32/lib:${pkgs.virtualglLib}/lib:${pkgs.pkgsi686Linux.virtualglLib}/lib";
    };

    boot.extraModprobeConfig = ''
      options amdgpu virtual_display=0000:01:00.0,1
    '';

    services.displayManager.autoLogin = {
      enable = true;
      user = "testuser";
    };

    hardware.opengl.enable = true;
    hardware.opengl.driSupport32Bit = true;

    networking.firewall.allowedTCPPorts = [ 5901 ];

If this could be updated on the official wiki I would appreciate it to help anyone else trying to achieve this.

EDIT: Sorry for accidentally closing this, then reopening it. Hopefully that didn't ruffle anything. I meant to just update this issue with my results.