!aRKdLCkUeIFjRPZuJT:nixos.org

NixOS JVM

72 Members
18 Servers

Load older messages


SenderMessageTime
6 Jul 2024
@devurandom:matrix.orgDennis Hi! In NixOS, is there a way to install multiple JDKs next to each other, and have the "default" (providing the java command) selected by programs.java, but still be able to point some programs (like gradle) to another JDK? 20:15:17
@devurandom:matrix.orgDennis *

Hi!

In NixOS, is there a way to install multiple JDKs next to each other, and have the "default" (providing the java command) selected by programs.java, but still be able to point some programs (like gradle) to another JDK?

I tried setting programs.java.enabled = true (which installs JDK 21) and environment.systemPackages = [jdk22] (to get JDK 22 in addition), but now my java --version reports v22, with apparently no way to make it point to v21.

20:18:43
@infinidoge:inx.moeInfinidoge 🏳️‍⚧️To my knowledge, there unfortunately isn't a system to do this across a system environment20:23:29
@infinidoge:inx.moeInfinidoge 🏳️‍⚧️(Namely because you can only (really) have 1 copy of something in the path)20:24:25
@infinidoge:inx.moeInfinidoge 🏳️‍⚧️Multiple Java versions on Linux in other distros is kinda an illusion, in that they are just switching which version is properly installed though things like apt's alternatives, then setting a different JAVA_HOME20:25:07
@infinidoge:inx.moeInfinidoge 🏳️‍⚧️ * Multiple Java versions on Linux in other distros is kinda an illusion, in that they are just switching which version is properly installed though things like apt's alternatives, then setting a different JAVA_HOME and PATH 20:26:06
@infinidoge:inx.moeInfinidoge 🏳️‍⚧️If you want to have a different version for gradle in a project-specific manner, setting up a devshell would likely be the best option20:26:39
@devurandom:matrix.orgDennisThanks! I just found https://github.com/NixOS/nixpkgs/pull/119444 and that seems to do the trick / work well enough for my specific use case.20:30:09
@infinidoge:inx.moeInfinidoge 🏳️‍⚧️Neat, good to know20:31:10
@devurandom:matrix.orgDennis Hm, the build succeeded, but now I have a different issue: Loading library prism_es2 from resource failed: java.lang.UnsatisfiedLinkError: /home/[USER]/.openjfx/cache/21.0.1+6/amd64/libprism_es2.so: libXxf86vm.so.1: cannot open shared object file: No such file or directory.
Any idea how to solve that? I guess if I could get it to use the NixOS OpenJFX...
20:45:21
@infinidoge:inx.moeInfinidoge 🏳️‍⚧️ Try adding xorg.libXxf86vm to your system packages 20:48:27
@infinidoge:inx.moeInfinidoge 🏳️‍⚧️Using the Nixpkgs OpenJFX would be the better solution20:48:38
7 Jul 2024
@devurandom:matrix.orgDennis I do not know much about OpenJFX. How can I make gradle run run the application with a different OpenJFX implementation? Does that need modifications to the build.gradle script? 00:18:25
@infinidoge:inx.moeInfinidoge 🏳️‍⚧️Unfortunately I don't know much about JFX either, so I'd have to do some tinkering to figure it out03:44:45
@infinidoge:inx.moeInfinidoge 🏳️‍⚧️(And I have a midterm Monday so unfortunately I don't have the time to dig into it at the moment)03:45:11
@devurandom:matrix.orgDennis

Thanks!

I found docs that seem promising: https://github.com/openjfx/javafx-gradle-plugin?tab=readme-ov-file#5-using-a-local-javafx-sdk

However I noticed that after nix-collect-garbage nothing in /run/current-system or /nix/store remains of jfx / javafx. Of the openjfx packages only some drv files remain:

❯ ls /nix/store/*openjfx*
   #                                                 name                                                  type      size         modified
   0   /nix/store/0451pbbdphkz64rfz9f7j6vv38ar80rp-openjfx-deps-22.0.1-ga.drv                             file       4.2 KiB   54 years ago
   1   /nix/store/385rb03mfsfsz7536qzy96cvvamwvwgk-openjfx-deps-21.0.3-ga.drv                             file       4.4 KiB   54 years ago
   2   /nix/store/604ghwk9gy9yxz17yrlrm7nr60qv2iwk-openjfx-modular-sdk-22.0.1-ga_fish-completions.drv     file       2.1 KiB   54 years ago
   3   /nix/store/qrm093p68pzdrd8h9jvqzcdpq0zafnwi-openjfx-modular-sdk-21.0.3-ga.drv                      file       5.1 KiB   54 years ago
   4   /nix/store/v2k5drzq7k6m316n7998616fqyricmv1-openjfx-modular-sdk-22.0.1-ga.drv                      file       4.9 KiB   54 years ago
   5   /nix/store/vbdsg55wkkkbi5n1x2f5dq9x287bksfc-openjfx-modular-sdk-21.0.3-ga_fish-completions.drv     file       2.1 KiB   54 years ago

Is this because I have no application installed that uses these packages? So Nix ignores systemPackages and believes the package is not needed?

14:20:04
@infinidoge:inx.moeInfinidoge 🏳️‍⚧️How- How did matrix put that message in between July 6th messages14:20:55
@infinidoge:inx.moeInfinidoge 🏳️‍⚧️SmartSelect_20240707_102112_SchildiChat.jpg
Download SmartSelect_20240707_102112_SchildiChat.jpg
14:21:32
@infinidoge:inx.moeInfinidoge 🏳️‍⚧️SmartSelect_20240707_102122_SchildiChat.jpg
Download SmartSelect_20240707_102122_SchildiChat.jpg
14:21:33
@infinidoge:inx.moeInfinidoge 🏳️‍⚧️
In reply to @devurandom:matrix.org

Thanks!

I found docs that seem promising: https://github.com/openjfx/javafx-gradle-plugin?tab=readme-ov-file#5-using-a-local-javafx-sdk

However I noticed that after nix-collect-garbage nothing in /run/current-system or /nix/store remains of jfx / javafx. Of the openjfx packages only some drv files remain:

❯ ls /nix/store/*openjfx*
   #                                                 name                                                  type      size         modified
   0   /nix/store/0451pbbdphkz64rfz9f7j6vv38ar80rp-openjfx-deps-22.0.1-ga.drv                             file       4.2 KiB   54 years ago
   1   /nix/store/385rb03mfsfsz7536qzy96cvvamwvwgk-openjfx-deps-21.0.3-ga.drv                             file       4.4 KiB   54 years ago
   2   /nix/store/604ghwk9gy9yxz17yrlrm7nr60qv2iwk-openjfx-modular-sdk-22.0.1-ga_fish-completions.drv     file       2.1 KiB   54 years ago
   3   /nix/store/qrm093p68pzdrd8h9jvqzcdpq0zafnwi-openjfx-modular-sdk-21.0.3-ga.drv                      file       5.1 KiB   54 years ago
   4   /nix/store/v2k5drzq7k6m316n7998616fqyricmv1-openjfx-modular-sdk-22.0.1-ga.drv                      file       4.9 KiB   54 years ago
   5   /nix/store/vbdsg55wkkkbi5n1x2f5dq9x287bksfc-openjfx-modular-sdk-21.0.3-ga_fish-completions.drv     file       2.1 KiB   54 years ago

Is this because I have no application installed that uses these packages? So Nix ignores systemPackages and believes the package is not needed?

More specifically, it gets garbage collected because it isn't listed as a garbage collection root. I believe there is a nix store command to add it manually, or you can use something like system.extraDependencies to include it in your NixOS configuration
14:23:42
@infinidoge:inx.moeInfinidoge 🏳️‍⚧️It's not an ideal solution, referring to nix store paths explicitly isn't generally recommended, but it does work at least14:24:31
@devurandom:matrix.orgDennis Thanks! Why did that not happen to other packages in systemPackages? Because they install sth into /run/current-system? 14:25:12
@infinidoge:inx.moeInfinidoge 🏳️‍⚧️
In reply to @devurandom:matrix.org
Thanks! Why did that not happen to other packages in systemPackages? Because they install sth into /run/current-system?
Yes. Everything that is installed in the system is part of the "closure", which is marked as a garbage collection root, so it doesn't get cleaned up
14:26:14
@infinidoge:inx.moeInfinidoge 🏳️‍⚧️(It wouldn't be very good if you garbage collected all of the stuff your system needed to run lol)14:26:34
@devurandom:matrix.orgDennis

Sadly this does not work. The Gradle JavaFX plugin can take the path to the JavaFX SDK, but that SDK contains JARs and shared objects, while javaPackages.openjfx21 (and 22) contains the raw class files in one directory and the shared object in a separate directory (not sure how the classes will later find them). The JavaFX plugin just says Could not find org.openjfx:javafx-base:..

Maybe I have to write a Nix derivation to make this work?

14:47:04
@devurandom:matrix.orgDennis *

Sadly this does not work. The Gradle JavaFX plugin can take the path to the JavaFX SDK, but that SDK contains JARs and shared objects, while javaPackages.openjfx21 (and 22) contains the raw class files in one directory and the shared object in a separate directory (not sure how the classes will later find them). The JavaFX plugin says Could not find org.openjfx:javafx-base:..

Maybe I have to write a Nix derivation to make this work?

14:55:13
@devurandom:matrix.orgDennis *

Sadly this does not work. The Gradle JavaFX plugin can take the path to the JavaFX SDK, but that SDK contains JARs and shared objects, while javaPackages.openjfx21 (and 22) contains the raw class files in one directory and the shared object in a separate directory (not sure how the classes will later find them). The JavaFX plugin says Could not find org.openjfx:javafx-base:..

Maybe I have to write a Nix package to make this work?

19:53:05
@devurandom:matrix.orgDennis Next attempt also failed.
In my nixos config I am now at (gradle.override { javaToolchains = [ (jdk21.override { enableJavaFX = true; }) ]; }), but when I pass sdk = ... to the javafx plugin in build.gradle, it tries to find javafx as JARs (to put them on the classpath?), while the JDK contains jmods.
20:30:14
9 Jul 2024
@sbc64:matrix.orgsbc64 joined the room.16:48:46
23 Jul 2024
@ezzobirbezziou:matrix.orgEzzobir Bezziou joined the room.08:20:04

There are no newer messages yet.


Back to Room ListRoom Version: 6