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