Skip to content

Commit

Permalink
OpenJDK: expose more versions
Browse files Browse the repository at this point in the history
Provide a way to access all JDK versions.
  • Loading branch information
chisui authored and jonringer committed Dec 3, 2021
1 parent 305b7de commit a3401f6
Show file tree
Hide file tree
Showing 6 changed files with 269 additions and 99 deletions.
6 changes: 6 additions & 0 deletions nixos/doc/manual/from_md/release-notes/rl-2111.section.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
2 changes: 2 additions & 0 deletions nixos/doc/manual/release-notes/rl-2111.section.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
81 changes: 81 additions & 0 deletions pkgs/development/compilers/openjdk/darwin/17.nix
Original file line number Diff line number Diff line change
@@ -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
111 changes: 13 additions & 98 deletions pkgs/top-level/all-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Loading

0 comments on commit a3401f6

Please sign in to comment.