Infinidoge / nix-minecraft

An attempt to better support Minecraft-related content for the Nix ecosystem
MIT License
172 stars 18 forks source link

Document how to change java package #64

Open darichey opened 1 month ago

darichey commented 1 month ago

Minecraft 1.20.5+ requires Java 21, but jre_headless in nixpkgs 23.11 is Java 19. This causes the server to fail to start with an error like

net/minecraft/bundler/Main has been compiled by a more recent version of the Java Runtime (class file version 65.0), this version of the Java Runtime only recognizes class file versions up to 63.0

This can be fixed by overriding the jre_headless input to the desired server package like

package = pkgs.fabricServers.fabric-1_20_6.override {
  jre_headless = pkgs.temurin-jre-bin-21;
};

Maybe this could be made more convenient with some kind of javaPackage option? Either way, it would be great to document a recommended approach.

I see that you probably already noticed some related issue here with https://github.com/Infinidoge/nix-minecraft/commit/d9ca459b3b87d2639407cef26bb8e94a1314f40e.

Infinidoge commented 1 month ago

Yeah, I did notice this issue, which ended up being """fixed""" by me bumping the nixpkgs revision both for nix-minecraft and in my system configuration. Ideally this should be fixed by requesting the proper version in nix-minecraft explicitly, as opposed to setting it. (I.e., nix-minecraft will explicitly gran jdk 8/17/21 instead of 8 or 'latest')

I do agree that this should be documented though, especially in the event that someone wants to use a custom version of Java for whatever reason.

Making the input javaPackage ? jre_headless (this you use .override { javaPackage = ...; } instead) would be small but nice.