From d9c87993d30ca2422cd5f7385badf298c929a0ae Mon Sep 17 00:00:00 2001 From: Weijia Wang <9713184+wegank@users.noreply.github.com> Date: Sat, 7 Oct 2023 21:49:21 +0200 Subject: [PATCH 1/5] openjdk: deduplicate expressions on darwin --- .../compilers/openjdk/darwin/11.nix | 77 ++---------------- .../compilers/openjdk/darwin/16.nix | 77 ++---------------- .../compilers/openjdk/darwin/17.nix | 77 ++---------------- .../compilers/openjdk/darwin/18.nix | 77 ++---------------- .../compilers/openjdk/darwin/19.nix | 77 ++---------------- .../compilers/openjdk/darwin/20.nix | 77 ++---------------- .../compilers/openjdk/darwin/8.nix | 81 ++----------------- .../compilers/openjdk/darwin/common.nix | 75 +++++++++++++++++ 8 files changed, 124 insertions(+), 494 deletions(-) create mode 100644 pkgs/development/compilers/openjdk/darwin/common.nix diff --git a/pkgs/development/compilers/openjdk/darwin/11.nix b/pkgs/development/compilers/openjdk/darwin/11.nix index 48de37679385..d4785e4308ac 100644 --- a/pkgs/development/compilers/openjdk/darwin/11.nix +++ b/pkgs/development/compilers/openjdk/darwin/11.nix @@ -1,11 +1,10 @@ -{ lib -, stdenv -, fetchurl -, unzip -, setJavaClassPath +{ callPackage , enableJavaFX ? false -}: -let +, stdenv +, ... +}@args: + +callPackage ./common.nix ({ # Details from https://www.azul.com/downloads/?version=java-11-lts&os=macos&package=jdk # Note that the latest build may differ by platform dist = { @@ -27,66 +26,4 @@ let else "sha256-djK8Kfikt9SSuT87x1p7YWMIlNuF0TZFYDWrKiTTiIU="; }; }."${stdenv.hostPlatform.system}"; - - jce-policies = fetchurl { - url = "https://web.archive.org/web/20211126120343/http://cdn.azul.com/zcek/bin/ZuluJCEPolicies.zip"; - hash = "sha256-gCGii4ysQbRPFCH9IQoKCCL8r4jWLS5wo1sv9iioZ1o="; - }; - - javaPackage = if enableJavaFX then "ca-fx-jdk" else "ca-jdk"; - - jdk = stdenv.mkDerivation rec { - pname = "zulu${dist.zuluVersion}-${javaPackage}"; - version = dist.jdkVersion; - - src = fetchurl { - url = "https://cdn.azul.com/zulu/bin/zulu${dist.zuluVersion}-${javaPackage}${dist.jdkVersion}-macosx_${dist.arch}.tar.gz"; - inherit (dist) hash; - 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 <> $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-11.jdk/Contents/Home/man $out/share/man - ''; - - passthru = { - home = jdk; - }; - - meta = import ./meta.nix lib version; - }; -in -jdk +} // builtins.removeAttrs args [ "callPackage" ]) diff --git a/pkgs/development/compilers/openjdk/darwin/16.nix b/pkgs/development/compilers/openjdk/darwin/16.nix index 657b3eeafeab..80d80c4ebf6f 100644 --- a/pkgs/development/compilers/openjdk/darwin/16.nix +++ b/pkgs/development/compilers/openjdk/darwin/16.nix @@ -1,11 +1,10 @@ -{ lib -, stdenv -, fetchurl -, unzip -, setJavaClassPath +{ callPackage , enableJavaFX ? false -}: -let +, stdenv +, ... +}@args: + +callPackage ./common.nix ({ # Details from https://www.azul.com/downloads/?version=java-16-sts&os=macos&package=jdk # Note that the latest build may differ by platform dist = { @@ -27,66 +26,4 @@ let else "sha256-3bUfDcLLyahLeURFAgLAVapBZHvqtam8GHbWTA6MQog="; }; }."${stdenv.hostPlatform.system}"; - - jce-policies = fetchurl { - url = "https://web.archive.org/web/20211126120343/http://cdn.azul.com/zcek/bin/ZuluJCEPolicies.zip"; - hash = "sha256-gCGii4ysQbRPFCH9IQoKCCL8r4jWLS5wo1sv9iioZ1o="; - }; - - javaPackage = if enableJavaFX then "ca-fx-jdk" else "ca-jdk"; - - jdk = stdenv.mkDerivation rec { - pname = "zulu${dist.zuluVersion}-${javaPackage}"; - version = dist.jdkVersion; - - src = fetchurl { - url = "https://cdn.azul.com/zulu/bin/zulu${dist.zuluVersion}-${javaPackage}${dist.jdkVersion}-macosx_${dist.arch}.tar.gz"; - inherit (dist) hash; - 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 <> $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 +} // builtins.removeAttrs args [ "callPackage" ]) diff --git a/pkgs/development/compilers/openjdk/darwin/17.nix b/pkgs/development/compilers/openjdk/darwin/17.nix index 49b23b440e23..01750e39fe1d 100644 --- a/pkgs/development/compilers/openjdk/darwin/17.nix +++ b/pkgs/development/compilers/openjdk/darwin/17.nix @@ -1,11 +1,10 @@ -{ lib -, stdenv -, fetchurl -, unzip -, setJavaClassPath +{ callPackage , enableJavaFX ? false -}: -let +, stdenv +, ... +}@args: + +callPackage ./common.nix ({ # 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 = { @@ -27,66 +26,4 @@ let else "sha256-MUsEVo7Arps2ugPJy9Qq3J4SZfdGeJI7GSl9ZuuE3Mo="; }; }."${stdenv.hostPlatform.system}"; - - jce-policies = fetchurl { - url = "https://web.archive.org/web/20211126120343/http://cdn.azul.com/zcek/bin/ZuluJCEPolicies.zip"; - hash = "sha256-gCGii4ysQbRPFCH9IQoKCCL8r4jWLS5wo1sv9iioZ1o="; - }; - - javaPackage = if enableJavaFX then "ca-fx-jdk" else "ca-jdk"; - - jdk = stdenv.mkDerivation rec { - pname = "zulu${dist.zuluVersion}-${javaPackage}"; - version = dist.jdkVersion; - - src = fetchurl { - url = "https://cdn.azul.com/zulu/bin/zulu${dist.zuluVersion}-${javaPackage}${dist.jdkVersion}-macosx_${dist.arch}.tar.gz"; - inherit (dist) hash; - 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 <> $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 +} // builtins.removeAttrs args [ "callPackage" ]) diff --git a/pkgs/development/compilers/openjdk/darwin/18.nix b/pkgs/development/compilers/openjdk/darwin/18.nix index 30a61b4b1faa..00ee57628441 100644 --- a/pkgs/development/compilers/openjdk/darwin/18.nix +++ b/pkgs/development/compilers/openjdk/darwin/18.nix @@ -1,11 +1,10 @@ -{ lib -, stdenv -, fetchurl -, unzip -, setJavaClassPath +{ callPackage , enableJavaFX ? false -}: -let +, stdenv +, ... +}@args: + +callPackage ./common.nix ({ # Details from https://www.azul.com/downloads/?version=java-18-sts&os=macos&package=jdk # Note that the latest build may differ by platform dist = { @@ -27,66 +26,4 @@ let else "sha256-jAZDgxtWMq/74yKAxA69oOU0C9nXvKG5MjmZLsK04iM="; }; }."${stdenv.hostPlatform.system}"; - - jce-policies = fetchurl { - url = "https://web.archive.org/web/20211126120343/http://cdn.azul.com/zcek/bin/ZuluJCEPolicies.zip"; - hash = "sha256-gCGii4ysQbRPFCH9IQoKCCL8r4jWLS5wo1sv9iioZ1o="; - }; - - javaPackage = if enableJavaFX then "ca-fx-jdk" else "ca-jdk"; - - jdk = stdenv.mkDerivation rec { - pname = "zulu${dist.zuluVersion}-${javaPackage}"; - version = dist.jdkVersion; - - src = fetchurl { - url = "https://cdn.azul.com/zulu/bin/zulu${dist.zuluVersion}-${javaPackage}${dist.jdkVersion}-macosx_${dist.arch}.tar.gz"; - inherit (dist) hash; - 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 <> $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 +} // builtins.removeAttrs args [ "callPackage" ]) diff --git a/pkgs/development/compilers/openjdk/darwin/19.nix b/pkgs/development/compilers/openjdk/darwin/19.nix index a087de1b5727..f8611517bdca 100644 --- a/pkgs/development/compilers/openjdk/darwin/19.nix +++ b/pkgs/development/compilers/openjdk/darwin/19.nix @@ -1,11 +1,10 @@ -{ lib -, stdenv -, fetchurl -, unzip -, setJavaClassPath +{ callPackage , enableJavaFX ? false -}: -let +, stdenv +, ... +}@args: + +callPackage ./common.nix ({ # 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 = { @@ -27,66 +26,4 @@ let else "sha256-F30FjZaLL756X/Xs6xjNwW9jds4pEATxoxOeeLL7Y5E="; }; }."${stdenv.hostPlatform.system}"; - - jce-policies = fetchurl { - url = "https://web.archive.org/web/20211126120343/http://cdn.azul.com/zcek/bin/ZuluJCEPolicies.zip"; - hash = "sha256-gCGii4ysQbRPFCH9IQoKCCL8r4jWLS5wo1sv9iioZ1o="; - }; - - javaPackage = if enableJavaFX then "ca-fx-jdk" else "ca-jdk"; - - jdk = stdenv.mkDerivation rec { - pname = "zulu${dist.zuluVersion}-${javaPackage}"; - version = dist.jdkVersion; - - src = fetchurl { - url = "https://cdn.azul.com/zulu/bin/zulu${dist.zuluVersion}-${javaPackage}${dist.jdkVersion}-macosx_${dist.arch}.tar.gz"; - inherit (dist) hash; - 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 <> $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 +} // builtins.removeAttrs args [ "callPackage" ]) diff --git a/pkgs/development/compilers/openjdk/darwin/20.nix b/pkgs/development/compilers/openjdk/darwin/20.nix index b0c62aafd78d..f414b4fad26a 100644 --- a/pkgs/development/compilers/openjdk/darwin/20.nix +++ b/pkgs/development/compilers/openjdk/darwin/20.nix @@ -1,11 +1,10 @@ -{ lib -, stdenv -, fetchurl -, unzip -, setJavaClassPath +{ callPackage , enableJavaFX ? false -}: -let +, stdenv +, ... +}@args: + +callPackage ./common.nix ({ # 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 = { @@ -27,66 +26,4 @@ let else "sha256-15uNZ6uMfSASV3QU2q2oA/jBk2PCHOfSjn1GY7/7qIY="; }; }."${stdenv.hostPlatform.system}"; - - jce-policies = fetchurl { - url = "https://web.archive.org/web/20211126120343/http://cdn.azul.com/zcek/bin/ZuluJCEPolicies.zip"; - hash = "sha256-gCGii4ysQbRPFCH9IQoKCCL8r4jWLS5wo1sv9iioZ1o="; - }; - - javaPackage = if enableJavaFX then "ca-fx-jdk" else "ca-jdk"; - - jdk = stdenv.mkDerivation rec { - pname = "zulu${dist.zuluVersion}-${javaPackage}"; - version = dist.jdkVersion; - - src = fetchurl { - url = "https://cdn.azul.com/zulu/bin/zulu${dist.zuluVersion}-${javaPackage}${dist.jdkVersion}-macosx_${dist.arch}.tar.gz"; - inherit (dist) hash; - 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 <> $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 +} // builtins.removeAttrs args [ "callPackage" ]) diff --git a/pkgs/development/compilers/openjdk/darwin/8.nix b/pkgs/development/compilers/openjdk/darwin/8.nix index 9bfd9a8db1a3..f2648b35db55 100644 --- a/pkgs/development/compilers/openjdk/darwin/8.nix +++ b/pkgs/development/compilers/openjdk/darwin/8.nix @@ -1,11 +1,10 @@ -{ lib -, stdenv -, fetchurl -, unzip -, setJavaClassPath +{ callPackage , enableJavaFX ? false -}: -let +, stdenv +, ... +}@args: + +callPackage ./common.nix ({ # Details from https://www.azul.com/downloads/?version=java-8-lts&os=macos&package=jdk # Note that the latest build may differ by platform dist = { @@ -27,70 +26,4 @@ let else "sha256-rN5AI4xAWppE4kJlzMod0JmGyHdHjTXYtx8/wOW6CFk="; }; }."${stdenv.hostPlatform.system}"; - - jce-policies = fetchurl { - url = "https://web.archive.org/web/20211126120343/http://cdn.azul.com/zcek/bin/ZuluJCEPolicies.zip"; - hash = "sha256-gCGii4ysQbRPFCH9IQoKCCL8r4jWLS5wo1sv9iioZ1o="; - }; - - javaPackage = if enableJavaFX then "ca-fx-jdk" else "ca-jdk"; - - jdk = stdenv.mkDerivation rec { - # @hlolli: Later version than 1.8.0_202 throws error when building jvmci. - # dyld: lazy symbol binding failed: Symbol not found: _JVM_BeforeHalt - # Referenced from: ../libjava.dylib Expected in: .../libjvm.dylib - pname = "zulu${dist.zuluVersion}-${javaPackage}"; - version = dist.jdkVersion; - - src = fetchurl { - url = "https://cdn.azul.com/zulu/bin/zulu${dist.zuluVersion}-${javaPackage}${dist.jdkVersion}-macosx_${dist.arch}.tar.gz"; - inherit (dist) hash; - 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/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/ - - 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 JRE so that - # any package that depends on the JRE has $CLASSPATH set up - # properly. - mkdir -p $out/nix-support - printWords ${setJavaClassPath} > $out/nix-support/propagated-build-inputs - - # Set JAVA_HOME automatically. - cat <> $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 = { - jre = jdk; - home = jdk; - }; - - meta = import ./meta.nix lib version; - }; -in -jdk +} // builtins.removeAttrs args [ "callPackage" ]) diff --git a/pkgs/development/compilers/openjdk/darwin/common.nix b/pkgs/development/compilers/openjdk/darwin/common.nix new file mode 100644 index 000000000000..ed1778bcecc2 --- /dev/null +++ b/pkgs/development/compilers/openjdk/darwin/common.nix @@ -0,0 +1,75 @@ +{ lib +, stdenv +, fetchurl +, unzip +, setJavaClassPath +, enableJavaFX ? false +, dist +}: +let + jce-policies = fetchurl { + url = "https://web.archive.org/web/20211126120343/http://cdn.azul.com/zcek/bin/ZuluJCEPolicies.zip"; + hash = "sha256-gCGii4ysQbRPFCH9IQoKCCL8r4jWLS5wo1sv9iioZ1o="; + }; + + javaPackage = if enableJavaFX then "ca-fx-jdk" else "ca-jdk"; + + isJdk8 = lib.versions.major dist.jdkVersion == "8"; + + jdk = stdenv.mkDerivation rec { + pname = "zulu${dist.zuluVersion}-${javaPackage}"; + version = dist.jdkVersion; + + src = fetchurl { + url = "https://cdn.azul.com/zulu/bin/zulu${dist.zuluVersion}-${javaPackage}${dist.jdkVersion}-macosx_${dist.arch}.tar.gz"; + inherit (dist) hash; + 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.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/ + + 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 ${if isJdk8 then "JRE" else "JDK"} so that + # any package that depends on the ${if isJdk8 then "JRE" else "JDK"} has $CLASSPATH set up + # properly. + mkdir -p $out/nix-support + printWords ${setJavaClassPath} > $out/nix-support/propagated-build-inputs + + # Set JAVA_HOME automatically. + cat <> $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 = (lib.optionalAttrs isJdk8 { + jre = jdk; + }) // { + home = jdk; + }; + + meta = import ./meta.nix lib version; + }; +in +jdk From 7251451049971ba332507d84dcba7b9ff310a123 Mon Sep 17 00:00:00 2001 From: Weijia Wang <9713184+wegank@users.noreply.github.com> Date: Sun, 8 Oct 2023 00:15:29 +0200 Subject: [PATCH 2/5] openjdk: refactor meta on darwin --- .../compilers/openjdk/darwin/11.nix | 5 ++--- .../compilers/openjdk/darwin/16.nix | 5 ++--- .../compilers/openjdk/darwin/17.nix | 5 ++--- .../compilers/openjdk/darwin/18.nix | 5 ++--- .../compilers/openjdk/darwin/19.nix | 5 ++--- .../compilers/openjdk/darwin/20.nix | 5 ++--- .../development/compilers/openjdk/darwin/8.nix | 5 ++--- .../compilers/openjdk/darwin/common.nix | 18 ++++++++++++++++-- .../compilers/openjdk/darwin/meta.nix | 4 ---- 9 files changed, 30 insertions(+), 27 deletions(-) delete mode 100644 pkgs/development/compilers/openjdk/darwin/meta.nix diff --git a/pkgs/development/compilers/openjdk/darwin/11.nix b/pkgs/development/compilers/openjdk/darwin/11.nix index d4785e4308ac..4d64d887c498 100644 --- a/pkgs/development/compilers/openjdk/darwin/11.nix +++ b/pkgs/development/compilers/openjdk/darwin/11.nix @@ -1,13 +1,12 @@ { callPackage , enableJavaFX ? false -, stdenv , ... }@args: callPackage ./common.nix ({ # Details from https://www.azul.com/downloads/?version=java-11-lts&os=macos&package=jdk # Note that the latest build may differ by platform - dist = { + dists = { x86_64-darwin = { arch = "x64"; zuluVersion = "11.66.15"; @@ -25,5 +24,5 @@ callPackage ./common.nix ({ if enableJavaFX then "sha256-VoZo34SCUU+HHnTl6iLe0QBC+4VDkPP14N98oqSg9EQ=" else "sha256-djK8Kfikt9SSuT87x1p7YWMIlNuF0TZFYDWrKiTTiIU="; }; - }."${stdenv.hostPlatform.system}"; + }; } // builtins.removeAttrs args [ "callPackage" ]) diff --git a/pkgs/development/compilers/openjdk/darwin/16.nix b/pkgs/development/compilers/openjdk/darwin/16.nix index 80d80c4ebf6f..cb44fb6c9978 100644 --- a/pkgs/development/compilers/openjdk/darwin/16.nix +++ b/pkgs/development/compilers/openjdk/darwin/16.nix @@ -1,13 +1,12 @@ { callPackage , enableJavaFX ? false -, stdenv , ... }@args: callPackage ./common.nix ({ # Details from https://www.azul.com/downloads/?version=java-16-sts&os=macos&package=jdk # Note that the latest build may differ by platform - dist = { + dists = { x86_64-darwin = { arch = "x64"; zuluVersion = "16.32.15"; @@ -25,5 +24,5 @@ callPackage ./common.nix ({ if enableJavaFX then "sha256-QuyhIAxUY3Vv1adGihW+LIsXtpDX2taCmFsMFj9o5vs=" else "sha256-3bUfDcLLyahLeURFAgLAVapBZHvqtam8GHbWTA6MQog="; }; - }."${stdenv.hostPlatform.system}"; + }; } // builtins.removeAttrs args [ "callPackage" ]) diff --git a/pkgs/development/compilers/openjdk/darwin/17.nix b/pkgs/development/compilers/openjdk/darwin/17.nix index 01750e39fe1d..0a4b05bcbcaf 100644 --- a/pkgs/development/compilers/openjdk/darwin/17.nix +++ b/pkgs/development/compilers/openjdk/darwin/17.nix @@ -1,13 +1,12 @@ { callPackage , enableJavaFX ? false -, stdenv , ... }@args: callPackage ./common.nix ({ # 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 = { + dists = { x86_64-darwin = { arch = "x64"; zuluVersion = "17.44.53"; @@ -25,5 +24,5 @@ callPackage ./common.nix ({ if enableJavaFX then "sha256-udYW3nOADclWqVcVtS9dgjSY0w6xf2nsBpLzPmQCYlI=" else "sha256-MUsEVo7Arps2ugPJy9Qq3J4SZfdGeJI7GSl9ZuuE3Mo="; }; - }."${stdenv.hostPlatform.system}"; + }; } // builtins.removeAttrs args [ "callPackage" ]) diff --git a/pkgs/development/compilers/openjdk/darwin/18.nix b/pkgs/development/compilers/openjdk/darwin/18.nix index 00ee57628441..5a0f07d22faf 100644 --- a/pkgs/development/compilers/openjdk/darwin/18.nix +++ b/pkgs/development/compilers/openjdk/darwin/18.nix @@ -1,13 +1,12 @@ { callPackage , enableJavaFX ? false -, stdenv , ... }@args: callPackage ./common.nix ({ # Details from https://www.azul.com/downloads/?version=java-18-sts&os=macos&package=jdk # Note that the latest build may differ by platform - dist = { + dists = { x86_64-darwin = { arch = "x64"; zuluVersion = "18.32.13"; @@ -25,5 +24,5 @@ callPackage ./common.nix ({ if enableJavaFX then "sha256-tNx0a1u9iamcN9VFOJ3eqDEA6C204dtIBJZvuAH2Vjk=" else "sha256-jAZDgxtWMq/74yKAxA69oOU0C9nXvKG5MjmZLsK04iM="; }; - }."${stdenv.hostPlatform.system}"; + }; } // builtins.removeAttrs args [ "callPackage" ]) diff --git a/pkgs/development/compilers/openjdk/darwin/19.nix b/pkgs/development/compilers/openjdk/darwin/19.nix index f8611517bdca..d7a8bb1c3c94 100644 --- a/pkgs/development/compilers/openjdk/darwin/19.nix +++ b/pkgs/development/compilers/openjdk/darwin/19.nix @@ -1,13 +1,12 @@ { callPackage , enableJavaFX ? false -, stdenv , ... }@args: callPackage ./common.nix ({ # 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 = { + dists = { x86_64-darwin = { arch = "x64"; zuluVersion = if enableJavaFX then "19.32.15" else "19.32.13"; @@ -25,5 +24,5 @@ callPackage ./common.nix ({ if enableJavaFX then "sha256-/R2rrcBr64qPGEtvhruXBhPwnvurt/hiR1ICzZAdYxE=" else "sha256-F30FjZaLL756X/Xs6xjNwW9jds4pEATxoxOeeLL7Y5E="; }; - }."${stdenv.hostPlatform.system}"; + }; } // builtins.removeAttrs args [ "callPackage" ]) diff --git a/pkgs/development/compilers/openjdk/darwin/20.nix b/pkgs/development/compilers/openjdk/darwin/20.nix index f414b4fad26a..4d21e52b9602 100644 --- a/pkgs/development/compilers/openjdk/darwin/20.nix +++ b/pkgs/development/compilers/openjdk/darwin/20.nix @@ -1,13 +1,12 @@ { callPackage , enableJavaFX ? false -, stdenv , ... }@args: callPackage ./common.nix ({ # 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 = { + dists = { x86_64-darwin = { arch = "x64"; zuluVersion = "20.32.11"; @@ -25,5 +24,5 @@ callPackage ./common.nix ({ if enableJavaFX then "sha256-iPQzZS4CwaoqT8cSzg4kWCT1OyGBSJLq+NETcbucLo4=" else "sha256-15uNZ6uMfSASV3QU2q2oA/jBk2PCHOfSjn1GY7/7qIY="; }; - }."${stdenv.hostPlatform.system}"; + }; } // builtins.removeAttrs args [ "callPackage" ]) diff --git a/pkgs/development/compilers/openjdk/darwin/8.nix b/pkgs/development/compilers/openjdk/darwin/8.nix index f2648b35db55..d6379dc60b65 100644 --- a/pkgs/development/compilers/openjdk/darwin/8.nix +++ b/pkgs/development/compilers/openjdk/darwin/8.nix @@ -1,13 +1,12 @@ { callPackage , enableJavaFX ? false -, stdenv , ... }@args: callPackage ./common.nix ({ # Details from https://www.azul.com/downloads/?version=java-8-lts&os=macos&package=jdk # Note that the latest build may differ by platform - dist = { + dists = { x86_64-darwin = { arch = "x64"; zuluVersion = "8.72.0.17"; @@ -25,5 +24,5 @@ callPackage ./common.nix ({ if enableJavaFX then "sha256-FkQ+0MzSZWUzc/HmiDVZEHGOrdKAVCdK5pm9wXXzzaU=" else "sha256-rN5AI4xAWppE4kJlzMod0JmGyHdHjTXYtx8/wOW6CFk="; }; - }."${stdenv.hostPlatform.system}"; + }; } // builtins.removeAttrs args [ "callPackage" ]) diff --git a/pkgs/development/compilers/openjdk/darwin/common.nix b/pkgs/development/compilers/openjdk/darwin/common.nix index ed1778bcecc2..e5fea19c0d30 100644 --- a/pkgs/development/compilers/openjdk/darwin/common.nix +++ b/pkgs/development/compilers/openjdk/darwin/common.nix @@ -4,9 +4,12 @@ , unzip , setJavaClassPath , enableJavaFX ? false -, dist +, dists }: let + dist = dists.${stdenv.hostPlatform.system} + or (throw "Unsupported system: ${stdenv.hostPlatform.system}"); + jce-policies = fetchurl { url = "https://web.archive.org/web/20211126120343/http://cdn.azul.com/zcek/bin/ZuluJCEPolicies.zip"; hash = "sha256-gCGii4ysQbRPFCH9IQoKCCL8r4jWLS5wo1sv9iioZ1o="; @@ -69,7 +72,18 @@ let home = jdk; }; - meta = import ./meta.nix lib version; + meta = (import ../../openjdk/meta.nix lib version) // { + description = "Certified builds of OpenJDK"; + longDescription = '' + Certified builds of OpenJDK that can be deployed across multiple + operating systems, containers, hypervisors and Cloud platforms. + ''; + homepage = "https://www.azul.com/products/zulu/"; + mainProgram = "java"; + maintainers = [ ]; + platforms = builtins.attrNames dists; + sourceProvenance = with lib.sourceTypes; [ binaryBytecode binaryNativeCode ]; + }; }; in jdk diff --git a/pkgs/development/compilers/openjdk/darwin/meta.nix b/pkgs/development/compilers/openjdk/darwin/meta.nix deleted file mode 100644 index f07a7f38a45b..000000000000 --- a/pkgs/development/compilers/openjdk/darwin/meta.nix +++ /dev/null @@ -1,4 +0,0 @@ -lib: version: (removeAttrs (import ../meta.nix lib version) [ "maintainers" ]) // { - platforms = lib.platforms.darwin; - homepage = "https://www.azul.com/"; -} 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 3/5] 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 ''; From 8d8796f34164436a341949250b15c721f1e984d2 Mon Sep 17 00:00:00 2001 From: Weijia Wang <9713184+wegank@users.noreply.github.com> Date: Sun, 8 Oct 2023 01:04:34 +0200 Subject: [PATCH 4/5] openjdk: add linux support for zulu builds --- .../compilers/openjdk/darwin/common.nix | 62 ++++++++++++++++++- 1 file changed, 60 insertions(+), 2 deletions(-) diff --git a/pkgs/development/compilers/openjdk/darwin/common.nix b/pkgs/development/compilers/openjdk/darwin/common.nix index 89ac0718ec28..6972c186bfa4 100644 --- a/pkgs/development/compilers/openjdk/darwin/common.nix +++ b/pkgs/development/compilers/openjdk/darwin/common.nix @@ -1,10 +1,25 @@ { lib , stdenv , fetchurl -, unzip , setJavaClassPath , enableJavaFX ? false , dists + # minimum dependencies +, unzip +, autoPatchelfHook +, makeWrapper +, alsa-lib +, fontconfig +, freetype +, zlib +, xorg + # runtime dependencies +, cups + # runtime dependencies for GTK+ Look and Feel +, gtkSupport ? stdenv.isLinux +, cairo +, glib +, gtk3 }: let dist = dists.${stdenv.hostPlatform.system} @@ -22,6 +37,16 @@ let }.${stdenv.hostPlatform.parsed.kernel.name} or (throw "Unsupported platform: ${stdenv.hostPlatform.parsed.kernel.name}"); + runtimeDependencies = [ + cups + ] ++ lib.optionals gtkSupport [ + cairo + glib + gtk3 + ]; + + runtimeLibraryPath = lib.makeLibraryPath runtimeDependencies; + jce-policies = fetchurl { url = "https://web.archive.org/web/20211126120343/http://cdn.azul.com/zcek/bin/ZuluJCEPolicies.zip"; hash = "sha256-gCGii4ysQbRPFCH9IQoKCCL8r4jWLS5wo1sv9iioZ1o="; @@ -41,7 +66,25 @@ let curlOpts = "-H Referer:https://www.azul.com/downloads/zulu/"; }; - nativeBuildInputs = [ unzip ]; + nativeBuildInputs = [ + unzip + ] ++ lib.optionals stdenv.isLinux [ + autoPatchelfHook + makeWrapper + ]; + + buildInputs = lib.optionals stdenv.isLinux [ + alsa-lib # libasound.so wanted by lib/libjsound.so + fontconfig + freetype + stdenv.cc.cc # libstdc++.so.6 + xorg.libX11 + xorg.libXext + xorg.libXi + xorg.libXrender + xorg.libXtst + zlib + ]; installPhase = '' mkdir -p $out @@ -70,6 +113,21 @@ let cat <> $out/nix-support/setup-hook if [ -z "\''${JAVA_HOME-}" ]; then export JAVA_HOME=$out; fi EOF + '' + lib.optionalString stdenv.isLinux '' + # We cannot use -exec since wrapProgram is a function but not a command. + # + # jspawnhelper is executed from JVM, so it doesn't need to wrap it, and it + # breaks building OpenJDK (#114495). + for bin in $( find "$out" -executable -type f -not -name jspawnhelper ); do + if patchelf --print-interpreter "$bin" &> /dev/null; then + wrapProgram "$bin" --prefix LD_LIBRARY_PATH : "${runtimeLibraryPath}" + fi + done + '' + # FIXME: move all of the above to installPhase. + + lib.optionalString stdenv.isLinux '' + find "$out" -name libfontmanager.so -exec \ + patchelf --add-needed libfontconfig.so {} \; ''; # fixupPhase is moving the man to share/man which breaks it because it's a From 2e692b3ddbf2d940a66cef59c4db01707a241515 Mon Sep 17 00:00:00 2001 From: Weijia Wang <9713184+wegank@users.noreply.github.com> Date: Sun, 8 Oct 2023 01:26:09 +0200 Subject: [PATCH 5/5] zulu: add darwin support --- .../compilers/openjdk/darwin/8.nix | 26 ---- .../compilers/{openjdk/darwin => zulu}/11.nix | 16 ++ .../compilers/{openjdk/darwin => zulu}/16.nix | 0 .../compilers/{openjdk/darwin => zulu}/17.nix | 0 .../compilers/{openjdk/darwin => zulu}/18.nix | 0 .../compilers/{openjdk/darwin => zulu}/19.nix | 0 .../compilers/{openjdk/darwin => zulu}/20.nix | 0 pkgs/development/compilers/zulu/21.nix | 26 ++++ pkgs/development/compilers/zulu/8.nix | 146 ++++-------------- .../{openjdk/darwin => zulu}/common.nix | 2 +- pkgs/development/compilers/zulu/default.nix | 125 --------------- pkgs/top-level/all-packages.nix | 3 +- pkgs/top-level/java-packages.nix | 14 +- 13 files changed, 82 insertions(+), 276 deletions(-) delete mode 100644 pkgs/development/compilers/openjdk/darwin/8.nix rename pkgs/development/compilers/{openjdk/darwin => zulu}/11.nix (61%) rename pkgs/development/compilers/{openjdk/darwin => zulu}/16.nix (100%) rename pkgs/development/compilers/{openjdk/darwin => zulu}/17.nix (100%) rename pkgs/development/compilers/{openjdk/darwin => zulu}/18.nix (100%) rename pkgs/development/compilers/{openjdk/darwin => zulu}/19.nix (100%) rename pkgs/development/compilers/{openjdk/darwin => zulu}/20.nix (100%) create mode 100644 pkgs/development/compilers/zulu/21.nix rename pkgs/development/compilers/{openjdk/darwin => zulu}/common.nix (98%) delete mode 100644 pkgs/development/compilers/zulu/default.nix diff --git a/pkgs/development/compilers/openjdk/darwin/8.nix b/pkgs/development/compilers/openjdk/darwin/8.nix deleted file mode 100644 index b42681999cf7..000000000000 --- a/pkgs/development/compilers/openjdk/darwin/8.nix +++ /dev/null @@ -1,26 +0,0 @@ -{ callPackage -, enableJavaFX ? false -, ... -}@args: - -callPackage ./common.nix ({ - # 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 = { - zuluVersion = "8.72.0.17"; - jdkVersion = "8.0.382"; - hash = - if enableJavaFX then "sha256-/x8FqygivzddXsOwIV8aj/u+LPXMmokgu97vLAVEv80=" - else "sha256-3dTPIPGUeT6nb3gncNvEa4VTRyQIBJpp8oZadrT2ToE="; - }; - - aarch64-darwin = { - zuluVersion = "8.72.0.17"; - jdkVersion = "8.0.382"; - hash = - if enableJavaFX then "sha256-FkQ+0MzSZWUzc/HmiDVZEHGOrdKAVCdK5pm9wXXzzaU=" - else "sha256-rN5AI4xAWppE4kJlzMod0JmGyHdHjTXYtx8/wOW6CFk="; - }; - }; -} // builtins.removeAttrs args [ "callPackage" ]) diff --git a/pkgs/development/compilers/openjdk/darwin/11.nix b/pkgs/development/compilers/zulu/11.nix similarity index 61% rename from pkgs/development/compilers/openjdk/darwin/11.nix rename to pkgs/development/compilers/zulu/11.nix index 03880066f890..9272dc75c3e8 100644 --- a/pkgs/development/compilers/openjdk/darwin/11.nix +++ b/pkgs/development/compilers/zulu/11.nix @@ -7,6 +7,22 @@ callPackage ./common.nix ({ # 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-linux = { + zuluVersion = "11.66.15"; + jdkVersion = "11.0.20"; + hash = + if enableJavaFX then "sha256-CjWtqnirEDrpF61WXm/Yi372IzhpTpi+/AfEqirlZnc=" + else "sha256-o0tAT4egimEUizjhQW2DcYnh33oEDZSedDYz2vRpWjw="; + }; + + aarch64-linux = { + zuluVersion = "11.66.15"; + jdkVersion = "11.0.20"; + hash = + if enableJavaFX then throw "JavaFX is not available for aarch64-linux" + else "sha256-VBdEOfKz/d0R8QSMOX/nu0XUydZtRS1oibAT0E0hxN4="; + }; + x86_64-darwin = { zuluVersion = "11.66.15"; jdkVersion = "11.0.20"; diff --git a/pkgs/development/compilers/openjdk/darwin/16.nix b/pkgs/development/compilers/zulu/16.nix similarity index 100% rename from pkgs/development/compilers/openjdk/darwin/16.nix rename to pkgs/development/compilers/zulu/16.nix diff --git a/pkgs/development/compilers/openjdk/darwin/17.nix b/pkgs/development/compilers/zulu/17.nix similarity index 100% rename from pkgs/development/compilers/openjdk/darwin/17.nix rename to pkgs/development/compilers/zulu/17.nix diff --git a/pkgs/development/compilers/openjdk/darwin/18.nix b/pkgs/development/compilers/zulu/18.nix similarity index 100% rename from pkgs/development/compilers/openjdk/darwin/18.nix rename to pkgs/development/compilers/zulu/18.nix diff --git a/pkgs/development/compilers/openjdk/darwin/19.nix b/pkgs/development/compilers/zulu/19.nix similarity index 100% rename from pkgs/development/compilers/openjdk/darwin/19.nix rename to pkgs/development/compilers/zulu/19.nix diff --git a/pkgs/development/compilers/openjdk/darwin/20.nix b/pkgs/development/compilers/zulu/20.nix similarity index 100% rename from pkgs/development/compilers/openjdk/darwin/20.nix rename to pkgs/development/compilers/zulu/20.nix diff --git a/pkgs/development/compilers/zulu/21.nix b/pkgs/development/compilers/zulu/21.nix new file mode 100644 index 000000000000..0feaf6216bb1 --- /dev/null +++ b/pkgs/development/compilers/zulu/21.nix @@ -0,0 +1,26 @@ +{ callPackage +, enableJavaFX ? false +, ... +}@args: + +callPackage ./common.nix ({ + # Details from https://www.azul.com/downloads/?version=java-21-lts&package=jdk + # Note that the latest build may differ by platform + dists = { + x86_64-darwin = { + zuluVersion = "21.28.85"; + jdkVersion = "21.0.0"; + hash = + if enableJavaFX then "sha256-QrgEpLaNGc2aNFF38z2ckUTCpweKnuALYLOWATZFJPA=" + else "sha256-ljm4fbWG0MifepiSrkf0IeRCxkuXuuvf8xeI++IyZb0="; + }; + + aarch64-darwin = { + zuluVersion = "21.28.85"; + jdkVersion = "21.0.0"; + hash = + if enableJavaFX then "sha256-PUVB/R1K1dLTi1FsOYIvcI76M6EYYeMG1Bm+oMno//Y=" + else "sha256-KnqZo+omPb2NMqZ9Hm42O6iyXGRcgm9eFnoCu6+v8fo="; + }; + }; +} // builtins.removeAttrs args [ "callPackage" ]) diff --git a/pkgs/development/compilers/zulu/8.nix b/pkgs/development/compilers/zulu/8.nix index ed4d529ebd51..91aaaf06cd13 100644 --- a/pkgs/development/compilers/zulu/8.nix +++ b/pkgs/development/compilers/zulu/8.nix @@ -1,120 +1,34 @@ -{ stdenv -, lib -, fetchurl -, autoPatchelfHook -, unzip -, makeWrapper -, setJavaClassPath -, zulu -# minimum dependencies -, alsa-lib -, fontconfig -, freetype -, xorg -# runtime dependencies -, cups -# runtime dependencies for GTK+ Look and Feel -, gtkSupport ? stdenv.isLinux -, cairo -, glib -, gtk3 -}: +{ callPackage +, enableJavaFX ? false +, ... +}@args: -let - version = "8.68.0.19"; - openjdk = "8.0.362"; +callPackage ./common.nix ({ + # 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-linux = { + zuluVersion = "8.72.0.17"; + jdkVersion = "8.0.382"; + hash = + if enableJavaFX then "sha256-mIPCFESU7hy2naYur2jvFBtVn/LZQRcFiyiG61buCYs=" + else "sha256-exWlbyrgBb7aD4daJps9qtFP+hKWkwbMdFR4OFslupY="; + }; - sha256_linux = "sha256-jNty0iJoXG+sp7v2fGCrwZWCSZfQ4tkYe8ERixQMKL0="; - sha256_darwin = "sha256-3/P3puM6a7tCHP5eZM6IzbdPrqnhY1dTa7QWss9M08M="; + x86_64-darwin = { + zuluVersion = "8.72.0.17"; + jdkVersion = "8.0.382"; + hash = + if enableJavaFX then "sha256-/x8FqygivzddXsOwIV8aj/u+LPXMmokgu97vLAVEv80=" + else "sha256-3dTPIPGUeT6nb3gncNvEa4VTRyQIBJpp8oZadrT2ToE="; + }; - platform = if stdenv.isDarwin then "macosx" else "linux"; - hash = if stdenv.isDarwin then sha256_darwin else sha256_linux; - extension = if stdenv.isDarwin then "zip" else "tar.gz"; - - runtimeDependencies = [ - cups - ] ++ lib.optionals gtkSupport [ - cairo glib gtk3 - ]; - runtimeLibraryPath = lib.makeLibraryPath runtimeDependencies; - -in stdenv.mkDerivation { - inherit version openjdk platform hash extension; - - pname = "zulu"; - - src = fetchurl { - url = "https://cdn.azul.com/zulu/bin/zulu${version}-ca-jdk${openjdk}-${platform}_x64.${extension}"; - sha256 = hash; + aarch64-darwin = { + zuluVersion = "8.72.0.17"; + jdkVersion = "8.0.382"; + hash = + if enableJavaFX then "sha256-FkQ+0MzSZWUzc/HmiDVZEHGOrdKAVCdK5pm9wXXzzaU=" + else "sha256-rN5AI4xAWppE4kJlzMod0JmGyHdHjTXYtx8/wOW6CFk="; + }; }; - - buildInputs = lib.optionals stdenv.isLinux [ - alsa-lib # libasound.so wanted by lib/libjsound.so - fontconfig - freetype - stdenv.cc.cc # libstdc++.so.6 - xorg.libX11 - xorg.libXext - xorg.libXi - xorg.libXrender - xorg.libXtst - ]; - - nativeBuildInputs = [ - makeWrapper - ] ++ lib.optionals stdenv.isLinux [ - autoPatchelfHook - ] ++ lib.optionals stdenv.isDarwin [ - unzip - ]; - - installPhase = '' - runHook preInstall - - mkdir -p $out - cp -r ./* "$out/" - '' + lib.optionalString stdenv.isLinux '' - # jni.h expects jni_md.h to be in the header search path. - ln -s $out/include/linux/*_md.h $out/include/ - '' + '' - mkdir -p $out/nix-support - printWords ${setJavaClassPath} > $out/nix-support/propagated-build-inputs - - # Set JAVA_HOME automatically. - cat <> $out/nix-support/setup-hook - if [ -z "\''${JAVA_HOME-}" ]; then export JAVA_HOME=$out; fi - EOF - '' + lib.optionalString stdenv.isLinux '' - # We cannot use -exec since wrapProgram is a function but not a command. - for bin in $( find "$out" -executable -type f ); do - if patchelf --print-interpreter "$bin" &> /dev/null; then - wrapProgram "$bin" --prefix LD_LIBRARY_PATH : "${runtimeLibraryPath}" - fi - done - '' + '' - runHook postInstall - ''; - - preFixup = '' - find "$out" -name libfontmanager.so -exec \ - patchelf --add-needed libfontconfig.so {} \; - ''; - - passthru = { - home = zulu; - }; - - meta = with lib; { - homepage = "https://www.azul.com/products/zulu/"; - sourceProvenance = with sourceTypes; [ binaryBytecode binaryNativeCode ]; - license = licenses.gpl2; - description = "Certified builds of OpenJDK"; - longDescription = '' - Certified builds of OpenJDK that can be deployed across multiple - operating systems, containers, hypervisors and Cloud platforms. - ''; - maintainers = with maintainers; [ ]; - platforms = [ "x86_64-linux" "x86_64-darwin" ]; - mainProgram = "java"; - }; -} +} // builtins.removeAttrs args [ "callPackage" ]) diff --git a/pkgs/development/compilers/openjdk/darwin/common.nix b/pkgs/development/compilers/zulu/common.nix similarity index 98% rename from pkgs/development/compilers/openjdk/darwin/common.nix rename to pkgs/development/compilers/zulu/common.nix index 6972c186bfa4..d09555b00c9c 100644 --- a/pkgs/development/compilers/openjdk/darwin/common.nix +++ b/pkgs/development/compilers/zulu/common.nix @@ -142,7 +142,7 @@ let home = jdk; }; - meta = (import ../../openjdk/meta.nix lib version) // { + meta = (import ../openjdk/meta.nix lib version) // { description = "Certified builds of OpenJDK"; longDescription = '' Certified builds of OpenJDK that can be deployed across multiple diff --git a/pkgs/development/compilers/zulu/default.nix b/pkgs/development/compilers/zulu/default.nix deleted file mode 100644 index 045aa4e5abae..000000000000 --- a/pkgs/development/compilers/zulu/default.nix +++ /dev/null @@ -1,125 +0,0 @@ -{ stdenv -, lib -, fetchurl -, autoPatchelfHook -, unzip -, makeWrapper -, setJavaClassPath -, zulu -# minimum dependencies -, alsa-lib -, fontconfig -, freetype -, zlib -, xorg -# runtime dependencies -, cups -# runtime dependencies for GTK+ Look and Feel -, gtkSupport ? stdenv.isLinux -, cairo -, glib -, gtk3 -}: - -let - version = "11.62.17"; - openjdk = "11.0.18"; - - sha256_x64_linux = "sha256-b65oEbDzrrsUw+WaX94USBz/QS74yiMiGZPxqzMmmqs="; - sha256_x64_darwin = "sha256-nRRWTWiog8bRblmmPIPE5YibA34St3ZrJpZN91qEDUg="; - sha256_aarch64_darwin = "sha256-TBTrBxOfGo6MV+Md49P3sDfqVG1e+NraqfVbw9WTppk="; - - platform = if stdenv.isDarwin then "macosx" else "linux"; - hash = if stdenv.isAarch64 && stdenv.isDarwin then sha256_aarch64_darwin else if stdenv.isDarwin then sha256_x64_darwin else sha256_x64_linux; - extension = if stdenv.isDarwin then "zip" else "tar.gz"; - architecture = if stdenv.isAarch64 then "aarch64" else "x64"; - - runtimeDependencies = [ - cups - ] ++ lib.optionals gtkSupport [ - cairo glib gtk3 - ]; - runtimeLibraryPath = lib.makeLibraryPath runtimeDependencies; - -in stdenv.mkDerivation { - inherit version openjdk platform hash extension; - - pname = "zulu"; - - src = fetchurl { - url = "https://cdn.azul.com/zulu/bin/zulu${version}-ca-jdk${openjdk}-${platform}_${architecture}.${extension}"; - sha256 = hash; - }; - - buildInputs = lib.optionals stdenv.isLinux [ - alsa-lib # libasound.so wanted by lib/libjsound.so - fontconfig - freetype - stdenv.cc.cc # libstdc++.so.6 - xorg.libX11 - xorg.libXext - xorg.libXi - xorg.libXrender - xorg.libXtst - zlib - ]; - - nativeBuildInputs = [ - makeWrapper - ] ++ lib.optionals stdenv.isLinux [ - autoPatchelfHook - ] ++ lib.optionals stdenv.isDarwin [ - unzip - ]; - - installPhase = '' - runHook preInstall - - mkdir -p $out - cp -r ./* "$out/" - '' + lib.optionalString stdenv.isLinux '' - # jni.h expects jni_md.h to be in the header search path. - ln -s $out/include/linux/*_md.h $out/include/ - '' + '' - mkdir -p $out/nix-support - printWords ${setJavaClassPath} > $out/nix-support/propagated-build-inputs - - # Set JAVA_HOME automatically. - cat <> $out/nix-support/setup-hook - if [ -z "\''${JAVA_HOME-}" ]; then export JAVA_HOME=$out; fi - EOF - '' + lib.optionalString stdenv.isLinux '' - # We cannot use -exec since wrapProgram is a function but not a command. - # - # jspawnhelper is executed from JVM, so it doesn't need to wrap it, and it - # breaks building OpenJDK (#114495). - for bin in $( find "$out" -executable -type f -not -name jspawnhelper ); do - wrapProgram "$bin" --prefix LD_LIBRARY_PATH : "${runtimeLibraryPath}" - done - '' + '' - runHook postInstall - ''; - - preFixup = '' - find "$out" -name libfontmanager.so -exec \ - patchelf --add-needed libfontconfig.so {} \; - ''; - - passthru = { - home = zulu; - }; - - meta = with lib; { - homepage = "https://www.azul.com/products/zulu/"; - sourceProvenance = with sourceTypes; [ binaryBytecode binaryNativeCode ]; - license = licenses.gpl2; - description = "Certified builds of OpenJDK"; - longDescription = '' - Certified builds of OpenJDK that can be deployed across multiple - operating systems, containers, hypervisors and Cloud platforms. - ''; - maintainers = with maintainers; [ ]; - platforms = [ "x86_64-linux" "x86_64-darwin" "aarch64-darwin" ]; - mainProgram = "java"; - }; -} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 7a590c236b41..a5680ac98a5a 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -17688,7 +17688,8 @@ with pkgs; zulip-term = callPackage ../applications/networking/instant-messengers/zulip-term { }; zulu8 = callPackage ../development/compilers/zulu/8.nix { }; - zulu = callPackage ../development/compilers/zulu { }; + zulu11 = callPackage ../development/compilers/zulu/11.nix { }; + zulu = zulu11; ### DEVELOPMENT / INTERPRETERS diff --git a/pkgs/top-level/java-packages.nix b/pkgs/top-level/java-packages.nix index 5d938a12e829..6e1d0939c3e8 100644 --- a/pkgs/top-level/java-packages.nix +++ b/pkgs/top-level/java-packages.nix @@ -141,12 +141,12 @@ in { openjdk8 = mkOpenjdk ../development/compilers/openjdk/8.nix - ../development/compilers/openjdk/darwin/8.nix + ../development/compilers/zulu/8.nix { }; openjdk11 = mkOpenjdk ../development/compilers/openjdk/11.nix - ../development/compilers/openjdk/darwin/11.nix + ../development/compilers/zulu/11.nix { openjfx = openjfx11; }; openjdk12 = mkOpenjdkLinuxOnly ../development/compilers/openjdk/12.nix { @@ -172,7 +172,7 @@ in { openjdk16 = mkOpenjdk ../development/compilers/openjdk/16.nix - ../development/compilers/openjdk/darwin/16.nix + ../development/compilers/zulu/16.nix { inherit openjdk16-bootstrap; openjfx = openjfx15; @@ -180,7 +180,7 @@ in { openjdk17 = mkOpenjdk ../development/compilers/openjdk/17.nix - ../development/compilers/openjdk/darwin/17.nix + ../development/compilers/zulu/17.nix { inherit openjdk17-bootstrap; openjfx = openjfx17; @@ -188,7 +188,7 @@ in { openjdk18 = mkOpenjdk ../development/compilers/openjdk/18.nix - ../development/compilers/openjdk/darwin/18.nix + ../development/compilers/zulu/18.nix { inherit openjdk18-bootstrap; openjfx = openjfx17; @@ -196,7 +196,7 @@ in { openjdk19 = mkOpenjdk ../development/compilers/openjdk/19.nix - ../development/compilers/openjdk/darwin/19.nix + ../development/compilers/zulu/19.nix { openjdk19-bootstrap = temurin-bin.jdk-19; openjfx = openjfx19; @@ -204,7 +204,7 @@ in { openjdk20 = mkOpenjdk ../development/compilers/openjdk/20.nix - ../development/compilers/openjdk/darwin/20.nix + ../development/compilers/zulu/20.nix { openjdk20-bootstrap = temurin-bin.jdk-20; openjfx = openjfx20;