Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Java Template installs wrong JDK #55

Closed
vbrandl opened this issue Aug 13, 2024 · 1 comment · Fixed by #54
Closed

Java Template installs wrong JDK #55

vbrandl opened this issue Aug 13, 2024 · 1 comment · Fixed by #54

Comments

@vbrandl
Copy link

vbrandl commented Aug 13, 2024

The template for Java projects seems to install the wrong JDK.

I'm using the following flake.nix on NixOS/nixpkgs@a58bc8a:

{
  description = "A very basic flake";

  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
  };

  outputs = { self, nixpkgs }:
  let
    javaVersion = 22;
    supportedSystems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ];
    forEachSupportedSystem = f: nixpkgs.lib.genAttrs supportedSystems (system: f {
      pkgs = import nixpkgs { inherit system; };
    });
  in
  {
    overlays.default =
      final: prev: rec {
        jdk = prev."jdk${toString javaVersion}";
        maven = prev.maven.override { jre = jdk; };
      };

    devShells = forEachSupportedSystem ({ pkgs }: {
        default = pkgs.mkShell {
          packages = with pkgs; [ jdk maven ];
          MAVEN_OPTS = "--enable-preview";
        };
      });
  };
}

When I run nix shell .\#devShells.x86_64-linux.default (or activate the shell using direnv with use flake) and run java --version, I get openjdk 21.0.3 2024-04-16 instead of the expected Java 22.

My guess is, this is using the jdk package from nixpkgs, which is Java 21, instead of the jdk package from the overlay, which should be Java 22.

I'm not quite sure how to tell my flake to use the overlay...

Edit: Merging #53, #54 applying my comment from #54 seems to fix the issue for me.

@hatch01
Copy link

hatch01 commented Sep 5, 2024

I am having the same issue, would love to see those PR merged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants