From e075853151b4bb579beecd5946719ef3327f672f Mon Sep 17 00:00:00 2001 From: Weijia Wang <9713184+wegank@users.noreply.github.com> Date: Sun, 8 Oct 2023 00:27:47 +0200 Subject: [PATCH] openjdk: generalize platforms for zulu builds --- .../compilers/openjdk/darwin/11.nix | 4 +--- .../compilers/openjdk/darwin/16.nix | 4 +--- .../compilers/openjdk/darwin/17.nix | 4 +--- .../compilers/openjdk/darwin/18.nix | 4 +--- .../compilers/openjdk/darwin/19.nix | 4 +--- .../compilers/openjdk/darwin/20.nix | 4 +--- .../development/compilers/openjdk/darwin/8.nix | 4 +--- .../compilers/openjdk/darwin/common.nix | 18 +++++++++++++++--- 8 files changed, 22 insertions(+), 24 deletions(-) diff --git a/pkgs/development/compilers/openjdk/darwin/11.nix b/pkgs/development/compilers/openjdk/darwin/11.nix index 4d64d887c498..03880066f890 100644 --- a/pkgs/development/compilers/openjdk/darwin/11.nix +++ b/pkgs/development/compilers/openjdk/darwin/11.nix @@ -4,11 +4,10 @@ }@args: callPackage ./common.nix ({ - # Details from https://www.azul.com/downloads/?version=java-11-lts&os=macos&package=jdk + # Details from https://www.azul.com/downloads/?version=java-11-lts&package=jdk # Note that the latest build may differ by platform dists = { x86_64-darwin = { - arch = "x64"; zuluVersion = "11.66.15"; jdkVersion = "11.0.20"; hash = @@ -17,7 +16,6 @@ callPackage ./common.nix ({ }; aarch64-darwin = { - arch = "aarch64"; zuluVersion = "11.66.15"; jdkVersion = "11.0.20"; hash = diff --git a/pkgs/development/compilers/openjdk/darwin/16.nix b/pkgs/development/compilers/openjdk/darwin/16.nix index cb44fb6c9978..941a7e8d64f9 100644 --- a/pkgs/development/compilers/openjdk/darwin/16.nix +++ b/pkgs/development/compilers/openjdk/darwin/16.nix @@ -4,11 +4,10 @@ }@args: callPackage ./common.nix ({ - # Details from https://www.azul.com/downloads/?version=java-16-sts&os=macos&package=jdk + # Details from https://www.azul.com/downloads/?version=java-16-sts&package=jdk # Note that the latest build may differ by platform dists = { x86_64-darwin = { - arch = "x64"; zuluVersion = "16.32.15"; jdkVersion = "16.0.2"; hash = @@ -17,7 +16,6 @@ callPackage ./common.nix ({ }; aarch64-darwin = { - arch = "aarch64"; zuluVersion = "16.32.15"; jdkVersion = "16.0.2"; hash = diff --git a/pkgs/development/compilers/openjdk/darwin/17.nix b/pkgs/development/compilers/openjdk/darwin/17.nix index 0a4b05bcbcaf..7d1ec7cf473f 100644 --- a/pkgs/development/compilers/openjdk/darwin/17.nix +++ b/pkgs/development/compilers/openjdk/darwin/17.nix @@ -4,11 +4,10 @@ }@args: callPackage ./common.nix ({ - # Details from https://www.azul.com/downloads/?version=java-17-lts&os=macos&package=jdk + # Details from https://www.azul.com/downloads/?version=java-17-lts&package=jdk # Note that the latest build may differ by platform dists = { x86_64-darwin = { - arch = "x64"; zuluVersion = "17.44.53"; jdkVersion = "17.0.8.1"; hash = @@ -17,7 +16,6 @@ callPackage ./common.nix ({ }; aarch64-darwin = { - arch = "aarch64"; zuluVersion = "17.44.53"; jdkVersion = "17.0.8.1"; hash = diff --git a/pkgs/development/compilers/openjdk/darwin/18.nix b/pkgs/development/compilers/openjdk/darwin/18.nix index 5a0f07d22faf..cbee8ac6e5bd 100644 --- a/pkgs/development/compilers/openjdk/darwin/18.nix +++ b/pkgs/development/compilers/openjdk/darwin/18.nix @@ -4,11 +4,10 @@ }@args: callPackage ./common.nix ({ - # Details from https://www.azul.com/downloads/?version=java-18-sts&os=macos&package=jdk + # Details from https://www.azul.com/downloads/?version=java-18-sts&package=jdk # Note that the latest build may differ by platform dists = { x86_64-darwin = { - arch = "x64"; zuluVersion = "18.32.13"; jdkVersion = "18.0.2.1"; hash = @@ -17,7 +16,6 @@ callPackage ./common.nix ({ }; aarch64-darwin = { - arch = "aarch64"; zuluVersion = "18.32.13"; jdkVersion = "18.0.2.1"; hash = diff --git a/pkgs/development/compilers/openjdk/darwin/19.nix b/pkgs/development/compilers/openjdk/darwin/19.nix index d7a8bb1c3c94..28dbf5887616 100644 --- a/pkgs/development/compilers/openjdk/darwin/19.nix +++ b/pkgs/development/compilers/openjdk/darwin/19.nix @@ -4,11 +4,10 @@ }@args: callPackage ./common.nix ({ - # Details from https://www.azul.com/downloads/?version=java-19-sts&os=macos&package=jdk + # Details from https://www.azul.com/downloads/?version=java-19-sts&package=jdk # Note that the latest build may differ by platform dists = { x86_64-darwin = { - arch = "x64"; zuluVersion = if enableJavaFX then "19.32.15" else "19.32.13"; jdkVersion = "19.0.2"; hash = @@ -17,7 +16,6 @@ callPackage ./common.nix ({ }; aarch64-darwin = { - arch = "aarch64"; zuluVersion = if enableJavaFX then "19.32.15" else "19.32.13"; jdkVersion = "19.0.2"; hash = diff --git a/pkgs/development/compilers/openjdk/darwin/20.nix b/pkgs/development/compilers/openjdk/darwin/20.nix index 4d21e52b9602..38083a881f51 100644 --- a/pkgs/development/compilers/openjdk/darwin/20.nix +++ b/pkgs/development/compilers/openjdk/darwin/20.nix @@ -4,11 +4,10 @@ }@args: callPackage ./common.nix ({ - # Details from https://www.azul.com/downloads/?version=java-19-sts&os=macos&package=jdk + # Details from https://www.azul.com/downloads/?version=java-20-sts&package=jdk # Note that the latest build may differ by platform dists = { x86_64-darwin = { - arch = "x64"; zuluVersion = "20.32.11"; jdkVersion = "20.0.2"; hash = @@ -17,7 +16,6 @@ callPackage ./common.nix ({ }; aarch64-darwin = { - arch = "aarch64"; zuluVersion = "20.32.11"; jdkVersion = "20.0.2"; hash = diff --git a/pkgs/development/compilers/openjdk/darwin/8.nix b/pkgs/development/compilers/openjdk/darwin/8.nix index d6379dc60b65..b42681999cf7 100644 --- a/pkgs/development/compilers/openjdk/darwin/8.nix +++ b/pkgs/development/compilers/openjdk/darwin/8.nix @@ -4,11 +4,10 @@ }@args: callPackage ./common.nix ({ - # Details from https://www.azul.com/downloads/?version=java-8-lts&os=macos&package=jdk + # Details from https://www.azul.com/downloads/?version=java-8-lts&package=jdk # Note that the latest build may differ by platform dists = { x86_64-darwin = { - arch = "x64"; zuluVersion = "8.72.0.17"; jdkVersion = "8.0.382"; hash = @@ -17,7 +16,6 @@ callPackage ./common.nix ({ }; aarch64-darwin = { - arch = "aarch64"; zuluVersion = "8.72.0.17"; jdkVersion = "8.0.382"; hash = diff --git a/pkgs/development/compilers/openjdk/darwin/common.nix b/pkgs/development/compilers/openjdk/darwin/common.nix index e5fea19c0d30..89ac0718ec28 100644 --- a/pkgs/development/compilers/openjdk/darwin/common.nix +++ b/pkgs/development/compilers/openjdk/darwin/common.nix @@ -10,6 +10,18 @@ let dist = dists.${stdenv.hostPlatform.system} or (throw "Unsupported system: ${stdenv.hostPlatform.system}"); + arch = { + "aarch64" = "aarch64"; + "x86_64" = "x64"; + }.${stdenv.hostPlatform.parsed.cpu.name} + or (throw "Unsupported architecture: ${stdenv.hostPlatform.parsed.cpu.name}"); + + platform = { + "darwin" = "macosx"; + "linux" = "linux"; + }.${stdenv.hostPlatform.parsed.kernel.name} + or (throw "Unsupported platform: ${stdenv.hostPlatform.parsed.kernel.name}"); + jce-policies = fetchurl { url = "https://web.archive.org/web/20211126120343/http://cdn.azul.com/zcek/bin/ZuluJCEPolicies.zip"; hash = "sha256-gCGii4ysQbRPFCH9IQoKCCL8r4jWLS5wo1sv9iioZ1o="; @@ -24,7 +36,7 @@ let version = dist.jdkVersion; src = fetchurl { - url = "https://cdn.azul.com/zulu/bin/zulu${dist.zuluVersion}-${javaPackage}${dist.jdkVersion}-macosx_${dist.arch}.tar.gz"; + url = "https://cdn.azul.com/zulu/bin/zulu${dist.zuluVersion}-${javaPackage}${dist.jdkVersion}-${platform}_${arch}.tar.gz"; inherit (dist) hash; curlOpts = "-H Referer:https://www.azul.com/downloads/zulu/"; }; @@ -39,7 +51,7 @@ let mv -f ZuluJCEPolicies/*.jar $out/${lib.optionalString isJdk8 "jre/"}lib/security/ # jni.h expects jni_md.h to be in the header search path. - ln -s $out/include/darwin/*_md.h $out/include/ + ln -s $out/include/${stdenv.hostPlatform.parsed.kernel.name}/*_md.h $out/include/ if [ -f $out/LICENSE ]; then install -D $out/LICENSE $out/share/zulu/LICENSE @@ -62,7 +74,7 @@ let # fixupPhase is moving the man to share/man which breaks it because it's a # relative symlink. - postFixup = '' + postFixup = lib.optionalString stdenv.isDarwin '' ln -nsf ../zulu-${lib.versions.major version}.jdk/Contents/Home/man $out/share/man '';