2023-08-11 19:24:36 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
|
|
|
, fetchurl
|
|
|
|
, unzip
|
|
|
|
, setJavaClassPath
|
|
|
|
, enableJavaFX ? false
|
|
|
|
}:
|
2023-05-16 07:39:17 +00:00
|
|
|
let
|
|
|
|
# Details from https://www.azul.com/downloads/?version=java-19-sts&os=macos&package=jdk
|
|
|
|
# Note that the latest build may differ by platform
|
|
|
|
dist = {
|
|
|
|
x86_64-darwin = {
|
|
|
|
arch = "x64";
|
2023-08-05 00:02:08 +00:00
|
|
|
zuluVersion = "20.32.11";
|
|
|
|
jdkVersion = "20.0.2";
|
2023-08-11 19:24:36 +00:00
|
|
|
hash =
|
|
|
|
if enableJavaFX then "sha256-hyxQAivZAXtqMebe30L+EYa7p+TdSdKNYj7Rl/ZwRNQ="
|
|
|
|
else "sha256-Ev9KG6DvuBnsZrOguLsO1KQzudHCBcJNwKh45Inpnfo=";
|
2023-05-16 07:39:17 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
aarch64-darwin = {
|
|
|
|
arch = "aarch64";
|
2023-08-05 00:02:08 +00:00
|
|
|
zuluVersion = "20.32.11";
|
|
|
|
jdkVersion = "20.0.2";
|
2023-08-11 19:24:36 +00:00
|
|
|
hash =
|
|
|
|
if enableJavaFX then "sha256-iPQzZS4CwaoqT8cSzg4kWCT1OyGBSJLq+NETcbucLo4="
|
|
|
|
else "sha256-15uNZ6uMfSASV3QU2q2oA/jBk2PCHOfSjn1GY7/7qIY=";
|
2023-05-16 07:39:17 +00:00
|
|
|
};
|
|
|
|
}."${stdenv.hostPlatform.system}";
|
|
|
|
|
|
|
|
jce-policies = fetchurl {
|
2023-08-05 00:02:08 +00:00
|
|
|
url = "https://web.archive.org/web/20211126120343/http://cdn.azul.com/zcek/bin/ZuluJCEPolicies.zip";
|
|
|
|
hash = "sha256-gCGii4ysQbRPFCH9IQoKCCL8r4jWLS5wo1sv9iioZ1o=";
|
2023-05-16 07:39:17 +00:00
|
|
|
};
|
|
|
|
|
2023-08-11 19:24:36 +00:00
|
|
|
javaPackage = if enableJavaFX then "ca-fx-jdk" else "ca-jdk";
|
|
|
|
|
2023-05-16 07:39:17 +00:00
|
|
|
jdk = stdenv.mkDerivation rec {
|
2023-08-11 19:24:36 +00:00
|
|
|
pname = "zulu${dist.zuluVersion}-${javaPackage}";
|
2023-05-16 07:39:17 +00:00
|
|
|
version = dist.jdkVersion;
|
|
|
|
|
|
|
|
src = fetchurl {
|
2023-08-11 19:24:36 +00:00
|
|
|
url = "https://cdn.azul.com/zulu/bin/zulu${dist.zuluVersion}-${javaPackage}${dist.jdkVersion}-macosx_${dist.arch}.tar.gz";
|
2023-08-05 00:02:08 +00:00
|
|
|
inherit (dist) hash;
|
2023-05-16 07:39:17 +00:00
|
|
|
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 version;
|
|
|
|
};
|
|
|
|
in
|
|
|
|
jdk
|