16 , pluginSupport ? true
35 assert swingSupport -> xorg != null;
40 * The JRE libraries are in directories that depend on the CPU.
44 x86_64-linux = "amd64";
46 aarch64-linux = "aarch64";
47 }.${stdenv.hostPlatform.system} or (throw "unsupported system ${stdenv.hostPlatform.system}");
53 url = "http://www.oracle.com/technetwork/java/javase/downloads/jce8-download-2133166.html";
60 "lib/${architecture}/jli"
61 "lib/${architecture}/server"
62 "lib/${architecture}/xawt"
68 let result = stdenv.mkDerivation rec {
69 pname = if installjdk then "oraclejdk" else "oraclejre" + lib.optionalString pluginSupport "-with-plugin";
70 version = "${productVersion}u${patchVersion}";
75 i686-linux = "linux-i586";
76 x86_64-linux = "linux-x64";
77 armv7l-linux = "linux-arm32-vfp-hflt";
78 aarch64-linux = "linux-aarch64";
79 }.${stdenv.hostPlatform.system} or (throw "unsupported system ${stdenv.hostPlatform.system}");
81 name = "jdk-${productVersion}u${patchVersion}-${platformName}.tar.gz";
82 url = "http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html";
83 sha256 = sha256.${stdenv.hostPlatform.system} or (throw "unsupported system ${stdenv.hostPlatform.system}");
86 nativeBuildInputs = [ file makeWrapper ]
87 ++ lib.optional installjce unzip;
89 # See: https://github.com/NixOS/patchelf/issues/10
95 if test -z "$installjdk"; then
96 mv $sourceRoot/jre $out
102 for file in $out/!(*src.zip)
104 if test -f $file ; then
109 if test -n "$installjdk"; then
110 for file in $out/jre/*
112 if test -f $file ; then
118 if test -z "$installjdk"; then
124 if test -n "${jce}"; then
126 cp -v UnlimitedJCEPolicy*/*.jar $jrePath/lib/security
129 if test -z "$pluginSupport"; then
130 rm -f $out/bin/javaws
131 if test -n "$installjdk"; then
132 rm -f $out/jre/bin/javaws
136 mkdir $jrePath/lib/${architecture}/plugins
137 ln -s $jrePath/lib/${architecture}/libnpjp2.so $jrePath/lib/${architecture}/plugins
139 mkdir -p $out/nix-support
140 printWords ${setJavaClassPath} > $out/nix-support/propagated-build-inputs
142 # Set JAVA_HOME automatically.
143 cat <<EOF >> $out/nix-support/setup-hook
144 if [ -z "\''${JAVA_HOME-}" ]; then export JAVA_HOME=$out; fi
149 rpath+="''${rpath:+:}${lib.concatStringsSep ":" (map (a: "$jrePath/${a}") rSubPaths)}"
151 # set all the dynamic linkers
152 find $out -type f -perm -0100 \
153 -exec patchelf --interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
154 --set-rpath "$rpath" {} \;
156 find $out -name "*.so" -exec patchelf --set-rpath "$rpath" {} \;
158 # Oracle Java Mission Control needs to know where libgtk-x11 and related is
159 if test -n "$installjdk" -a -x $out/bin/jmc; then
160 wrapProgram "$out/bin/jmc" \
161 --suffix-each LD_LIBRARY_PATH ':' "$rpath"
165 inherit installjdk pluginSupport;
168 * libXt is only needed on amd64
171 [stdenv.cc.libc glib libxml2 ffmpeg libxslt libGL xorg.libXxf86vm alsa-lib fontconfig freetype pango gtk2 cairo gdk-pixbuf atk] ++
172 lib.optionals swingSupport [xorg.libX11 xorg.libXext xorg.libXtst xorg.libXi xorg.libXp xorg.libXt xorg.libXrender stdenv.cc.cc];
174 rpath = lib.strings.makeLibraryPath libraries;
176 passthru.mozillaPlugin = if installjdk then "/jre/lib/${architecture}/plugins" else "/lib/${architecture}/plugins";
178 passthru.jre = result; # FIXME: use multiple outputs or return actual JRE package
180 passthru.home = result;
182 passthru.architecture = architecture;
185 license = licenses.unfree;
186 platforms = [ "i686-linux" "x86_64-linux" "armv7l-linux" "aarch64-linux" ]; # some inherit jre.meta.platforms
187 mainProgram = "java";