@@ -1,8 +1,11 @@
1−{ stdenv, fetchurl, cpio, pkgconfig, file, which, unzip, zip, xorg, cups, freetype
2−, alsaLib, bootjdk, cacert, perl, liberation_ttf, fontconfig, zlib
1+{ stdenv, lib, fetchurl, cpio, pkgconfig, file, which, unzip, zip, cups, freetype
2+, alsaLib, bootjdk, cacert, perl, liberation_ttf, fontconfig, zlib, lndir
3+, libX11, libICE, libXrender, libXext, libXt, libXtst, libXi, libXinerama, libXcursor
4+, libjpeg, giflib
35, setJavaClassPath
46, minimal ? false
57, enableInfinality ? true # font rendering patch
8+, enableGnome2 ? true, gtk2, gnome_vfs, glib, GConf
69}:
710
811let
@@ -65,10 +68,11 @@ let
6568
6669 nativeBuildInputs = [ pkgconfig ];
6770 buildInputs = [
68− cpio file which unzip zip
69− xorg.libX11 xorg.libXt xorg.libXext xorg.libXrender xorg.libXtst
70− xorg.libXi xorg.libXinerama xorg.libXcursor xorg.lndir
71− cups freetype alsaLib perl liberation_ttf fontconfig bootjdk zlib
71+ cpio file which unzip zip perl bootjdk zlib cups freetype alsaLib
72+ libjpeg giflib libX11 libICE libXext libXrender libXtst libXt libXtst
73+ libXi libXinerama libXcursor lndir fontconfig
74+ ] ++ lib.optionals (!minimal && enableGnome2) [
75+ gtk2 gnome_vfs GConf glib
7276 ];
7377
7478 prePatch = ''
@@ -82,10 +86,12 @@ let
8286 ./fix-java-home-jdk8.patch
8387 ./read-truststore-from-env-jdk8.patch
8488 ./currency-date-range-jdk8.patch
85− ] ++ (if enableInfinality then [
89+ ] ++ lib.optionals (!minimal && enableInfinality) [
8690 ./004_add-fontconfig.patch
8791 ./005_enable-infinality.patch
88− ] else []);
92+ ] ++ lib.optionals (!minimal && enableGnome2) [
93+ ./swing-use-gtk.patch
94+ ];
8995
9096 preConfigure = ''
9197 chmod +x configure
@@ -101,21 +107,22 @@ let
101107 "--enable-unlimited-crypto"
102108 "--disable-debug-symbols"
103109 "--disable-freetype-bundling"
110+ "--with-zlib=system"
111+ "--with-giflib=system"
112+ "--with-stdc++lib=dynamic"
104113
105114 # glibc 2.24 deprecated readdir_r so we need this
106115 # See https://www.mail-archive.com/openembedded-devel@lists.openembedded.org/msg49006.html
107116 "--with-extra-cflags=\"-Wno-error=deprecated-declarations\""
108− ] ++ (if minimal then [
109− "--disable-headful"
110− "--with-zlib=bundled"
111− "--with-giflib=bundled"
112− ] else [
113− "--with-zlib=system"
114− ]);
117+ ] ++ lib.optional minimal "--disable-headful";
115118
116− NIX_LDFLAGS= if minimal then null else "-lfontconfig";
119+ NIX_LDFLAGS= lib.optionals (!minimal) [
120+ "-lfontconfig" "-lcups" "-lXinerama" "-lXrandr" "-lmagic"
121+ ] ++ lib.optionals (!minimal && enableGnome2) [
122+ "-lgtk-x11-2.0" "-lgio-2.0" "-lgnomevfs-2" "-lgconf-2"
123+ ];
117124
118− buildFlags = "all";
125+ buildFlags = [ "all" ];
119126
120127 installPhase = ''
121128 mkdir -p $out/lib/openjdk $out/share $jre/lib/openjdk
@@ -135,12 +142,19 @@ let
135142
136143 # Remove crap from the installation.
137144 rm -rf $out/lib/openjdk/demo $out/lib/openjdk/sample
145+ ${lib.optionalString minimal ''
146+ rm $out/lib/openjdk/jre/lib/${architecture}/{libjsound,libjsoundalsa,libsplashscreen,libawt*,libfontmanager}.so
147+ rm $out/lib/openjdk/jre/bin/policytool
148+ rm $out/lib/openjdk/bin/{policytool,appletviewer}
149+ ''}
138150
139151 # Move the JRE to a separate output and setup fallback fonts
140152 mv $out/lib/openjdk/jre $jre/lib/openjdk/
141153 mkdir $out/lib/openjdk/jre
142− mkdir -p $jre/lib/openjdk/jre/lib/fonts/fallback
143− lndir ${liberation_ttf}/share/fonts/truetype $jre/lib/openjdk/jre/lib/fonts/fallback
154+ ${lib.optionalString (!minimal) ''
155+ mkdir -p $jre/lib/openjdk/jre/lib/fonts/fallback
156+ lndir ${liberation_ttf}/share/fonts/truetype $jre/lib/openjdk/jre/lib/fonts/fallback
157+ ''}
144158 lndir $jre/lib/openjdk/jre $out/lib/openjdk/jre
145159
146160 rm -rf $out/lib/openjdk/jre/bina