NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
17.51k stars 13.68k forks source link

godot_4: fails to run in non-NixOS system likely due to missing OpenGL runtime dependency #336400

Closed peacememories closed 1 month ago

peacememories commented 1 month ago

Describe the bug

When using Godot 4.3 from nix flakes on a non-nixos installation, the game crashes with the following output:

Godot Engine v4.3.stable.nixpkgs.77dcf97d8 - https://godotengine.org
ERROR: Parameter "fbc" is null.
   at: _create_context (platform/linuxbsd/x11/gl_manager_x11.cpp:162)
WARNING: Your video card drivers seem not to support the required OpenGL version, switching to OpenGLES.
     at: DisplayServerX11 (platform/linuxbsd/x11/display_server_x11.cpp:6232)
WARNING: EGL: EGL_EXT_platform_base not found during init, using default platform.
     at: initialize (drivers/egl/egl_manager.cpp:375)

================================================================
handle_crash: Program crashed with signal 11
Engine version: Godot Engine v4.3.stable.nixpkgs (77dcf97d82cbfe4e4615475fa52ca03da645dbd8)
Dumping the backtrace. Please include this when reporting the bug to the project developer.
[1] /nix/store/5adwdl39g3k9a2j0qadvirnliv4r7pwd-glibc-2.39-52/lib/libc.so.6(+0x405c0) [0x7f538ea035c0] (??:0)
[2] godot4() [0x1297518] (??:0)
[3] godot4() [0x4ca5ce] (??:0)
[4] godot4() [0x4cb066] (??:0)
[5] godot4() [0x4715eca] (??:0)
[6] godot4() [0x47ae483] (??:0)
[7] godot4() [0x470d002] (??:0)
[8] godot4() [0x421295] (??:0)
[9] /nix/store/5adwdl39g3k9a2j0qadvirnliv4r7pwd-glibc-2.39-52/lib/libc.so.6(+0x2a14e) [0x7f538e9ed14e] (??:0)
[10] /nix/store/5adwdl39g3k9a2j0qadvirnliv4r7pwd-glibc-2.39-52/lib/libc.so.6(__libc_start_main+0x89) [0x7f538e9ed209] (??:0)
[11] godot4() [0x43e615] (??:0)
-- END OF BACKTRACE --
================================================================
fish: Job 1, 'godot4' terminated by signal SIGABRT (Abort)

Steps To Reproduce

Steps to reproduce the behavior:

  1. Install nix on Bazzite (I assume this is true for other distros as well)
  2. run nix run nixpkgs#godot_4

Expected behavior

The Godot 4 project selection screen should open.

Additional context

It seems that this is caused by some of the opengl/mesa runtime missing. This discussion seems to revolve around a similar problem, but the solution is not applicable for me since I do not have a NixOS configuration.

Maybe Bazzite does not expose the right egl runtime features, but I don't know how to check that right now and I would also assume Nix would install its own version of mesa or whatever the application needs.

Notify maintainers

@shiryel @superherointj

Metadata

fetching github input 'github:NixOS/nixpkgs/nixpkgs-unstable'
these 2 paths will be fetched (0.02 MiB download, 0.06 MiB unpacked):
  /nix/store/2i8ml3prk338gmf6zfzy6z1pazifdy57-nix-info
  /nix/store/hix7sl0wxajb5aq14afjdvzc3w0i8b14-stdenv-linux
copying path '/nix/store/2i8ml3prk338gmf6zfzy6z1pazifdy57-nix-info' from 'https://cache.nixos.org'...
copying path '/nix/store/hix7sl0wxajb5aq14afjdvzc3w0i8b14-stdenv-linux' from 'https://cache.nixos.org'...
 - system: `"x86_64-linux"`
 - host os: `Linux 6.10.4-201.fsync.fc40.x86_64, Bazzite, 40.20240819.0 (Kinoite), 9633da0`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Lix, like Nix) 2.90.0`
 - nixpkgs: `/nix/store/2d55is03vs1fkfyyklqfjcfwibjgfm6f-source`

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

peacememories commented 1 month ago

I tried three more things:

  1. Running godot in native wayland mode crashes with more messages, but in essence the same error:
Godot Engine v4.3.stable.nixpkgs.77dcf97d8 - https://godotengine.org
WARNING: EGL: EGL_EXT_platform_base not found during init, using default platform.
     at: initialize (drivers/egl/egl_manager.cpp:375)
ERROR: Can't get a valid initial EGL display.
   at: initialize (drivers/egl/egl_manager.cpp:382)
WARNING: Your video card drivers seem not to support the required OpenGL version, switching to OpenGLES.
     at: DisplayServerWayland (platform/linuxbsd/wayland/display_server_wayland.cpp:1430)
WARNING: EGL: EGL_EXT_platform_base not found during init, using default platform.
     at: initialize (drivers/egl/egl_manager.cpp:375)
ERROR: Can't get a valid initial EGL display.
   at: initialize (drivers/egl/egl_manager.cpp:382)
ERROR: Could not initialize GLES3.
   at: DisplayServerWayland (platform/linuxbsd/wayland/display_server_wayland.cpp:1448)
ERROR: Can't create the Wayland display server.
   at: create_func (platform/linuxbsd/wayland/display_server_wayland.cpp:1311)
ERROR: Parameter "fbc" is null.
   at: _create_context (platform/linuxbsd/x11/gl_manager_x11.cpp:162)
WARNING: Your video card drivers seem not to support the required OpenGL version, switching to OpenGLES.
     at: DisplayServerX11 (platform/linuxbsd/x11/display_server_x11.cpp:6232)
WARNING: EGL: EGL_EXT_platform_base not found during init, using default platform.
     at: initialize (drivers/egl/egl_manager.cpp:375)

================================================================
handle_crash: Program crashed with signal 11
Engine version: Godot Engine v4.3.stable.nixpkgs (77dcf97d82cbfe4e4615475fa52ca03da645dbd8)
Dumping the backtrace. Please include this when reporting the bug to the project developer.
[1] /nix/store/5adwdl39g3k9a2j0qadvirnliv4r7pwd-glibc-2.39-52/lib/libc.so.6(+0x405c0) [0x7fcb80f395c0] (??:0)
[2] /nix/store/j0j1b9vavls87mds02mjdl7ayjfawby3-godot4-4.3-stable/bin/godot4() [0x1297518] (??:0)
[3] /nix/store/j0j1b9vavls87mds02mjdl7ayjfawby3-godot4-4.3-stable/bin/godot4() [0x4ca5ce] (??:0)
[4] /nix/store/j0j1b9vavls87mds02mjdl7ayjfawby3-godot4-4.3-stable/bin/godot4() [0x4cb066] (??:0)
[5] /nix/store/j0j1b9vavls87mds02mjdl7ayjfawby3-godot4-4.3-stable/bin/godot4() [0x4715eca] (??:0)
[6] /nix/store/j0j1b9vavls87mds02mjdl7ayjfawby3-godot4-4.3-stable/bin/godot4() [0x47b046c] (??:0)
[7] /nix/store/j0j1b9vavls87mds02mjdl7ayjfawby3-godot4-4.3-stable/bin/godot4() [0x470d002] (??:0)
[8] /nix/store/j0j1b9vavls87mds02mjdl7ayjfawby3-godot4-4.3-stable/bin/godot4() [0x421295] (??:0)
[9] /nix/store/5adwdl39g3k9a2j0qadvirnliv4r7pwd-glibc-2.39-52/lib/libc.so.6(+0x2a14e) [0x7fcb80f2314e] (??:0)
[10] /nix/store/5adwdl39g3k9a2j0qadvirnliv4r7pwd-glibc-2.39-52/lib/libc.so.6(__libc_start_main+0x89) [0x7fcb80f23209] (??:0)
[11] /nix/store/j0j1b9vavls87mds02mjdl7ayjfawby3-godot4-4.3-stable/bin/godot4() [0x43e615] (??:0)
-- END OF BACKTRACE --
================================================================
fish: Job 1, 'nix run nixpkgs#godot_4 -- --di…' terminated by signal SIGABRT (Abort)
  1. Installing and running Godot via Flatpak works fine
  2. Downloading and running the official Godot executable also works fine. This makes it pretty unlikely that my Bazzite install is missing some runtime components for Godot to work that cannot be provided by nixpkgs.
PedroHLC commented 1 month ago

Are you running it from a non-NixOS distro? Then you might need https://github.com/nix-community/nixGL

peacememories commented 1 month ago

Are you running it from a non-NixOS distro? Then you might need https://github.com/nix-community/nixGL

This does indeed work, thank you for the info!

Just to make sure I understand the problem: The issue is, that nixpkgs cannot patchelf in the "correct" version of mesa, etc, because I can't guarantee which graphics driver will actually be used to run the application, so nixOS just adds the current running driver's mesa library to LD_LIBRARY_PATH which can then be found by applications. Since I'm not running nixOS on this machine, nothing performs this step, hence Godot falls over?

Is there a way to teach home manager to add the correct LD_LIBRARY_PATH values to all of my shells? I'm looking for a way to avoid running the nixGLIntel wrapper because I need to give the Godot executable name to emacs (for language server reasons) and I don't think that will play well with a wrapper :sweat_smile:

Thanks in any case, I learned something new today :)

PedroHLC commented 1 month ago

There are many approaches to integrating it with home-manager: https://github.com/nix-community/home-manager/issues/3968. Even though they don't operate the way you described, it might help you.

You could try playing with home.sessionVariables for home-manager and https://github.com/nix-community/nix-direnv with https://nixos.org/manual/nixpkgs/unstable/#sec-pkgs-mkShell (or devenv.sh) to automate injecting it on shells, but I guess it might break the host's apps.