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-packages.nix: detect i686 using stdenv.hostPlatform #179648

Merged
merged 1 commit into from Nov 18, 2022
Merged

java-packages.nix: detect i686 using stdenv.hostPlatform #179648

merged 1 commit into from Nov 18, 2022

Conversation

ghost
Copy link

@ghost ghost commented Jun 30, 2022

The problem

java-packages.nix attempts to automatically decide which java to use for bootstrapping. When this works, it works well. However when it fails due to the user setting config.allowNonSource=false on a non-x86 platform, the reported failure is extremely confusing and does not mention the NIXPKGS_ALLOW_NONSOURCE=1 option to proceed, or that allowNonSource had anything to do with the eval failure.

Why the problem is happening

Currently, java-packages.nix makes its detection choice based on adoptopenjdk.jdk-hotspot.meta.available. If the user has set config.allowNonSource=false then the adoptopenjdk-bin packages will all report _.meta.available==false. If adoptopenjdk.jdk-hotspot.meta.available==false then the detection code will proceed to use callPackage path args, even if that package is also meta.unavailable for end-user-unfixable reasons.

In the case of openjdk8, the path passed is a nix expression that only works on x86. The user has two options for continuing the build: buy an x86 machine or add an allowNonSource exception for the bootstrap jdk. The second option is generally preferred, but the user is only offered the first option.

The fix for the problem

The following comment appears above the line in java-packages.nix which does the automatic selection:

/* adoptopenjdk not available for i686, so fall back to our old builds for bootstrapping */

Since the intent here was to decide based on "i686-ness", let's query the authoritative source for i686ness in nixpkgs: stdenv.hostPlatform.

Things done
  • Built on platform(s)
    • powerpc64le-linux
    • x86_64-linux
  • 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/)
  • Fits CONTRIBUTING.md.

@ofborg ofborg bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux labels Jun 30, 2022
@ghost ghost marked this pull request as ready for review June 30, 2022 02:37
@ghost
Copy link
Author

ghost commented Jul 27, 2022

Ping...

@chisui, this commit changes a line originally written by you. Are you okay with it?

Also pinging @taku0 (adoptopenjdk maintainer) and @edwtjo and @asbachb (openjdk maintainers).

@ghost
Copy link
Author

ghost commented Oct 2, 2022

Ping...

@bobby285271 bobby285271 added the 12.approvals: 1 This PR was reviewed and approved by one reputable person label Oct 2, 2022
`java-packages.nix` attempts to automatically decide which java to use
for bootstrapping.  When this works, it works well.  However when it
fails due to the user setting `config.allowNonSource=false` on a
non-x86 platform, the reported failure is extremely confusing and does
not mention the `NIXPKGS_ALLOW_NONSOURCE=1` option to proceed, or
that `allowNonSource` had anything to do with the eval failure.

Here's why this is happening:

Currently, `java-packages.nix` makes its detection choice based on
`adoptopenjdk.jdk-hotspot.meta.available`.  If the user has set
`config.allowNonSource=false` then the `adoptopenjdk-bin` packages
will all report `_.meta.available==false`.  If
`adoptopenjdk.jdk-hotspot.meta.available==false` then the detection
code will proceed to use `callPackage path args`, *even if that
package is **also** `meta.unavailable`* for end-user-unfixable
reasons.

In the case of `openjdk8`, the `path` passed is a `nix` expression
that only works on x86.  The user has two options for continuing the
build: buy an x86 machine or add an `allowNonSource` exception for the
bootstrap jdk.  The second option is generally preferred, but the user
is only offered the first option.

The following comment appears above the line in `java-packages.nix`
which does the automatic selection:

```
/* adoptopenjdk not available for i686, so fall back to our old builds for bootstrapping */
```

Since the intent here was to decide based on "i686-ness", let's query
the authoritative source for i686ness in nixpkgs: `stdenv.hostPlatform`.
@ghost ghost marked this pull request as draft November 5, 2022 01:02
@ghost
Copy link
Author

ghost commented Nov 5, 2022

Resolved merge conflict with #194255. @Artturin, since you've worked on this part of the code would you be willing to review?

@ghost ghost marked this pull request as ready for review November 5, 2022 01:05
@chisui chisui self-requested a review November 8, 2022 09:45
@Artturin Artturin merged commit 29e2da2 into NixOS:master Nov 18, 2022
@ghost ghost deleted the pr/java/dont-use-meta-available branch November 22, 2022 23:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux 12.approvals: 1 This PR was reviewed and approved by one reputable person
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants