NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
18.05k stars 14.08k forks source link

leiningen always uses java from package 'jdk" #306267

Closed behrica closed 6 months ago

behrica commented 6 months ago

Describe the bug

I would like to use leiningen and decide the jdk version its using

Steps To Reproduce

Steps to reproduce the behavior:

  1. install package leiningen
  2. install alternative jdk, for example: jdk21
  3. force JAVA used by leiningen version via: JAVA_HOME=/nix/store/iqz8lfhx69qxb0ydixfldsf0wiw87q34-openjdk-21+35 lein version

Expected behavior

java 21 should get reported and used Leiningen 2.10.0 on Java 21

found behaviour

default jdk is used: Leiningen 2.10.0 on Java 19.0.2

Metadata

Please run nix-shell -p nix-info --run "nix-info -m" and paste the result.

[user@system:~]$ nix-shell -p nix-info --run "nix-info -m"
- system: `"x86_64-linux"`
 - host os: `Linux 6.1.84, NixOS, 23.11 (Tapir), 23.11.5987.d272ca50d1f7`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.18.1`
 - channels(root): `"home-manager-23.11.tar.gz, nixos-23.11, unstable"`
 - channels(carsten): `""`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`
behrica commented 6 months ago

jdk seems to be "hardcoded" by ths line: https://github.com/NixOS/nixpkgs/blob/4c62c9792c90c78a6029b49d3a91f1bb733afaba/pkgs/development/tools/build-managers/leiningen/default.nix#L24

Shawn8901 commented 6 months ago

You should be able to override jdk argument, with your desired java version, as long as it's compatible to leiningen. Be aware that this will result in a cache miss and you will need to build it on your machine.

So

(pkgs.leinigen.override { jdk = pkgs.jdk19; })

It's handwritten on smartphone, so might need small adjustments, but that should override the jdk. Jdk19 should be replaced with the jdk you plan to use.

Idk leiningen, by I would also more suspect the JAVA_CMD few lines later to control the used java version, not the propagatedBuildInput.

behrica commented 6 months ago

Thanks @Shawn8901 , it solved it.