2014-05-11 11:13:52 +01:00
|
|
|
{ productVersion
|
|
|
|
, patchVersion
|
|
|
|
, downloadUrl
|
|
|
|
, sha256_i686
|
|
|
|
, sha256_x86_64
|
|
|
|
, jceName
|
|
|
|
, jceDownloadUrl
|
|
|
|
, sha256JCE
|
|
|
|
}:
|
|
|
|
|
|
|
|
{ swingSupport ? true
|
|
|
|
, stdenv
|
|
|
|
, requireFile
|
|
|
|
, unzip
|
2014-06-22 13:37:09 +01:00
|
|
|
, file
|
2015-09-15 10:26:18 +01:00
|
|
|
, xorg ? null
|
2014-05-11 11:13:52 +01:00
|
|
|
, installjdk ? true
|
|
|
|
, pluginSupport ? true
|
|
|
|
, installjce ? false
|
|
|
|
, glib
|
|
|
|
, libxml2
|
|
|
|
, libav_0_8
|
|
|
|
, ffmpeg
|
|
|
|
, libxslt
|
|
|
|
, mesa_noglu
|
|
|
|
, freetype
|
|
|
|
, fontconfig
|
|
|
|
, gnome
|
|
|
|
, cairo
|
|
|
|
, alsaLib
|
|
|
|
, atk
|
|
|
|
, gdk_pixbuf
|
2014-07-16 17:23:47 +01:00
|
|
|
, setJavaClassPath
|
2014-05-11 11:13:52 +01:00
|
|
|
}:
|
|
|
|
|
|
|
|
assert stdenv.system == "i686-linux" || stdenv.system == "x86_64-linux";
|
2015-09-15 10:26:18 +01:00
|
|
|
assert swingSupport -> xorg != null;
|
2014-05-11 11:13:52 +01:00
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The JRE libraries are in directories that depend on the CPU.
|
|
|
|
*/
|
|
|
|
architecture =
|
|
|
|
if stdenv.system == "i686-linux" then
|
|
|
|
"i386"
|
|
|
|
else if stdenv.system == "x86_64-linux" then
|
|
|
|
"amd64"
|
|
|
|
else
|
|
|
|
abort "jdk requires i686-linux or x86_64 linux";
|
|
|
|
|
|
|
|
jce =
|
|
|
|
if installjce then
|
|
|
|
requireFile {
|
|
|
|
name = jceName;
|
|
|
|
url = jceDownloadUrl;
|
|
|
|
sha256 = sha256JCE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
"";
|
|
|
|
in
|
|
|
|
|
2014-07-16 17:23:47 +01:00
|
|
|
let result = stdenv.mkDerivation rec {
|
2014-05-11 11:13:52 +01:00
|
|
|
name =
|
2014-07-16 17:10:56 +01:00
|
|
|
if installjdk then "oraclejdk-${productVersion}u${patchVersion}" else "oraclejre-${productVersion}u${patchVersion}";
|
2014-05-11 11:13:52 +01:00
|
|
|
|
|
|
|
src =
|
|
|
|
if stdenv.system == "i686-linux" then
|
|
|
|
requireFile {
|
|
|
|
name = "jdk-${productVersion}u${patchVersion}-linux-i586.tar.gz";
|
|
|
|
url = downloadUrl;
|
|
|
|
sha256 = sha256_i686;
|
|
|
|
}
|
|
|
|
else if stdenv.system == "x86_64-linux" then
|
|
|
|
requireFile {
|
|
|
|
name = "jdk-${productVersion}u${patchVersion}-linux-x64.tar.gz";
|
|
|
|
url = downloadUrl;
|
|
|
|
sha256 = sha256_x86_64;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
abort "jdk requires i686-linux or x86_64 linux";
|
|
|
|
|
2014-06-22 13:37:09 +01:00
|
|
|
nativeBuildInputs = [ file ]
|
|
|
|
++ stdenv.lib.optional installjce unzip;
|
2014-05-11 11:13:52 +01:00
|
|
|
|
|
|
|
# See: https://github.com/NixOS/patchelf/issues/10
|
|
|
|
dontStrip = 1;
|
2014-07-16 16:52:46 +01:00
|
|
|
|
2014-05-11 11:13:52 +01:00
|
|
|
installPhase = ''
|
|
|
|
cd ..
|
2014-06-22 13:37:09 +01:00
|
|
|
|
|
|
|
# Set PaX markings
|
|
|
|
exes=$(file $sourceRoot/bin/* $sourceRoot/jre/bin/* 2> /dev/null | grep -E 'ELF.*(executable|shared object)' | sed -e 's/: .*$//')
|
|
|
|
for file in $exes; do
|
|
|
|
paxmark m "$file"
|
|
|
|
# On x86 for heap sizes over 700MB disable SEGMEXEC and PAGEEXEC as well.
|
|
|
|
${stdenv.lib.optionalString stdenv.isi686 ''paxmark msp "$file"''}
|
|
|
|
done
|
|
|
|
|
2014-05-11 11:13:52 +01:00
|
|
|
if test -z "$installjdk"; then
|
|
|
|
mv $sourceRoot/jre $out
|
|
|
|
else
|
|
|
|
mv $sourceRoot $out
|
|
|
|
fi
|
|
|
|
|
|
|
|
for file in $out/*
|
|
|
|
do
|
|
|
|
if test -f $file ; then
|
|
|
|
rm $file
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
if test -n "$installjdk"; then
|
|
|
|
for file in $out/jre/*
|
|
|
|
do
|
|
|
|
if test -f $file ; then
|
|
|
|
rm $file
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
|
|
|
if test -z "$installjdk"; then
|
|
|
|
jrePath=$out
|
|
|
|
else
|
|
|
|
jrePath=$out/jre
|
|
|
|
fi
|
|
|
|
|
|
|
|
if test -n "${jce}"; then
|
|
|
|
unzip ${jce}
|
2015-09-27 11:27:46 +01:00
|
|
|
cp -v UnlimitedJCEPolicy*/*.jar $jrePath/lib/security
|
2014-05-11 11:13:52 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
rpath=$rpath''${rpath:+:}$jrePath/lib/${architecture}/jli
|
|
|
|
rpath=$rpath''${rpath:+:}$jrePath/lib/${architecture}/server
|
|
|
|
rpath=$rpath''${rpath:+:}$jrePath/lib/${architecture}/xawt
|
|
|
|
rpath=$rpath''${rpath:+:}$jrePath/lib/${architecture}
|
2014-07-16 16:52:46 +01:00
|
|
|
|
2014-05-11 11:13:52 +01:00
|
|
|
# set all the dynamic linkers
|
2015-09-06 09:21:43 +01:00
|
|
|
find $out -type f -perm -0100 \
|
2014-12-17 18:11:30 +00:00
|
|
|
-exec patchelf --interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
|
2014-05-11 11:13:52 +01:00
|
|
|
--set-rpath "$rpath" {} \;
|
|
|
|
|
|
|
|
find $out -name "*.so" -exec patchelf --set-rpath "$rpath" {} \;
|
|
|
|
|
|
|
|
if test -z "$pluginSupport"; then
|
|
|
|
rm -f $out/bin/javaws
|
|
|
|
if test -n "$installjdk"; then
|
|
|
|
rm -f $out/jre/bin/javaws
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
mkdir $jrePath/lib/${architecture}/plugins
|
|
|
|
ln -s $jrePath/lib/${architecture}/libnpjp2.so $jrePath/lib/${architecture}/plugins
|
2014-07-16 17:23:47 +01:00
|
|
|
|
|
|
|
mkdir -p $out/nix-support
|
|
|
|
echo -n "${setJavaClassPath}" > $out/nix-support/propagated-native-build-inputs
|
|
|
|
|
|
|
|
# Set JAVA_HOME automatically.
|
|
|
|
cat <<EOF >> $out/nix-support/setup-hook
|
|
|
|
if [ -z "\$JAVA_HOME" ]; then export JAVA_HOME=$out; fi
|
|
|
|
EOF
|
2014-05-11 11:13:52 +01:00
|
|
|
'';
|
|
|
|
|
|
|
|
inherit installjdk pluginSupport;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* libXt is only needed on amd64
|
|
|
|
*/
|
|
|
|
libraries =
|
2015-09-15 10:26:18 +01:00
|
|
|
[stdenv.cc.libc glib libxml2 libav_0_8 ffmpeg libxslt mesa_noglu xorg.libXxf86vm alsaLib fontconfig freetype gnome.pango gnome.gtk cairo gdk_pixbuf atk] ++
|
|
|
|
(if swingSupport then [xorg.libX11 xorg.libXext xorg.libXtst xorg.libXi xorg.libXp xorg.libXt xorg.libXrender stdenv.cc.cc] else []);
|
2014-05-11 11:13:52 +01:00
|
|
|
|
2016-04-20 01:26:58 +01:00
|
|
|
rpath = stdenv.lib.strings.makeLibraryPath libraries;
|
|
|
|
|
2014-05-11 11:13:52 +01:00
|
|
|
passthru.mozillaPlugin = if installjdk then "/jre/lib/${architecture}/plugins" else "/lib/${architecture}/plugins";
|
|
|
|
|
2014-07-16 17:23:47 +01:00
|
|
|
passthru.jre = result; # FIXME: use multiple outputs or return actual JRE package
|
|
|
|
|
2015-01-01 23:18:03 +00:00
|
|
|
passthru.home = result;
|
|
|
|
|
2015-10-22 19:38:53 +01:00
|
|
|
passthru.architecture = architecture;
|
|
|
|
|
2015-09-17 19:17:12 +01:00
|
|
|
meta = with stdenv.lib; {
|
|
|
|
license = licenses.unfree;
|
|
|
|
platforms = [ "i686-linux" "x86_64-linux" ]; # some inherit jre.meta.platforms
|
|
|
|
};
|
2014-07-16 17:23:47 +01:00
|
|
|
|
|
|
|
}; in result
|