Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ 2 name-prefix ? "temurin", 3 brand-name ? "Eclipse Temurin", 4 sourcePerArch, 5 knownVulnerabilities ? [ ], 6}: 7 8{ 9 stdenv, 10 lib, 11 fetchurl, 12 autoPatchelfHook, 13 makeWrapper, 14 setJavaClassPath, 15 # minimum dependencies 16 alsa-lib, 17 fontconfig, 18 freetype, 19 libffi, 20 xorg, 21 zlib, 22 # runtime dependencies 23 cups, 24 # runtime dependencies for GTK+ Look and Feel 25 # TODO(@sternenseemann): gtk3 fails to evaluate in pkgsCross.ghcjs.buildPackages 26 # which should be fixable, this is a no-rebuild workaround for GHC. 27 gtkSupport ? !stdenv.targetPlatform.isGhcjs, 28 cairo, 29 glib, 30 gtk3, 31}: 32 33let 34 cpuName = stdenv.hostPlatform.parsed.cpu.name; 35 runtimeDependencies = [ 36 cups 37 ] 38 ++ lib.optionals gtkSupport [ 39 cairo 40 glib 41 gtk3 42 ]; 43 runtimeLibraryPath = lib.makeLibraryPath runtimeDependencies; 44 validCpuTypes = builtins.attrNames lib.systems.parse.cpuTypes; 45 providedCpuTypes = builtins.filter (arch: builtins.elem arch validCpuTypes) ( 46 builtins.attrNames sourcePerArch 47 ); 48 result = stdenv.mkDerivation { 49 pname = 50 if sourcePerArch.packageType == "jdk" then 51 "${name-prefix}-bin" 52 else 53 "${name-prefix}-${sourcePerArch.packageType}-bin"; 54 55 version = sourcePerArch.${cpuName}.version or (throw "unsupported CPU ${cpuName}"); 56 57 src = fetchurl { 58 inherit (sourcePerArch.${cpuName}) url sha256; 59 }; 60 61 buildInputs = [ 62 alsa-lib # libasound.so wanted by lib/libjsound.so 63 fontconfig 64 freetype 65 (lib.getLib stdenv.cc.cc) # libstdc++.so.6 66 xorg.libX11 67 xorg.libXext 68 xorg.libXi 69 xorg.libXrender 70 xorg.libXtst 71 zlib 72 ] 73 ++ lib.optional stdenv.hostPlatform.isAarch32 libffi; 74 75 nativeBuildInputs = [ 76 autoPatchelfHook 77 makeWrapper 78 ]; 79 80 # See: https://github.com/NixOS/patchelf/issues/10 81 dontStrip = 1; 82 83 installPhase = '' 84 cd .. 85 86 mv $sourceRoot $out 87 88 # jni.h expects jni_md.h to be in the header search path. 89 ln -s $out/include/linux/*_md.h $out/include/ 90 91 # Remove some broken manpages. 92 # Only for 11 and earlier. 93 [ -e "$out/man/ja" ] && rm -r $out/man/ja* 94 95 # Remove embedded freetype to avoid problems like 96 # https://github.com/NixOS/nixpkgs/issues/57733 97 find "$out" -name 'libfreetype.so*' -delete 98 99 # Propagate the setJavaClassPath setup hook from the JDK so that 100 # any package that depends on the JDK has $CLASSPATH set up 101 # properly. 102 mkdir -p $out/nix-support 103 printWords ${setJavaClassPath} > $out/nix-support/propagated-build-inputs 104 105 # Set JAVA_HOME automatically. 106 cat <<EOF >> "$out/nix-support/setup-hook" 107 if [ -z "\''${JAVA_HOME-}" ]; then export JAVA_HOME=$out; fi 108 EOF 109 110 # We cannot use -exec since wrapProgram is a function but not a command. 111 # 112 # jspawnhelper is executed from JVM, so it doesn't need to wrap it, and it 113 # breaks building OpenJDK (#114495). 114 for bin in $( find "$out" -executable -type f -not -name jspawnhelper ); do 115 if patchelf --print-interpreter "$bin" &> /dev/null; then 116 wrapProgram "$bin" --prefix LD_LIBRARY_PATH : "${runtimeLibraryPath}" 117 fi 118 done 119 ''; 120 121 preFixup = '' 122 find "$out" -name libfontmanager.so -exec \ 123 patchelf --add-needed libfontconfig.so {} \; 124 ''; 125 126 # FIXME: use multiple outputs or return actual JRE package 127 passthru = { 128 jre = result; 129 home = result; 130 }; 131 132 meta = with lib; { 133 license = licenses.gpl2Classpath; 134 sourceProvenance = with sourceTypes; [ 135 binaryNativeCode 136 binaryBytecode 137 ]; 138 description = "${brand-name}, prebuilt OpenJDK binary"; 139 platforms = builtins.map (arch: arch + "-linux") providedCpuTypes; # some inherit jre.meta.platforms 140 maintainers = with maintainers; [ taku0 ]; 141 teams = [ teams.java ]; 142 inherit knownVulnerabilities; 143 mainProgram = "java"; 144 }; 145 }; 146in 147result