HanSolo / JDK-Updater

A little tool written in Swift that will help you keeping your builds of OpenJDK/GraalVM up to date
12 stars 0 forks source link

Scan `/nix/store` for JDKs #3

Open msgilligan opened 5 months ago

msgilligan commented 5 months ago

I am finding the Nix package manager very useful these days. Especially since I am using JDK 22 + Panama to interface to a native 'C" library.

It would be nice if JDK-Updater could know about and display JDKs installed via Nix.

p.s. I'm not sure how this can be done efficiently. Maybe there should be some mechanism for JDKs installed via Nix to register somehow.

HanSolo commented 5 months ago

JDKUpdater in principle simply scans the disk and tries to identify JVM‘s it found. Because some installer like sdkman use their own folders to manage installed software, JDKUpdater can identify the installer too. Meaning to say, if you can tell me where Nix does install JDK‘s, I can add this location to the search path and display them as installed by Nix. If Nix offers a mechanism to install JDK‘s via shell commands I might even be able to offer an update procedure but that’s probably not possible. In case Nix installs the JDK‘s in the default folder /Library/Java/JavaVirtualMachines, I won’t be able to figure where the JDK was „coming“ from.

HanSolo commented 5 months ago

Just did a quick check and if I‘m right, the Nix package manager stores it‘s pkgs in /nix/store. Is that also true for JDK‘s? In that case I could scan this path to find JVM‘s.

msgilligan commented 5 months ago

Yes, JDKs are also in /nix/store, for example: /nix/store/6amvs3wxc0lv382igpryc25dfcmgfcyv-graalvm-ce-22.0.0/ and /nix/store/cvmim67ikqj3wd42ys6vrdslyfmjgbcz-zulu-ca-jdk-22.0.0/. Because of the way Nix manages dependencies (similar in some ways to local Maven repos) there can be quite a few JDKs in /nix/store including multiple copies of the same version (but with different hashes).

As far as I know, Nix JDKs are not put into /Library/Java/JavaVirtualMachines, but there might be an add-on somewhere that does that. (Nix has a lot of add-ons, it seems)

msgilligan commented 5 months ago

Nix is powerful, exciting and frustrating. I would recommend this article for getting started: https://tonyfinn.com/blog/nix-from-first-principles-flake-edition/

It's best to set experimental-features = nix-command flakes and use the new commands and flakes features, but the frustrating part is that most of the documentation doesn't cover this.

HanSolo commented 5 months ago

Added scanning for the /nix/store path. Will come with the next release. Please let me know if it works once it will be available.

msgilligan commented 5 months ago

Added scanning for the /nix/store path. Will come with the next release. Please let me know if it works once it will be available.

Can I install from source?

HanSolo commented 5 months ago

Nope, there is only the dmg or pkg available atm

msgilligan commented 5 months ago

Nope, there is only the dmg or pkg available atm

I'm still running macOS 13, so I'll have to wait until I upgrade (which should be soon) to give it a try.

HanSolo commented 5 months ago

Check 👍🏻