Skip to content

openjdk22: add updateScript#306616

Merged
doronbehar merged 1 commit intoNixOS:masterfrom
jlesquembre:jl/jdk
Jun 8, 2024
Merged

openjdk22: add updateScript#306616
doronbehar merged 1 commit intoNixOS:masterfrom
jlesquembre:jl/jdk

Conversation

@jlesquembre
Copy link
Member

@jlesquembre jlesquembre commented Apr 24, 2024

Description of changes

Adds an update script for openjdk22. I tried to do make the script generic enough so it can be re-used for any openjdk version, but I'll handle that on a following PR if this one gets merged.
I had to replace the version attribute set with a string. The version is updated and validated in the updateScript with Java using Runtime.Version

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 24.05 Release Notes (or backporting 23.05 and 23.11 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

Add a 👍 reaction to pull requests you find important.

@ofborg ofborg bot requested a review from edwtjo April 24, 2024 19:40
@ofborg ofborg bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. labels Apr 24, 2024
Copy link
Contributor

@Princemachiavelli Princemachiavelli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The updater script works for me. A quick nix-diff of the PR shows the only change being the update from "22+36" to "22-ga" which is correct. Running the updater today causes an update from "22-ga" to "22.0.1-ga" which appears correct.

If the latest release always ends in -ga, perhaps it's better to strip that from the version? eg. openjdk-22.0.1 instead of openjdk-22.0.1-ga.

@jlesquembre
Copy link
Member Author

jlesquembre commented Apr 26, 2024

@Princemachiavelli Thanks for your review.
Added the pos back.
But I'd prefer to keep the -ga suffix to clarify which version we're using. Looking at https://github.com/openjdk/jdk22u/tags, there are many jdk-22+XX builds. In my opinion, the -ga suffix makes it clearer which specific version we're referring to.

@wegank wegank added the 12.approvals: 1 This PR was reviewed and approved by one person. label Apr 27, 2024
@jlesquembre jlesquembre mentioned this pull request Apr 29, 2024
13 tasks
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason why this was changed? It breaks the pattern with all of the other JDK builders, so it seems a bit out of place to change it in just 1 place. Same with the other references to the bootstrap JDK.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably I should have done it on a following PR.
The main reason is to unify the arguments to mkOpenJdk and create a more generic function in the future. There is a lot of duplication between the 22.nix, 21.nix, etc. files.

It also makes it more consistent with the openjfx argument. In my opinion, we should do this:

    openjdk22 = mkOpenjdk
      {
        jdk-bootstrap = temurin-bin.jdk-21;
        openjfx = openjfx22;
      };

or this:

    openjdk22 = mkOpenjdk
      {
        openjdk22-bootstrap = temurin-bin.jdk-21;
        openjdk22-openjfx = openjfx22;
      };

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jlesquembre regarding this change jdk-bootstrap rename, a quick git grep openjdk22-bootstrap showed me this:

pkgs/development/compilers/openjdk/22.nix:, openjdk22-bootstrap
pkgs/development/compilers/openjdk/22.nix:  openjdk-bootstrap = openjdk22-bootstrap.override { gtkSupport = !headless; };

So, won't it break what's in 22.nix and 21.nix?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just undid that change

@liff
Copy link
Contributor

liff commented May 22, 2024

Would it make sense to add some passthru.tests to this? Like testVersion and perhaps something that builds and runs a trivial application, just to make sure javac and java do what they should.

@jlesquembre
Copy link
Member Author

@liff My plan was to add a test on a following PR, but since getting this PR merged is taking longer than expected, I went ahead and added a test. I also reformatted the nix file with nixfmt (RFC 166)

@Infinidoge
Copy link
Contributor

Infinidoge commented May 26, 2024

Please split the commit to separate reformatting, adding the update script, and adding the test.
Having it all in 1 commit makes it more difficult to track in history and understand what was done.

@jlesquembre jlesquembre force-pushed the jl/jdk branch 2 times, most recently from 9fbaddb to 81fae6d Compare May 26, 2024 12:29
@ofborg ofborg bot requested a review from Infinidoge May 26, 2024 12:59
@jlesquembre
Copy link
Member Author

@Infinidoge I split it into 2 commits. For the review, please ignore the first one since it only contains formatting changes. I hope this helps reviewers and we can get this merged.
I didn't add an extra commit for the version tests for pragmatic reasons. The test changes are minimal, and having only one commit makes it easier to modify the commit again if more changes are requested.

Copy link
Member

@SuperSandro2000 SuperSandro2000 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Formatting of single packages is discouragrd as it creates lots of noise. Please wait for an organized effort.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a particular reason why the updater is not written in bash or python other than dog fooding?

It makes it a lot harder for general contributions to use it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two reasons:

@jlesquembre
Copy link
Member Author

@SuperSandro2000

Formatting of single packages is discouragrd as it creates lots of noise. Please wait for an organized effort.

I agree, but in this particular case I think it makes sense. The nix file was like this:

let 
  # ...
  openjdk = mkDerivation {...};
in
openjdk

and this PR updates it to

let 
  # ...
in
openjdk = mkDerivation (finalAttrs: {...})

only with that change, the diff is already quite noisy, so I took that opportunity to reformat it. Even without reformatting it with nixfmt, it makes sense to split the PR into two commits to make the real changes clear. That said, we could still meld both commits into one before merging into the master branch.

@Qyriad Qyriad added the 6.topic: java Including JDK, tooling, other languages, other VMs label May 26, 2024
@wegank wegank removed the 12.approvals: 1 This PR was reviewed and approved by one person. label May 29, 2024
@jlesquembre
Copy link
Member Author

What can I do to move forward this PR? I'm open to removing the formatting, remove the test, or other elements if it would help with the review process.

My only sticking point is that I believe the update script should remain in Java (or any JDK language) to leverage the Runtime.Version utilities.

cc @SuperSandro2000 @raboof

@jlesquembre jlesquembre requested a review from doronbehar June 3, 2024 20:42
Copy link
Contributor

@doronbehar doronbehar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 more general question:

  • Could we split perhaps the refactoring and the updateScript addition to separate commits?
  • Does this commit apply only to openjdk22? What about the other opdnjdk attributes?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jlesquembre regarding this change jdk-bootstrap rename, a quick git grep openjdk22-bootstrap showed me this:

pkgs/development/compilers/openjdk/22.nix:, openjdk22-bootstrap
pkgs/development/compilers/openjdk/22.nix:  openjdk-bootstrap = openjdk22-bootstrap.override { gtkSupport = !headless; };

So, won't it break what's in 22.nix and 21.nix?

@jlesquembre jlesquembre changed the title openjdk22: add updateScript + some refactoring openjdk22: add updateScript Jun 4, 2024
@jlesquembre
Copy link
Member Author

@SuperSandro2000 @Infinidoge @doronbehar I've undone all the unrelated changes (refactoring included) to focus solely on adding the update script. Hopefully, this helps moving forward the PR. I'll address the remaining changes in future PRs.

Copy link
Contributor

@doronbehar doronbehar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Diff LGTM. I trust the author to have tested the update script and that he will maintain it properly. I will merge in a week or so if no body else has any comments.

@jlesquembre
Copy link
Member Author

thanks @doronbehar
I did indeed test the script and plan to maintain it. Also, I intentionally didn't bump openjdk22 to the latest version. This way, once it gets merged, the update bot should create a PR.

For future reference, if anyone wants to test it locally, in the root directory of your nixpkgs copy run

nix build .#openjdk22.updateScript --print-out-paths

(or nix-build . --attr openjdk22.updateScript --no-out-link if you don't use flakes).

Then you can inspect the generated update script and run it if you want.

Copy link
Contributor

@Infinidoge Infinidoge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small problem with the versions specified in the build arguments, but outside of that LGTM

Comment on lines -148 to -149
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These should be kept, as they are used for marking the version.
From The Temurin build wiki, about versions in build configuration:

But when you build something that is fit for others to consume, you will still want to provide a build number with --with-build-number, use -with-version-pre="" if you want to say it is an actual release (use e.g. "ea", or just leave blank to make it "internal" otherwise), and in addition set --with-version-opt to control that thing that defaults to "adhoc.$USERNAME.$basedirname".

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I replaced it with --with-version-string=${version}, where the version value is the git tag.
Notice that --with-version-XX= overwrites the value set by --with-version-string.

Currently java --version returns:

openjdk 22-ga 2024-03-19
OpenJDK Runtime Environment (build 22-ga)
OpenJDK 64-Bit Server VM (build 22-ga, mixed mode, sharing)

If we add those 2 flags again (version-opt and version-pre) the output becomes::

openjdk 22 2024-03-19
OpenJDK Runtime Environment (build 22+-nixos)
OpenJDK 64-Bit Server VM (build 22+-nixos, mixed mode, sharing)

In my opinion, the first one makes the JDK version much clearer.

Looking at the link you posted, seems that what we should use is --with-vendor-version-string , but that option isn't mentioned here: https://openjdk.org/groups/build/doc/building.html

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, ideally we would still include the vendor information if possible, especially since we do patch OpenJDK for building on Nixpkgs. I do agree that it is much more clear though. Have you tested if --with-vendor-version-string works? (Finishing up a course so I haven't done so myself yet.)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with --with-vendor-version-string=${version}_nix-build:

openjdk 22-ga 2024-03-19
OpenJDK Runtime Environment 22-ga_nix-build (build 22-ga)
OpenJDK 64-Bit Server VM 22-ga_nix-build (build 22-ga, mixed mode, sharing)

Probably it is a good idea to add --with-vendor-version-string. What value makes sense to you? I like ${version}_nix-build, but I don't have a strong preference.

vendor-version-string is defined here:
https://github.com/openjdk/jdk/blob/6968770b1e918c74fc009e3562a827bb4acbe2d7/make/autoconf/jdk-version.m4#L488-L502

As a side note regarding the OpenJDK patches on nixpkgs, I think that some are not necessary for newer JDK versions. I'll open new PRs to remove them.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably it is a good idea to add --with-vendor-version-string. What value makes sense to you? I like ${version}_nix-build, but I don't have a strong preference.

I too don't have a strong preference, but I think the 22-ga is mentioned too many times if you'd use ${version} there too, so I'd vote for --with-veondor-version-string="(nix)".

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"--with-vendor-version-string=(nix)":

openjdk 22-ga 2024-03-19
OpenJDK Runtime Environment (nix) (build 22-ga)
OpenJDK 64-Bit Server VM (nix) (build 22-ga, mixed mode, sharing)

@doronbehar makes sense, changing my vote to (nix), I like it more :)
Let's wait for @Infinidoge vote

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It feels like it displays a little bit weirdly, with (nix) before the version, etc. But that's less of our problem and more of OpenJDK's problem. Looks good to me!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done, added "--with-vendor-version-string=(nix)"

@ofborg ofborg bot requested a review from Infinidoge June 7, 2024 21:07
@doronbehar doronbehar merged commit a07fdd5 into NixOS:master Jun 8, 2024
@doronbehar
Copy link
Contributor

Feel free to cc me for a review of other changes regarding java ecosystem @jlesquembre .

@jlesquembre
Copy link
Member Author

thanks @doronbehar , I will :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.topic: java Including JDK, tooling, other languages, other VMs 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants