Help setting up a BTA! modding environment

getting this error:

Unpacked JDK archive does not contain a Java home: /home/gobbe/.gradle/.tmp/jdks/OpenJDK21U-jdk_x64_linux_hotspot_21-Eclipse-Temurin-2111441753919758025703.tmp

Installing Java through Home Manager, but unsure if JAVA_HOME is properly set

programs.java = {
    enable = true;
    package = pkgs.jdk17;
# it says it sets home.sessionVariables.JAVA_HOME = "${cfg.package.home}";
# but unsure if IDEA/gradle finds this $JAVA_HOME
 };

installing IDEA with:

export NIXPKGS_ALLOW_UNFREE=1
nix-shell -p jetbrains.idea

tried using the BTA! mod template on codeberg ( gobbe/bta-test: det rullar nu? - Codeberg.org ) and github ( GitHub - Turnip-Labs/bta-example-mod: Fabric example mod for BTA · GitHub ), talked to the devs and they say they’ve never seen an error like this before. Both these examples work on a windows machine. Both produce the same error on NixOS

In other words, I opened IDEA, cloned either repo A or B. Waited for imports, then restarted IDEA. Error.

wondering what dependancies I should tweak or env-vars I should add to let gradle see java home

*could also be that gradle atm is doing auto-install of java, and that java doesn’t have a proper nixos $JAVA_HOME - if so I wonder how to set gradle up to use a current install of java.

Either way have struggled with this awhile and heard others also have had this issue so wondering if there are any solutions :slight_smile:

Not sure if I will be able to help, but have you tried echo $JAVA_HOME ?

And what happens on a hello-world java project ?

Also it’s not very clear how you reach this error, and were it comes from
Could you give the steps in chronological order ?

And “BTA!” is the mod “Better Than Adventure” for minecraft, right ?

Yes, sorry for being unclear with BTA! I am reffering to Better than adventure :³

running echo $JAVA_HOME returns nothing atm /:

At the moment the steps I took to get this error where

  1. Install Java (17) through home manager
  2. Install jetbrains.idea with a nix-shell
  3. Clone the example repo
  4. Open it with IDEA and let it load
  5. Restart IDEA

Then error

So:

  1. Where is the error printed ?
  2. It works perfectly fine the first time ?

If I were you I would now look into what JAVA_HOME is, and what home.sessionVariables.JAVA_HOME (if you don’t already)
As I personnally do not, I can’t help you on this front

Oh and also the original error does not point at the nix store, could you check if it’s a symlink to it ?

When I wanted to do some MC dev work, I used a devshell, that worked.

There might be some things you don’t need in there, so some experimentation might be required on your part.

The main takeaway is that you can tell gradle where the JDKs it needs are at with these lines in your gradle.properties

org.gradle.java.installations.auto-download=false
org.gradle.java.installations.fromEnv=JDK8,JDK17,JDK21,JDK25

which is documented here.

The reason I specifically have the Zulu JDK in there is because I was working with GTNH RFB, which aggressively wanted to download its own jdk and was only content with Zulu (I did not and still do not know enough to disable foojay-resolver or whatever it is called).

See my flake attached, maybe it helps you. I used direnv and launched intellij from the shell, but entering the shell with nix shell or using the direnv intellij plugin might also work, YMMV.

Nix flake
{
  description = "mc intellij flake";

  inputs = {
    nixpkgs.url = "https://channels.nixos.org/nixos-unstable/nixexprs.tar.zst";
  };

  outputs =
    { self, nixpkgs, ... }@inputs:
    let
      system = "x86_64-linux";
      pkgs = nixpkgs.legacyPackages.${system};
    in
    {
      devShells.${system}.default = pkgs.mkShell {
        packages = with pkgs; [
          zulu25
          zulu21
          zulu17
          zulu8
          gradle_9
          jetbrains.idea-oss
          xrandr
        ];
        shellHook = "echo 'happy hacking'";
        JDK8 = "${pkgs.zulu8}";
        JDK17 = "${pkgs.zulu17}";
        JDK25 = "${pkgs.zulu25}";
        JDK21 = "${pkgs.zulu21}";
        JDKJB = "${pkgs.jetbrains.jdk-no-jcef}";
        LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath (
          with pkgs;
          [
            glfw3-minecraft
            libGL
            libX11
            libXcursor
            libXext
            libXrandr
            libXxf86vm
            libjack2
            libpulseaudio
            libusb1
            openal
            xrandr
          ]
        );
      };

    };
}