summary refs log tree commit diff
path: root/pkgs/development/compilers/jetbrains-jdk/default.nix
blob: 54d95fbd8a88a8e186327ccbc2001d83c57f2742 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
{ stdenv, lib, fetchurl, file, glib, libxml2, libav_0_8, ffmpeg, libxslt
, libGL , xorg, alsaLib, fontconfig, freetype, pango, gtk2, cairo
, gdk-pixbuf, atk, zlib }:

# TODO: Investigate building from source instead of patching binaries.
# TODO: Binary patching for not just x86_64-linux but also x86_64-darwin i686-linux

let drv = stdenv.mkDerivation rec {
  pname = "jetbrainsjdk";
  version = "520.30";

  src = if stdenv.hostPlatform.system == "x86_64-linux" then
    fetchurl {
      url = "https://bintray.com/jetbrains/intellij-jbr/download_file?file_path=jbrsdk-11_0_5-linux-x64-b${version}.tar.gz";
      sha256 = "0xmr5jjnr4af7byz5w01phyrrdyizfhqmwhs4k8ih566fkhyzj02";
    }
  else if stdenv.hostPlatform.system == "x86_64-darwin" then
    fetchurl {
      url = "https://bintray.com/jetbrains/intellij-jbr/download_file?file_path=jbrsdk-11_0_5-osx-x64-b${version}.tar.gz";
      sha256 = "0wfcw66wv5rkkjzyzi9j7zk7c2fgi33ny09drgihxi2kdzyfrpcb";
    }
  else
    throw "unsupported system: ${stdenv.hostPlatform.system}";

  nativeBuildInputs = [ file ];

  unpackCmd = "mkdir jdk; pushd jdk; tar -xzf $src; popd";

  installPhase = ''
    cd ..

    mv $sourceRoot/jbrsdk $out
  '';

  postFixup = lib.optionalString (!stdenv.isDarwin) ''
    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" {} \;
  '';

  rpath = lib.optionalString (!stdenv.isDarwin) (lib.makeLibraryPath ([
    stdenv.cc.cc stdenv.cc.libc glib libxml2 libav_0_8 ffmpeg libxslt libGL
    alsaLib fontconfig freetype pango gtk2 cairo gdk-pixbuf atk zlib
    (placeholder "out")
  ] ++ (with xorg; [
    libX11 libXext libXtst libXi libXp libXt libXrender libXxf86vm
  ])) + ":${placeholder "out"}/lib/jli");

  passthru.home = drv;

  meta = with stdenv.lib; {
    description = "An OpenJDK fork to better support Jetbrains's products.";
    longDescription = ''
     JetBrains Runtime is a runtime environment for running IntelliJ Platform
     based products on Windows, Mac OS X, and Linux. JetBrains Runtime is
     based on OpenJDK project with some modifications. These modifications
     include: Subpixel Anti-Aliasing, enhanced font rendering on Linux, HiDPI
     support, ligatures, some fixes for native crashes not presented in
     official build, and other small enhancements.

     JetBrains Runtime is not a certified build of OpenJDK. Please, use at
     your own risk.
    '';
    homepage = "https://bintray.com/jetbrains/intellij-jdk/";
    license = licenses.gpl2;
    maintainers = with maintainers; [ edwtjo ];
    platforms = with platforms; [ "x86_64-linux" "x86_64-darwin" ];
  };
}; in drv