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

`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`.
This commit is contained in:
Adam Joseph 2022-06-29 17:29:39 -07:00
parent 0a471a0b94
commit 1a61c13bfa

View file

@ -44,7 +44,7 @@ in {
mkBootstrap = adoptopenjdk: path: args:
/* adoptopenjdk not available for i686, so fall back to our old builds for bootstrapping */
if adoptopenjdk.jdk-hotspot.meta.available
if !stdenv.hostPlatform.isi686
then
# only linux has the gtkSupport option
if stdenv.isLinux