Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: openGL terminals not running on Pop!_OS #2251

Closed
1 task done
billewanick opened this issue Aug 4, 2021 · 12 comments
Closed
1 task done

bug: openGL terminals not running on Pop!_OS #2251

billewanick opened this issue Aug 4, 2021 · 12 comments
Assignees
Labels
bug triage Issues or feature request that have not been triaged yet

Comments

@billewanick
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Issue description

When using home-manager, on Pop_OS!, trying to use OpenGL terminals like kitty or alacritty runs into problems.

This happens even tho I have the correct verisons, and can run kitty and alacritty from the Pop Shop.

The errors I get, along with the opengl info is:

❯ which kitty
/home/bill/.nix-profile/bin/kitty
❯ which alacritty
/home/bill/.nix-profile/bin/alacritty
❯ glxinfo | grep 'version'
server glx version string: 1.4
client glx version string: 1.4
GLX version: 1.4
OpenGL core profile version string: 4.6.0 NVIDIA 470.57.02
OpenGL core profile shading language version string: 4.60 NVIDIA
OpenGL version string: 4.6.0 NVIDIA 470.57.02
OpenGL shading language version string: 4.60 NVIDIA
OpenGL ES profile version string: OpenGL ES 3.2 NVIDIA 470.57.02
OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.20
    GL_EXT_shader_group_vote, GL_EXT_shader_implicit_conversions,
❯ kitty
[216 10:07:43.750841] [glfw error 65542]: GLX: No GLXFBConfigs returned
[216 10:07:43.750880] [glfw error 65545]: GLX: Failed to find a suitable GLXFBConfig
[216 10:07:43.750889] Failed to create GLFW temp window! This usually happens because of old/broken OpenGL drivers. kitty requires working OpenGL 3.3 drivers.
❯ alacritty
Created log file at "/tmp/Alacritty-112755.log"
[2021-08-04 10:07:45.634404364] [ERROR] [alacritty] Alacritty encountered an unrecoverable error:

                                                    	Error creating GL context; Received multiple errors. Errors: `[OsError("Could not create EGL display object"), OsError("`glXQueryExtensionsString` found no glX extensions")]`

❯

Maintainer CC

No response

System information

- system: `"x86_64-linux"`
 - host os: `Linux 5.11.0-7620-generic, Pop!_OS, 21.04`
 - multi-user?: `no`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.3.15`
 - channels(bill): `"nixpkgs-21.11pre305800.2a6732c38df, home-manager"`
 - nixpkgs: `/home/bill/.nix-defexpr/channels/nixpkgs`
@billewanick billewanick added bug triage Issues or feature request that have not been triaged yet labels Aug 4, 2021
@sumnerevans
Copy link
Member

Have you restarted lately? I sometimes run into this and restarting fixes it.

@billewanick
Copy link
Author

I have restarted a few times, and I continue to see this error.
Is this a path issue? I can't find any openGL settings in the Appendix

@cole-h
Copy link
Member

cole-h commented Aug 4, 2021

You might want to look into nixGL.

@billewanick
Copy link
Author

Thanks for the link!
I can get those programs working with nixGL.

I also hadn't thought to test this without home-manager, but running nix-shell -p kitty alacritty and then trying either of them produce the same result.
This clearly isn't a home-manager issue and I'll file it elsewhere.

@cole-h
Copy link
Member

cole-h commented Aug 4, 2021

This problem has been around for quite a long time, see NixOS/nixpkgs#9415. Unfortunately, there doesn't seem to be an easy way to solve this (or, at least, nobody has put the time in).

@billewanick
Copy link
Author

Thanks for the link! This looks like an issue I encountered in a totally different context. Sucks that it's been around for so long.
I'll see if I can get the time to look into that more.

@terlar
Copy link
Contributor

terlar commented Aug 4, 2021

For whatever it is worth, I found that you don't get this issue if you also let Nix handle the GNOME session. I created the following script to achieve this:

{ pkgs, ... }:

let
  installGnomeSessionScript = pkgs.writeShellScriptBin "install-gnome-session" ''
    sudo ln -fs ${pkgs.gnome.gnome-session.sessions}/share/wayland-sessions/gnome.desktop /usr/share/wayland-sessions/gnome.desktop
    sudo ln -fs ${pkgs.gnome.gnome-session.sessions}/share/xsessions/gnome.desktop /usr/share/xsessions/gnome.desktop
  '';
in
{
      home.packages = [ installGnomeSessionScript ];
}

Then I run the command install-gnome-session to add it and then I choose it at the login screen for my user. When I run the session via the nixpkgs one, the OpenGL stuff works without any warpper. I was able to run both alacritty and kitty on Ubuntu by doing this.

Let me know if that is the case for you as well, then we might be able to spread this information further.

@billewanick
Copy link
Author

@terlar I am unable to successfully test your suggestion.
When I switch to any other desktop environment my screen goes black and stays that way.
This includes GNOME, as well as the Pop!_OS supported DEs I've tried
Thanks for the suggestion, I will continue to try and troubleshoot my system

@terlar
Copy link
Contributor

terlar commented Aug 9, 2021

You should be able to change DEs like that, at least it has worked for me on Ubuntu. However now on a second try it seems it didn't fix the OpenGL stuff. I might have missed it since I have an overlay that patches packages, I thought I had tried without it but now when I did it didn't work, so seems nixGL might be the solution after all. Sorry to waste your time.

The overlay solution is like this instead:

let
  nixGLOverlay = final: prev: let
    nixGL = import inputs.nixGL { pkgs = final; };
    wrapWithNixGL = wrapper: package:
      let
        getBinFiles = pkg:
          lib.pipe "${lib.getBin pkg}/bin" [
            readDir
            attrNames
            (filter (n: match "^\\..*" n == null))
          ];

        wrapperBin = lib.pipe wrapper [
          getBinFiles
          (filter (n: n == (lib.getName wrapper)))
          head
          (x: "${wrapper}/bin/${x}")
        ];

        binFiles = getBinFiles package;
        wrapBin = name:
          final.writeShellScriptBin name ''
            exec ${wrapperBin} ${package}/bin/${name} "$@"
          '';
      in
      final.symlinkJoin {
        name = "${package.name}-nixgl";
        paths = (map wrapBin binFiles) ++ [ package ];
      };

    wrappers =
      let
        replacePrefix =
          replaceStrings [ "wrapWithNixGL" ] [ "nixGL" ];
      in
      lib.genAttrs [
        "wrapWithNixGLNvidia"
        "wrapWithNixGLIntel"
        "wrapWithNixGLDefault"
      ]
        (name: wrapWithNixGL final.${replacePrefix name});
  in
  {
    inherit (nixGL) nixGLNvidia nixGLIntel nixGLDefault;
    inherit wrapWithNixGL;
  } // wrappers;
in {
   homeConfigurations = {
     myuser =
       let
         system = "x86_64-linux";
         openglWrappedOverlay = final: prev:
           lib.genAttrs [ "kitty" "qutebrowser" ]
             (name: prev.wrapWithNixGLIntel prev.${name});
       in
       home-manager.homeManagerConfiguration {
         username = "myuser";
         inherit system;
         pkgs = import nixpkgs {
           inherit system;
           overlays = [ nixGLOverlay openglWrappedOverlay ];
         };

         configuration = { pkgs, ... }: {
           home.packages = [ pkgs.kitty pkgs.qutebrowser ];
         };
       };
   };
}

Not a beauty, but has worked well for me.

yurrriq added a commit to yurrriq/dotfiles that referenced this issue Mar 1, 2023
@izelnakri
Copy link

izelnakri commented Oct 2, 2023

an improvement over the @terlar s solution is to have 3 nixGLOverlay functions with overlayWithNixGLNvidia, overlayWithNixGLIntel and overlayWithNixGLDefault. Then apart from the internal implementation, the end-user(the developer) only needs to change one line with a single custom function call instead of 2 custom references(openglWrappedOverlay, nixGLOverlay).

I wish this was possible on home-manager layer though, I don't think this issue should stay closed. @billewanick could you reopen this? I think many people come across it and I think this can absolutely be accomplished on home-manager layer for DX.

@cole-h
Copy link
Member

cole-h commented Oct 2, 2023

This issue has been closed for ~2 years and was originally about a (real or perceived) bug. I feel it would be more appropriate if you were to open a new issue to discuss what you think should / could be done in home-mananger.

@leiserfg
Copy link

leiserfg commented Nov 7, 2023

What I do, and yes it's not pure but "it works" is to inject all the GPU related variables in the environment. With that I can even run sway from nixpkgs on top of debian.
You can see my hack here, originally based on nixGL but with way more variables now (to make opencl, vulkan and egl work).
https://github.com/leiserfg/nix-config/blob/wayland/home/leiserfg/features/mesa.nix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug triage Issues or feature request that have not been triaged yet
Projects
None yet
Development

No branches or pull requests

8 participants