nixpkgs/pkgs/development/compilers/oraclejdk/jdk-linux-base.nix

193 lines
4.6 KiB
Nix
Raw Normal View History

2014-05-11 11:13:52 +01:00
{ productVersion
, patchVersion
2017-12-06 07:38:45 +00:00
, sha256
2014-05-11 11:13:52 +01:00
, jceName
, sha256JCE
}:
{ swingSupport ? true
, stdenv
2020-01-15 18:57:27 +00:00
, requireFile
, makeWrapper
2014-05-11 11:13:52 +01:00
, unzip
2014-06-22 13:37:09 +01:00
, file
, xorg ? null
2014-05-11 11:13:52 +01:00
, installjdk ? true
, pluginSupport ? true
, installjce ? false
, config
2014-05-11 11:13:52 +01:00
, glib
, libxml2
, libav_0_8
, ffmpeg_3
2014-05-11 11:13:52 +01:00
, libxslt
, libGL
2014-05-11 11:13:52 +01:00
, freetype
, fontconfig
, gtk2
, pango
2014-05-11 11:13:52 +01:00
, cairo
, alsaLib
, atk
2019-05-22 12:03:39 +01:00
, gdk-pixbuf
, setJavaClassPath
2014-05-11 11:13:52 +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.
*/
2017-12-06 07:38:45 +00:00
architecture = {
i686-linux = "i386";
x86_64-linux = "amd64";
armv7l-linux = "arm";
aarch64-linux = "aarch64";
2020-01-15 18:57:27 +00:00
}.${stdenv.hostPlatform.system} or (throw "unsupported system ${stdenv.hostPlatform.system}");
2014-05-11 11:13:52 +01:00
jce =
if installjce then
2020-01-15 18:57:27 +00:00
requireFile {
name = jceName;
url = "http://www.oracle.com/technetwork/java/javase/downloads/jce8-download-2133166.html";
2014-05-11 11:13:52 +01:00
sha256 = sha256JCE;
}
else
"";
2016-06-24 14:41:12 +01:00
rSubPaths = [
"lib/${architecture}/jli"
"lib/${architecture}/server"
"lib/${architecture}/xawt"
"lib/${architecture}"
];
2014-05-11 11:13:52 +01:00
in
let result = stdenv.mkDerivation rec {
2020-01-15 18:57:27 +00:00
pname = if installjdk then "oraclejdk" else "oraclejre";
version = "${productVersion}u${patchVersion}";
src =
let
platformName = {
i686-linux = "linux-i586";
x86_64-linux = "linux-x64";
armv7l-linux = "linux-arm32-vfp-hflt";
aarch64-linux = "linux-arm64-vfp-hflt";
}.${stdenv.hostPlatform.system} or (throw "unsupported system ${stdenv.hostPlatform.system}");
in requireFile {
name = "jdk-${productVersion}u${patchVersion}-${platformName}.tar.gz";
url = "http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html";
sha256 = sha256.${stdenv.hostPlatform.system};
};
2014-05-11 11:13:52 +01:00
2014-06-22 13:37:09 +01:00
nativeBuildInputs = [ file ]
++ stdenv.lib.optional installjce unzip;
2014-05-11 11:13:52 +01:00
buildInputs = [ makeWrapper ];
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
2014-05-11 11:13:52 +01:00
if test -z "$installjdk"; then
mv $sourceRoot/jre $out
else
mv $sourceRoot $out
fi
shopt -s extglob
for file in $out/!(*src.zip)
2014-05-11 11:13:52 +01:00
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}
cp -v UnlimitedJCEPolicy*/*.jar $jrePath/lib/security
2014-05-11 11:13:52 +01:00
fi
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
mkdir -p $out/nix-support
printWords ${setJavaClassPath} > $out/nix-support/propagated-build-inputs
# Set JAVA_HOME automatically.
cat <<EOF >> $out/nix-support/setup-hook
if [ -z "\''${JAVA_HOME-}" ]; then export JAVA_HOME=$out; fi
EOF
2016-06-24 14:41:12 +01:00
'';
postFixup = ''
rpath+="''${rpath:+:}${stdenv.lib.concatStringsSep ":" (map (a: "$jrePath/${a}") rSubPaths)}"
# set all the dynamic linkers
find $out -type f -perm -0100 \
-exec patchelf --interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
--set-rpath "$rpath" {} \;
find $out -name "*.so" -exec patchelf --set-rpath "$rpath" {} \;
# Oracle Java Mission Control needs to know where libgtk-x11 and related is
2016-06-24 14:41:12 +01:00
if test -n "$installjdk" -a -x $out/bin/jmc; then
wrapProgram "$out/bin/jmc" \
2016-06-24 14:41:12 +01:00
--suffix-each LD_LIBRARY_PATH ':' "$rpath"
fi
2014-05-11 11:13:52 +01:00
'';
inherit installjdk pluginSupport;
/**
* libXt is only needed on amd64
*/
libraries =
[stdenv.cc.libc glib libxml2 libav_0_8 ffmpeg_3 libxslt libGL xorg.libXxf86vm alsaLib fontconfig freetype pango gtk2 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";
passthru.jre = result; # FIXME: use multiple outputs or return actual JRE package
2015-01-01 23:18:03 +00:00
passthru.home = result;
passthru.architecture = architecture;
meta = with stdenv.lib; {
license = licenses.unfree;
platforms = [ "i686-linux" "x86_64-linux" "armv7l-linux" "aarch64-linux" ]; # some inherit jre.meta.platforms
};
2019-10-18 13:53:25 +01:00
}; in result