Minecraft can't load GLX

I’m using NixOS 24.05; and am trying to some modding with fabricmc.
As part of the process; I usually get a template from their website which has a build process and such setup already. The problem is with the runClient task. It’s supposed to run a test instance of minecraft with your mod loaded and a random playerID.

The problem is that I’m getting an error GLFW: GLX: Failed to load GLX
I’m on X11 and I’ve enabled openGL in my config. It doesn’t say this name of the shared library it’s trying to load (if that’s what it’s trying to do). So I’m stumped as to what to even add to LD_LIBRARY_PATH or nix-ld.

I found this post but the difference between me and them seems to be that lwjgl tries to load GLX on my end instead of libGL.so. Minecraft outside the dev environment runs fine.

If someone gives me a pointer to a way forward; I can do the rest on my own. Thanks for your attention.

Oh and the GLFW error number was 65542. This is the GLFW_API_UNAVAILABLE error, the description from the docs says:

The installed graphics driver does not support the requested API, or does not support it via the chosen context creation API. Below are a few examples.

Some pre-installed Windows graphics drivers do not support OpenGL. AMD only supports OpenGL ES via EGL, while Nvidia and Intel only support it via a WGL or GLX extension. macOS does not provide OpenGL ES at all. The Mesa EGL, OpenGL and OpenGL ES libraries do not interface with the Nvidia binary driver. Older graphics drivers do not support Vulkan.

The second paragraph does not apply to me I don’t think because Minecraft uses OpenGL 3.2

I haven’t tried developing Minecraft mods on NixOS yet, but I think you might have some luck with setting up your dev environment with the PATH and LD_LIBRARY_PATH set similar to how PrismLauncher does it.
Link: nixpkgs/pkgs/by-name/pr/prismlauncher/package.nix at 9295d8ef80cc9ee7f7bdfba801d63238e245a073 · NixOS/nixpkgs · GitHub

This is a bit late but I ran into the same issue which I was able to solve using the following shell.nix file to create a development shell to run the runClient task inside. You could easily modify this to work outside of a nix-shell by modifying the environment variable changed in the shellHook in your configuration.nix instead.

{ pkgs ? import <nixpkgs> {} }:
pkgs.mkShell {
  shellHook = ''
    export LD_LIBRARY_PATH="''${LD_LIBRARY_PATH}''${LD_LIBRARY_PATH:+:}${pkgs.libglvnd}/lib"
  '';
}

Place this file inside your mod directory and then run nix-shell before running ./gradlew runClient and Minecraft should start normally. Credit to this solution in the post you originally linked for the code which I modified slightly.

Ah so is that the package I was missing?

I tried putting quite a few packages in my LD_LIBRARY_PATH but none of them worked, I’m glad I found one that does. Will try this out when I am able to return to NixOS.