OpenJDK: expose more versions

Provide a way to access all JDK versions.
This commit is contained in:
Philipp Dargel 2021-10-28 20:46:09 +02:00 committed by Jonathan Ringer
parent 305b7de421
commit a3401f6e33
6 changed files with 269 additions and 99 deletions

View file

@ -2023,6 +2023,12 @@ Superuser created successfully.
hydrus manual</link>.
</para>
</listitem>
<listitem>
<para>
More jdk and jre versions are now exposed via
<literal>java-packages.compiler</literal>.
</para>
</listitem>
</itemizedlist>
</section>
</section>

View file

@ -549,3 +549,5 @@ In addition to numerous new and upgraded packages, this release has the followin
- RetroArch has been upgraded from version `1.8.5` to `1.9.13.2`. Since the previous release was quite old, if you're having issues after the upgrade, please delete your `$XDG_CONFIG_HOME/retroarch/retroarch.cfg` file.
- hydrus has been upgraded from version `438` to `463`. Since upgrading between releases this old is advised against, be sure to have a backup of your data before upgrading. For details, see [the hydrus manual](https://hydrusnetwork.github.io/hydrus/help/getting_started_installing.html#big_updates).
- More jdk and jre versions are now exposed via `java-packages.compiler`.

View file

@ -0,0 +1,81 @@
{ lib, stdenv, fetchurl, unzip, setJavaClassPath }:
let
# Details from https://www.azul.com/downloads/?version=java-17-lts&os=macos&package=jdk
# Note that the latest build may differ by platform
dist = {
x86_64-darwin = {
arch = "x64";
zuluVersion = "17.30.15";
jdkVersion = "17.0.1";
sha256 = "sha256-CdZP5XY3O0MUQigRvIQC+7dwAXaCKw4eK/L/imytEOs=";
};
aarch64-darwin = {
arch = "aarch64";
zuluVersion = "17.30.19";
jdkVersion = "17.0.1";
sha256 = "sha256-zhBCXOnO/fsj6+q+vAlEz7QVMRFKLVvYnjwZzFz6mRM=";
};
}."${stdenv.hostPlatform.system}";
jce-policies = fetchurl {
# Ugh, unversioned URLs... I hope this doesn't change often enough to cause pain before we move to a Darwin source build of OpenJDK!
url = "http://cdn.azul.com/zcek/bin/ZuluJCEPolicies.zip";
sha256 = "0nk7m0lgcbsvldq2wbfni2pzq8h818523z912i7v8hdcij5s48c0";
};
jdk = stdenv.mkDerivation rec {
pname = "zulu${dist.zuluVersion}-ca-jdk";
version = dist.jdkVersion;
src = fetchurl {
url = "https://cdn.azul.com/zulu/bin/zulu${dist.zuluVersion}-ca-jdk${dist.jdkVersion}-macosx_${dist.arch}.tar.gz";
inherit (dist) sha256;
curlOpts = "-H Referer:https://www.azul.com/downloads/zulu/";
};
nativeBuildInputs = [ unzip ];
installPhase = ''
mkdir -p $out
mv * $out
unzip ${jce-policies}
mv -f ZuluJCEPolicies/*.jar $out/lib/security/
# jni.h expects jni_md.h to be in the header search path.
ln -s $out/include/darwin/*_md.h $out/include/
if [ -f $out/LICENSE ]; then
install -D $out/LICENSE $out/share/zulu/LICENSE
rm $out/LICENSE
fi
'';
preFixup = ''
# Propagate the setJavaClassPath setup hook from the JDK so that
# any package that depends on the JDK has $CLASSPATH set up
# properly.
mkdir -p $out/nix-support
printWords ${setJavaClassPath} > $out/nix-support/propagated-build-inputs
# Set JAVA_HOME automatically.
cat <<EOF >> $out/nix-support/setup-hook
if [ -z "\''${JAVA_HOME-}" ]; then export JAVA_HOME=$out; fi
EOF
'';
# fixupPhase is moving the man to share/man which breaks it because it's a
# relative symlink.
postFixup = ''
ln -nsf ../zulu-${lib.versions.major version}.jdk/Contents/Home/man $out/share/man
'';
passthru = {
home = jdk;
};
meta = import ./meta.nix lib;
};
in
jdk

View file

@ -12250,116 +12250,31 @@ with pkgs;
hugs = callPackage ../development/interpreters/hugs { };
openjfx11 = callPackage ../development/compilers/openjdk/openjfx/11.nix { };
openjfx15 = callPackage ../development/compilers/openjdk/openjfx/15.nix { };
openjdk8-bootstrap =
if adoptopenjdk-hotspot-bin-8.meta.available then
adoptopenjdk-hotspot-bin-8
else
callPackage ../development/compilers/openjdk/bootstrap.nix { version = "8"; };
/* legacy jdk for use as needed by older apps */
openjdk8 =
if stdenv.isDarwin then
callPackage ../development/compilers/openjdk/darwin/8.nix { }
else
callPackage ../development/compilers/openjdk/8.nix {
inherit (gnome2) GConf gnome_vfs;
};
openjdk8_headless =
if stdenv.isDarwin || stdenv.isAarch64 then
openjdk8
else
openjdk8.override { headless = true; };
inherit (javaPackages) openjfx11 openjfx15;
openjfx = openjfx15;
openjdk8-bootstrap = javaPackages.compiler.openjdk8-bootstrap;
openjdk8 = javaPackages.compiler.openjdk8;
openjdk8_headless = javaPackages.compiler.openjdk8.headless;
jdk8 = openjdk8;
jdk8_headless = openjdk8_headless;
jre8 = openjdk8.jre;
jre8_headless = openjdk8_headless.jre;
openjdk11-bootstrap =
if adoptopenjdk-hotspot-bin-11.meta.available then
adoptopenjdk-hotspot-bin-11
else
callPackage ../development/compilers/openjdk/bootstrap.nix { version = "10"; };
openjdk11 =
if stdenv.isDarwin then
callPackage ../development/compilers/openjdk/darwin/11.nix { }
else
callPackage ../development/compilers/openjdk/11.nix {
openjfx = openjfx11;
inherit (gnome2) GConf gnome_vfs;
};
openjdk11_headless =
if stdenv.isDarwin then
openjdk11
else
openjdk11.override { headless = true; };
openjdk17-bootstrap =
if adoptopenjdk-hotspot-bin-16.meta.available then
adoptopenjdk-hotspot-bin-16
else
/* adoptopenjdk not available for i686, so fall back to our old builds for bootstrapping */
callPackage ../development/compilers/openjdk/16.nix {
openjfx = openjfx11; /* need this despite next line :-( */
enableJavaFX = false;
headless = true;
inherit (gnome2) GConf gnome_vfs;
openjdk16-bootstrap = callPackage ../development/compilers/openjdk/15.nix {
openjfx = openjfx11; /* need this despite next line :-( */
enableJavaFX = false;
headless = true;
inherit (gnome2) GConf gnome_vfs;
openjdk15-bootstrap = callPackage ../development/compilers/openjdk/14.nix {
openjfx = openjfx11; /* need this despite next line :-( */
enableJavaFX = false;
headless = true;
inherit (gnome2) GConf gnome_vfs;
openjdk14-bootstrap = callPackage ../development/compilers/openjdk/13.nix {
openjfx = openjfx11; /* need this despite next line :-( */
enableJavaFX = false;
headless = true;
inherit (gnome2) GConf gnome_vfs;
openjdk13-bootstrap = callPackage ../development/compilers/openjdk/12.nix {
stdenv = gcc8Stdenv; /* build segfaults with gcc9 or newer, so use gcc8 like Debian does */
openjfx = openjfx11; /* need this despite next line :-( */
enableJavaFX = false;
headless = true;
inherit (gnome2) GConf gnome_vfs;
};
};
};
};
};
openjdk11-bootstrap = javaPackages.compiler.openjdk11-bootstrap;
openjdk11 = javaPackages.compiler.openjdk11;
openjdk11_headless = javaPackages.compiler.openjdk11.headless;
jdk11 = openjdk11;
jdk11_headless = openjdk11_headless;
/* Latest JDK */
openjdk17 =
if stdenv.isDarwin then
callPackage ../development/compilers/openjdk/darwin { }
else
callPackage ../development/compilers/openjdk/17.nix {
openjfx = openjfx15;
inherit (gnome2) GConf gnome_vfs;
};
openjdk17_headless =
if stdenv.isDarwin then
openjdk17
else
openjdk17.override { headless = true; };
openjdk17-bootstrap = javaPackages.compiler.openjdk17-bootstrap;
openjdk17 = javaPackages.compiler.openjdk17;
openjdk17_headless = javaPackages.compiler.openjdk17.headless;
jdk17 = openjdk17;
jdk17_headless = openjdk17_headless;
openjdk16-bootstrap = javaPackages.compiler.openjdk16-bootstrap;
/* default JDK */
jdk = jdk17;

View file

@ -5,8 +5,174 @@ with pkgs;
let
mavenbuild = callPackage ../development/java-modules/build-maven-package.nix { };
fetchMaven = callPackage ../development/java-modules/m2install.nix { };
openjfx11 = callPackage ../development/compilers/openjdk/openjfx/11.nix { };
openjfx15 = callPackage ../development/compilers/openjdk/openjfx/15.nix { };
in {
inherit mavenbuild fetchMaven;
inherit mavenbuild fetchMaven openjfx11 openjfx15;
compiler = let
gnomeArgs = {
inherit (gnome2) GConf gnome_vfs;
};
bootstrapArgs = gnomeArgs // {
openjfx = openjfx11; /* need this despite next line :-( */
enableJavaFX = false;
headless = true;
};
mkAdoptopenjdk = path-linux: path-darwin: let
package-linux = import path-linux { inherit lib; };
package-darwin = import path-darwin { inherit lib; };
package = if stdenv.isLinux
then package-linux
else package-darwin;
in rec {
inherit package-linux package-darwin;
jdk-hotspot = callPackage package.jdk-hotspot {};
jre-hotspot = callPackage package.jre-hotspot {};
jdk-openj9 = callPackage package.jdk-openj9 {};
jre-openj9 = callPackage package.jre-openj9 {};
};
mkBootstrap = adoptopenjdk: path: args:
/* adoptopenjdk not available for i686, so fall back to our old builds for bootstrapping */
if adoptopenjdk.jdk-hotspot.meta.available
then adoptopenjdk.jdk-hotspot
else callPackage path args;
mkOpenjdk = path-linux: path-darwin: args:
if stdenv.isLinux
then mkOpenjdkLinuxOnly path-linux args
else let
openjdk = callPackage path-darwin {};
in openjdk // { headless = openjdk; };
mkOpenjdkLinuxOnly = path-linux: args: let
openjdk = callPackage path-linux (gnomeArgs // args);
in openjdk // {
headless = openjdk.override { headless = true; };
};
openjdkDarwinMissing = version:
abort "OpenJDK ${builtins.toString version} is currently not supported on Darwin by nixpkgs.";
in rec {
adoptopenjdk-8 = mkAdoptopenjdk
../development/compilers/adoptopenjdk-bin/jdk8-linux.nix
../development/compilers/adoptopenjdk-bin/jdk8-darwin.nix;
adoptopenjdk-11 = mkAdoptopenjdk
../development/compilers/adoptopenjdk-bin/jdk11-linux.nix
../development/compilers/adoptopenjdk-bin/jdk11-darwin.nix;
adoptopenjdk-13 = mkAdoptopenjdk
../development/compilers/adoptopenjdk-bin/jdk13-linux.nix
../development/compilers/adoptopenjdk-bin/jdk13-darwin.nix;
adoptopenjdk-14 = mkAdoptopenjdk
../development/compilers/adoptopenjdk-bin/jdk14-linux.nix
../development/compilers/adoptopenjdk-bin/jdk14-darwin.nix;
adoptopenjdk-15 = mkAdoptopenjdk
../development/compilers/adoptopenjdk-bin/jdk15-linux.nix
../development/compilers/adoptopenjdk-bin/jdk15-darwin.nix;
adoptopenjdk-16 = mkAdoptopenjdk
../development/compilers/adoptopenjdk-bin/jdk16-linux.nix
../development/compilers/adoptopenjdk-bin/jdk16-darwin.nix;
openjdk8-bootstrap = mkBootstrap adoptopenjdk-8
../development/compilers/openjdk/bootstrap.nix
{ version = "8"; };
openjdk11-bootstrap = mkBootstrap adoptopenjdk-11
../development/compilers/openjdk/bootstrap.nix
{ version = "10"; };
openjdk13-bootstrap = mkBootstrap adoptopenjdk-13
../development/compilers/openjdk/12.nix
(bootstrapArgs // {
/* build segfaults with gcc9 or newer, so use gcc8 like Debian does */
stdenv = gcc8Stdenv;
});
openjdk14-bootstrap = mkBootstrap adoptopenjdk-14
../development/compilers/openjdk/13.nix
(bootstrapArgs // {
inherit openjdk13-bootstrap;
});
openjdk15-bootstrap = mkBootstrap adoptopenjdk-15
../development/compilers/openjdk/14.nix
(bootstrapArgs // {
inherit openjdk14-bootstrap;
});
openjdk16-bootstrap = mkBootstrap adoptopenjdk-16
../development/compilers/openjdk/15.nix
(bootstrapArgs // {
inherit openjdk15-bootstrap;
});
openjdk17-bootstrap = mkBootstrap adoptopenjdk-16
../development/compilers/openjdk/16.nix
(bootstrapArgs // {
inherit openjdk16-bootstrap;
});
openjdk8 = mkOpenjdk
../development/compilers/openjdk/8.nix
../development/compilers/openjdk/darwin/8.nix
{ };
openjdk11 = mkOpenjdk
../development/compilers/openjdk/11.nix
../development/compilers/openjdk/darwin/11.nix
{ openjfx = openjfx11; };
openjdk12 = mkOpenjdkLinuxOnly ../development/compilers/openjdk/12.nix {
/* build segfaults with gcc9 or newer, so use gcc8 like Debian does */
stdenv = gcc8Stdenv;
openjfx = openjfx11;
};
openjdk13 = mkOpenjdkLinuxOnly ../development/compilers/openjdk/13.nix {
inherit openjdk13-bootstrap;
openjfx = openjfx11;
};
openjdk14 = mkOpenjdkLinuxOnly ../development/compilers/openjdk/14.nix {
inherit openjdk14-bootstrap;
openjfx = openjfx11;
};
openjdk15 = mkOpenjdkLinuxOnly ../development/compilers/openjdk/15.nix {
inherit openjdk15-bootstrap;
openjfx = openjfx15;
};
openjdk16 = mkOpenjdk
../development/compilers/openjdk/16.nix
../development/compilers/openjdk/darwin/16.nix
{
inherit openjdk16-bootstrap;
openjfx = openjfx15;
};
openjdk17 = mkOpenjdk
../development/compilers/openjdk/17.nix
../development/compilers/openjdk/darwin/17.nix
{
inherit openjdk17-bootstrap;
openjfx = openjfx15;
};
};
mavenPlugins = recurseIntoAttrs (callPackage ../development/java-modules/mavenPlugins.nix { });