How to solve `Could not initialize GLX` and similar errors? # Workaround (not recommended) ```bash export QT_XCB_GL_INTEGRATION=none ``` -- https://github.com/NixOS/nixpkgs/issues/82959#issuecomment-657306112 This a workaround that works most of the times, but what about a proper solution? # NixGL (recommended) ## Setup ```bash nix-channel --add https://github.com/nix-community/nixGL/archive/main.tar.gz nixgl && nix-channel --update nix-env -iA nixgl.auto.nixGLDefault ``` -- https://github.com/nix-community/nixGL?tab=readme-ov-file#nix-channel-recommended On some NVIDIA systems, it is necessary to force the loading of NVIDIA libraries by adding this line to `.bashrc` or similar: ```bash export __GLX_VENDOR_LIBRARY_NAME=nvidia ``` -- https://github.com/nix-community/nixGL/issues/177#issuecomment-2221756363 ## Run the app Run you apps as usual: ```bash nixGL nix-shell -p rstudio -p R --run rstudio ``` To avoid running each command using the `nixGL` wrapper, it is possible to set some environmental variables which will do the same (you might put them in your `shellHook`): ```bash library_path="$LD_LIBRARY_PATH" export $(env -i $(which nixGL) $(which printenv)) export LD_LIBRARY_PATH="$library_path:$LD_LIBRARY_PATH" ``` -- https://github.com/nix-community/nixGL/issues/46#issuecomment-2438400233