nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at 22.05 162 lines 5.8 kB view raw
1{ stdenv, lib, fetchurl, bash, pkg-config, autoconf, cpio, file, which, unzip 2, zip, perl, cups, freetype, alsa-lib, libjpeg, giflib, libpng, zlib, lcms2 3, libX11, libICE, libXrender, libXext, libXt, libXtst, libXi, libXinerama 4, libXcursor, libXrandr, fontconfig, openjdk13-bootstrap, fetchpatch 5, setJavaClassPath 6, headless ? false 7, enableJavaFX ? openjfx.meta.available, openjfx 8, enableGnome2 ? true, gtk3, gnome_vfs, glib, GConf 9}: 10 11let 12 major = "13"; 13 update = ".0.2"; 14 build = "-ga"; 15 16 openjdk = stdenv.mkDerivation rec { 17 pname = "openjdk" + lib.optionalString headless "-headless"; 18 version = "${major}${update}${build}"; 19 20 src = fetchurl { 21 url = "http://hg.openjdk.java.net/jdk-updates/jdk${major}u/archive/jdk-${version}.tar.gz"; 22 sha256 = "1871ziss7ny19rw8f7bay5vznmhpqbfi4ihn3yygs06wyxhm0zmv"; 23 }; 24 25 nativeBuildInputs = [ pkg-config autoconf unzip ]; 26 buildInputs = [ 27 cpio file which zip perl zlib cups freetype alsa-lib libjpeg giflib 28 libpng zlib lcms2 libX11 libICE libXrender libXext libXtst libXt libXtst 29 libXi libXinerama libXcursor libXrandr fontconfig openjdk13-bootstrap 30 ] ++ lib.optionals (!headless && enableGnome2) [ 31 gtk3 gnome_vfs GConf glib 32 ]; 33 34 patches = [ 35 ./fix-java-home-jdk10.patch 36 ./read-truststore-from-env-jdk10.patch 37 ./currency-date-range-jdk10.patch 38 ./increase-javadoc-heap-jdk13.patch 39 # -Wformat etc. are stricter in newer gccs, per 40 # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79677 41 # so grab the work-around from 42 # https://src.fedoraproject.org/rpms/java-openjdk/pull-request/24 43 (fetchurl { 44 url = "https://src.fedoraproject.org/rpms/java-openjdk/raw/06c001c7d87f2e9fe4fedeef2d993bcd5d7afa2a/f/rh1673833-remove_removal_of_wformat_during_test_compilation.patch"; 45 sha256 = "082lmc30x64x583vqq00c8y0wqih3y4r0mp1c4bqq36l22qv6b6r"; 46 }) 47 # Fix gnumake 4.3 incompatibility 48 (fetchpatch { 49 url = "https://github.com/openjdk/panama-foreign/commit/af5c725b8109ce83fc04ef0f8bf6aaf0b50c0441.patch"; 50 sha256 = "0ja84kih5wkjn58pml53s59qnavb1z92dc88cbgw7vcyqwc1gs0h"; 51 }) 52 ] ++ lib.optionals (!headless && enableGnome2) [ 53 ./swing-use-gtk-jdk13.patch 54 ]; 55 56 prePatch = '' 57 chmod +x configure 58 patchShebangs --build configure 59 ''; 60 61 configureFlags = [ 62 "--with-boot-jdk=${openjdk13-bootstrap.home}" 63 "--with-version-pre=" 64 "--enable-unlimited-crypto" 65 "--with-native-debug-symbols=internal" 66 "--with-libjpeg=system" 67 "--with-giflib=system" 68 "--with-libpng=system" 69 "--with-zlib=system" 70 "--with-lcms=system" 71 "--with-stdc++lib=dynamic" 72 ] ++ lib.optional stdenv.isx86_64 "--with-jvm-features=zgc" 73 ++ lib.optional headless "--enable-headless-only" 74 ++ lib.optional (!headless && enableJavaFX) "--with-import-modules=${openjfx}"; 75 76 separateDebugInfo = true; 77 78 NIX_CFLAGS_COMPILE = "-Wno-error"; 79 80 NIX_LDFLAGS = toString (lib.optionals (!headless) [ 81 "-lfontconfig" "-lcups" "-lXinerama" "-lXrandr" "-lmagic" 82 ] ++ lib.optionals (!headless && enableGnome2) [ 83 "-lgtk-3" "-lgio-2.0" "-lgnomevfs-2" "-lgconf-2" 84 ]); 85 86 # -j flag is explicitly rejected by the build system: 87 # Error: 'make -jN' is not supported, use 'make JOBS=N' 88 # Note: it does not make build sequential. Build system 89 # still runs in parallel. 90 enableParallelBuilding = false; 91 92 buildFlags = [ "all" ]; 93 94 installPhase = '' 95 mkdir -p $out/lib 96 97 mv build/*/images/jdk $out/lib/openjdk 98 99 # Remove some broken manpages. 100 rm -rf $out/lib/openjdk/man/ja* 101 102 # Mirror some stuff in top-level. 103 mkdir -p $out/share 104 ln -s $out/lib/openjdk/include $out/include 105 ln -s $out/lib/openjdk/man $out/share/man 106 107 # jni.h expects jni_md.h to be in the header search path. 108 ln -s $out/include/linux/*_md.h $out/include/ 109 110 # Remove crap from the installation. 111 rm -rf $out/lib/openjdk/demo 112 ${lib.optionalString headless '' 113 rm $out/lib/openjdk/lib/{libjsound,libfontmanager}.so 114 ''} 115 116 ln -s $out/lib/openjdk/bin $out/bin 117 ''; 118 119 preFixup = '' 120 # Propagate the setJavaClassPath setup hook so that any package 121 # that depends on the JDK has $CLASSPATH set up properly. 122 mkdir -p $out/nix-support 123 #TODO or printWords? cf https://github.com/NixOS/nixpkgs/pull/27427#issuecomment-317293040 124 echo -n "${setJavaClassPath}" > $out/nix-support/propagated-build-inputs 125 126 # Set JAVA_HOME automatically. 127 mkdir -p $out/nix-support 128 cat <<EOF > $out/nix-support/setup-hook 129 if [ -z "\''${JAVA_HOME-}" ]; then export JAVA_HOME=$out/lib/openjdk; fi 130 EOF 131 ''; 132 133 postFixup = '' 134 # Build the set of output library directories to rpath against 135 LIBDIRS="" 136 for output in $outputs; do 137 if [ "$output" = debug ]; then continue; fi 138 LIBDIRS="$(find $(eval echo \$$output) -name \*.so\* -exec dirname {} \+ | sort | uniq | tr '\n' ':'):$LIBDIRS" 139 done 140 # Add the local library paths to remove dependencies on the bootstrap 141 for output in $outputs; do 142 if [ "$output" = debug ]; then continue; fi 143 OUTPUTDIR=$(eval echo \$$output) 144 BINLIBS=$(find $OUTPUTDIR/bin/ -type f; find $OUTPUTDIR -name \*.so\*) 145 echo "$BINLIBS" | while read i; do 146 patchelf --set-rpath "$LIBDIRS:$(patchelf --print-rpath "$i")" "$i" || true 147 patchelf --shrink-rpath "$i" || true 148 done 149 done 150 ''; 151 152 disallowedReferences = [ openjdk13-bootstrap ]; 153 154 meta = import ./meta.nix lib version; 155 156 passthru = { 157 architecture = ""; 158 home = "${openjdk}/lib/openjdk"; 159 inherit gtk3; 160 }; 161 }; 162in openjdk