Minecraft launcher in pure Nix. All MC versions!

4 Likes

Hi,

Got the following error when installing/running minecraft:

	OpenGL: ~~ERROR~~ RuntimeException: No OpenGL context found in the current thread.
	GL Caps: 
	Using VBOs: No
	Is Modded: Probably not. Jar signature remains and client brand is untouched.
	Type: Client (map_client.txt)
	Resource Packs: 
	Current Language: ~~ERROR~~ NullPointerException: null
	Profiler Position: N/A (disabled)
	CPU: <unknown>

Any idea how to fix it ?

Hello. I have run into a similar problem when trying out mod development. This is how far I got. https://gist.github.com/moaxcp/2410aafb4b67733676d74e8bf6d0a96b

I never solved this problem but I would suggest looking into the minecraft package and see what it does to fix this. There is also the multi-mc package.

I didn’t do it here (because I don’t have custom mods), but for customs you should add a few java args to launcher:

   -Dorg.lwjgl.glfw.libname=$(nix-build '<nixpkgs>' -A glfw33 --no-out-link)/lib/libglfw.so \
   -Dorg.lwjgl.openal.libname=$(nix-build '<nixpkgs>' -A openal --no-out-link)/lib/libopenal.so \

where glfw33 is an updated version of glfw. I use this overlay (yeah, I know, I should upstream it to nixpkgs…):

self: super: {
    glfw33 = super.glfw3.overrideDerivation (old: rec {
        version = "3.3";
        name = "glfw-${version}";
        buildInputs = old.buildInputs ++ [
            self.xlibs.libXi.dev
            self.xlibs.libXext.dev
        ];
        src = super.fetchFromGitHub {
            owner = "glfw";
            repo = "GLFW";
            rev = "${version}";
            sha256 = "1f1hqpqffzg46z33ybs2c3akmkly7b3qmgp5byk50nvad6g2pm4p";
        };
    });
}

Some lwjgl packages try to unpack a shared library, which doesn’t work on NixOS. This -D option stops them from doing this.

PS. BTW, my intent is to launch add Forge and ComputerCraft using Nix. I’ll post an update if I ever manage to do that.

Can you pastebin full stacktrace, what is your videocard and show LD_LIBRARY_PATH? I think this is an issue with pkgs.libGL. I have pretty standard drivers (intel), so generic libGL works for me, but you may have custom drivers in LD_LIBRARY_PATH and this pkgs.libGL masks that.

Maybe https://github.com/guibou/nixGL can help here.