diff --git a/pkgs/development/compilers/temurin-bin/jdk-darwin-base.nix b/pkgs/development/compilers/temurin-bin/jdk-darwin-base.nix index c4234ab3fda9..58803637f81c 100644 --- a/pkgs/development/compilers/temurin-bin/jdk-darwin-base.nix +++ b/pkgs/development/compilers/temurin-bin/jdk-darwin-base.nix @@ -19,7 +19,7 @@ let providedCpuTypes = builtins.filter (arch: builtins.elem arch validCpuTypes) ( builtins.attrNames sourcePerArch ); - result = stdenv.mkDerivation { + result = stdenv.mkDerivation (finalAttrs: { pname = if sourcePerArch.packageType == "jdk" then "${name-prefix}-bin" @@ -40,16 +40,19 @@ let installPhase = '' cd .. - mv $sourceRoot $out + mkdir -p $out/Library/Java/JavaVirtualMachines + + bundle=$out/Library/Java/JavaVirtualMachines/${name-prefix}-${lib.versions.major finalAttrs.version}.jdk + mv $sourceRoot $bundle # jni.h expects jni_md.h to be in the header search path. - ln -s $out/Contents/Home/include/darwin/*_md.h $out/Contents/Home/include/ + ln -s $bundle/Contents/Home/include/darwin/*_md.h $bundle/Contents/Home/include/ # Remove some broken manpages. # Only for 11 and earlier. - [ -e "$out/Contents/Home/man/ja" ] && rm -r $out/Contents/Home/man/ja + [ -e "$bundle/Contents/Home/man/ja" ] && rm -r $bundle/Contents/Home/man/ja - ln -s $out/Contents/Home/* $out/ + ln -s $bundle/Contents/Home/* $out/ # Propagate the setJavaClassPath setup hook from the JDK so that # any package that depends on the JDK has $CLASSPATH set up @@ -65,8 +68,9 @@ let # FIXME: use multiple outputs or return actual JRE package passthru = { - jre = result; - home = result; + jre = finalAttrs.finalPackage; + home = finalAttrs.finalPackage; + bundle = "${finalAttrs.finalPackage}/Library/Java/JavaVirtualMachines/${name-prefix}-${lib.versions.major finalAttrs.version}.jdk"; }; meta = with lib; { @@ -81,6 +85,6 @@ let inherit knownVulnerabilities; mainProgram = "java"; }; - }; + }); in result diff --git a/pkgs/development/compilers/zulu/common.nix b/pkgs/development/compilers/zulu/common.nix index 1db9ba9b625d..758b5c0e81d7 100644 --- a/pkgs/development/compilers/zulu/common.nix +++ b/pkgs/development/compilers/zulu/common.nix @@ -116,21 +116,30 @@ let else null; - installPhase = '' - mkdir -p $out - mv * $out + installPhase = + '' + mkdir -p $out + mv * $out + '' + + lib.optionalString stdenv.hostPlatform.isDarwin '' + mkdir -p $out/Library/Java/JavaVirtualMachines + bundle=$out/Library/Java/JavaVirtualMachines/zulu-${lib.versions.major version}.jdk + mv $out/zulu-${lib.versions.major version}.jdk $bundle + ln -sf $bundle/Contents/Home/* $out/ + '' + + '' - unzip ${jce-policies} - mv -f ZuluJCEPolicies/*.jar $out/${lib.optionalString isJdk8 "jre/"}lib/security/ + 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/${stdenv.hostPlatform.parsed.kernel.name}/*_md.h $out/include/ + # jni.h expects jni_md.h to be in the header search path. + 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 - rm $out/LICENSE - fi - ''; + if [ -f $out/LICENSE ]; then + install -D $out/LICENSE $out/share/zulu/LICENSE + rm $out/LICENSE + fi + ''; preFixup = '' @@ -174,6 +183,9 @@ let }) // { home = jdk; + } + // lib.optionalAttrs stdenv.hostPlatform.isDarwin { + bundle = "${jdk}/Library/Java/JavaVirtualMachines/zulu-${lib.versions.major version}.jdk"; }; meta = {