diff options
author | Alyssa Ross <hi@alyssa.is> | 2019-01-07 02:18:36 +0000 |
---|---|---|
committer | Alyssa Ross <hi@alyssa.is> | 2019-01-07 02:18:47 +0000 |
commit | 36f56d99fa0a0765c9f1de4a5f17a9b05830c3f2 (patch) | |
tree | b3faaf573407b32aa645237a4d16b82778a39a92 /nixpkgs/pkgs/development/compilers/oraclejdk/jdk-linux-base.nix | |
parent | 4e31070265257dc67d120c27e0f75c2344fdfa9a (diff) | |
parent | abf060725d7614bd3b9f96764262dfbc2f9c2199 (diff) | |
download | nixlib-36f56d99fa0a0765c9f1de4a5f17a9b05830c3f2.tar nixlib-36f56d99fa0a0765c9f1de4a5f17a9b05830c3f2.tar.gz nixlib-36f56d99fa0a0765c9f1de4a5f17a9b05830c3f2.tar.bz2 nixlib-36f56d99fa0a0765c9f1de4a5f17a9b05830c3f2.tar.lz nixlib-36f56d99fa0a0765c9f1de4a5f17a9b05830c3f2.tar.xz nixlib-36f56d99fa0a0765c9f1de4a5f17a9b05830c3f2.tar.zst nixlib-36f56d99fa0a0765c9f1de4a5f17a9b05830c3f2.zip |
Add 'nixpkgs/' from commit 'abf060725d7614bd3b9f96764262dfbc2f9c2199'
git-subtree-dir: nixpkgs git-subtree-mainline: 4e31070265257dc67d120c27e0f75c2344fdfa9a git-subtree-split: abf060725d7614bd3b9f96764262dfbc2f9c2199
Diffstat (limited to 'nixpkgs/pkgs/development/compilers/oraclejdk/jdk-linux-base.nix')
-rw-r--r-- | nixpkgs/pkgs/development/compilers/oraclejdk/jdk-linux-base.nix | 198 |
1 files changed, 198 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/development/compilers/oraclejdk/jdk-linux-base.nix b/nixpkgs/pkgs/development/compilers/oraclejdk/jdk-linux-base.nix new file mode 100644 index 000000000000..5d55e0554e55 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/oraclejdk/jdk-linux-base.nix @@ -0,0 +1,198 @@ +{ productVersion +, patchVersion +, downloadUrl +, sha256 +, jceName +, jceDownloadUrl +, sha256JCE +}: + +{ swingSupport ? true +, stdenv +, requireFile +, makeWrapper +, unzip +, file +, xorg ? null +, installjdk ? true +, pluginSupport ? true +, installjce ? false +, glib +, libxml2 +, libav_0_8 +, ffmpeg +, libxslt +, libGL +, freetype +, fontconfig +, gtk2 +, pango +, cairo +, alsaLib +, atk +, gdk_pixbuf +, setJavaClassPath +}: + +assert swingSupport -> xorg != null; + +let + + /** + * The JRE libraries are in directories that depend on the CPU. + */ + architecture = { + i686-linux = "i386"; + x86_64-linux = "amd64"; + armv7l-linux = "arm"; + aarch64-linux = "aarch64"; + }.${stdenv.hostPlatform.system}; + + jce = + if installjce then + requireFile { + name = jceName; + url = jceDownloadUrl; + sha256 = sha256JCE; + } + else + ""; + + rSubPaths = [ + "lib/${architecture}/jli" + "lib/${architecture}/server" + "lib/${architecture}/xawt" + "lib/${architecture}" + ]; + +in + +let result = stdenv.mkDerivation rec { + name = + if installjdk then "oraclejdk-${productVersion}u${patchVersion}" else "oraclejre-${productVersion}u${patchVersion}"; + + src = requireFile { + name = { + i686-linux = "jdk-${productVersion}u${patchVersion}-linux-i586.tar.gz"; + x86_64-linux = "jdk-${productVersion}u${patchVersion}-linux-x64.tar.gz"; + armv7l-linux = "jdk-${productVersion}u${patchVersion}-linux-arm32-vfp-hflt.tar.gz"; + aarch64-linux = "jdk-${productVersion}u${patchVersion}-linux-arm64-vfp-hflt.tar.gz"; + }.${stdenv.hostPlatform.system}; + url = downloadUrl; + sha256 = sha256.${stdenv.hostPlatform.system}; + }; + + nativeBuildInputs = [ file ] + ++ stdenv.lib.optional installjce unzip; + + buildInputs = [ makeWrapper ]; + + # See: https://github.com/NixOS/patchelf/issues/10 + dontStrip = 1; + + installPhase = '' + cd .. + + # 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" || true + # On x86 for heap sizes over 700MB disable SEGMEXEC and PAGEEXEC as well. + ${stdenv.lib.optionalString stdenv.isi686 ''paxmark msp "$file"''} + done + + if test -z "$installjdk"; then + mv $sourceRoot/jre $out + else + mv $sourceRoot $out + fi + + shopt -s extglob + for file in $out/!(*src.zip) + 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 + 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 + ''; + + 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 + if test -n "$installjdk" -a -x $out/bin/jmc; then + wrapProgram "$out/bin/jmc" \ + --suffix-each LD_LIBRARY_PATH ':' "$rpath" + fi + ''; + + inherit installjdk pluginSupport; + + /** + * libXt is only needed on amd64 + */ + libraries = + [stdenv.cc.libc glib libxml2 libav_0_8 ffmpeg 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 []); + + rpath = stdenv.lib.strings.makeLibraryPath libraries; + + 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 + + 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 + }; + +}; in result |