Minecraft launcher in pure Nix. All MC versions!

7 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. minecraft-mods-on-nixos.adoc · GitHub

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 GitHub - nix-community/nixGL: A wrapper tool for nix OpenGL application [maintainer=@guibou] can help here.

Hello again. I started going through the fabric tutorials and with the recent updates I have been able to write a mod. There are two things that don’t seem to work.

Loading the narrator library

[22:24:52] [main/WARN]: ERROR : Couldn't load Narrator library : Unable to load library 'fliteWrapper': Native library (linux-x86-64/libfliteWrapper.so) not found in

And opening the sound device

[22:25:00] [main/ERROR]: Error starting SoundSystem. Turning off sounds & music
java.lang.IllegalStateException: Failed to open OpenAL device
	at net.minecraft.client.sound.SoundEngine.openDevice(SoundEngine.java:210) ~[minecraft-1.15.2-mapped-net.fabricmc.yarn-1.15.2+build.14-v2.jar:?]
	at net.minecraft.client.sound.SoundEngine.init(SoundEngine.java:135) ~[minecraft-1.15.2-mapped-net.fabricmc.yarn-1.15.2+build.14-v2.jar:?]
	at net.minecraft.client.sound.SoundSystem.start(SoundSystem.java:98) ~[minecraft-1.15.2-mapped-net.fabricmc.yarn-1.15.2+build.14-v2.jar:?]
	at net.minecraft.client.sound.SoundSystem.reloadSounds(SoundSystem.java:89) ~[minecraft-1.15.2-mapped-net.fabricmc.yarn-1.15.2+build.14-v2.jar:?]
	at net.minecraft.client.sound.SoundManager.apply(SoundManager.java:134) ~[minecraft-1.15.2-mapped-net.fabricmc.yarn-1.15.2+build.14-v2.jar:?]
	at net.minecraft.client.sound.SoundManager.apply(SoundManager.java:40) ~[minecraft-1.15.2-mapped-net.fabricmc.yarn-1.15.2+build.14-v2.jar:?]
	at net.minecraft.resource.SinglePreparationResourceReloadListener.method_18790(SinglePreparationResourceReloadListener.java:13) ~[minecraft-1.15.2-mapped-net.fabricmc.yarn-1.15.2+build.14-v2.jar:?]

I made some test using a simple python script, and I tested it can download all version of minecraft. Here the script:

import json

file = open("./version_manifest.json")
parsed = json.load(file)

for v in parsed["versions"]:
        id = v["id"]
        id_no_dot = id.replace(".", "_")
        print("nix-build all-minecrafts.nix -A versions.v{}.client -o minecraft/{}".format(id_no_dot, id))
1 Like

Is there a way to log in to a minecraft account when using the clients from this expression?

yes. For pirate servers I use two additional flags:

                --add-flags "--accessToken foobarbaz" \
                --add-flags "--server 0.0.0.0" \

Then at command line you can pass --username XXX --password YYY and add new online servers.

3 Likes

I’m not sure about the narrator issue, but on the sound device issue: try adding libX11 libXext to the libPath used – these are the only packages missing versus the library path used in the nixpkgs multimc package, and audio works fine for it.

You can provide the appropriate account credentials by passing --uuid, --username, --accessToken, --userType to Minecraft. You can see how to actually log in here: Legacy Mojang Authentication - wiki.vg.
I have no idea what you’re supposed to do if you’re using a Microsoft account though…

How did you load fabric with this?