1{ lib, stdenv
2, requireFile
3, xorg
4, zlib
5, freetype
6, alsa-lib
7, setJavaClassPath
8}:
9
10let result = stdenv.mkDerivation rec {
11 pname = "oraclejdk";
12 version = "11.0.10";
13
14 src = requireFile {
15 name = "jdk-${version}_linux-x64_bin.tar.gz";
16 url = "https://www.oracle.com/java/technologies/javase-jdk11-downloads.html";
17 sha256 = "94bd34f85ee38d3ef59e5289ec7450b9443b924c55625661fffe66b03f2c8de2";
18 };
19
20 installPhase = ''
21 mv ../$sourceRoot $out
22
23 mkdir -p $out/nix-support
24 printWords ${setJavaClassPath} > $out/nix-support/propagated-build-inputs
25
26 # Set JAVA_HOME automatically.
27 cat <<EOF >> $out/nix-support/setup-hook
28 if [ -z "\''${JAVA_HOME-}" ]; then export JAVA_HOME=$out; fi
29 EOF
30 '';
31
32 postFixup = ''
33 rpath="$out/lib/jli:$out/lib/server:$out/lib:${lib.strings.makeLibraryPath [ zlib xorg.libX11 xorg.libXext xorg.libXtst xorg.libXi xorg.libXrender freetype alsa-lib]}"
34
35 for f in $(find $out -name "*.so") $(find $out -type f -perm -0100); do
36 patchelf --interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" "$f" || true
37 patchelf --set-rpath "$rpath" "$f" || true
38 done
39
40 for f in $(find $out -name "*.so") $(find $out -type f -perm -0100); do
41 if ldd "$f" | fgrep 'not found'; then echo "in file $f"; fi
42 done
43 '';
44
45 passthru.jre = result;
46 passthru.home = result;
47
48 dontStrip = true; # See: https://github.com/NixOS/patchelf/issues/10
49
50 meta = with lib; {
51 license = licenses.unfree;
52 platforms = [ "x86_64-linux" ];
53 };
54}; in result