From 1a61c13bfa63c731e7dd245861b4e36e33a7b969 Mon Sep 17 00:00:00 2001 From: Adam Joseph Date: Wed, 29 Jun 2022 17:29:39 -0700 Subject: [PATCH] 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`. --- pkgs/top-level/java-packages.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/top-level/java-packages.nix b/pkgs/top-level/java-packages.nix index 8a419a6a0960..dd2f70d7529f 100644 --- a/pkgs/top-level/java-packages.nix +++ b/pkgs/top-level/java-packages.nix @@ -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