1{ stdenv, lib, fetchurl, unzip, jdk, pkgconfig, gtk2
2, libXt, libXtst, libXi, libGLU_combined, webkit, libsoup, xorg
3, pango, gdk_pixbuf, glib
4}:
5
6let
7 platformMap = {
8 "x86_64-linux" =
9 { platform = "gtk-linux-x86_64";
10 sha256 = "1qq0pjll6030v4ml0hifcaaik7sx3fl7ghybfdw95vsvxafwp2ff"; };
11 "i686-linux" =
12 { platform = "gtk-linux-x86";
13 sha256 = "03mhzraikcs4fsz7d3h5af9pw1bbcfd6dglsvbk2ciwimy9zj30q"; };
14 "x86_64-darwin" =
15 { platform = "cocoa-macosx-x86_64";
16 sha256 = "00k1mfbncvyh8klgmk0891w8jwnd5niqb16j1j8yacrm2smmlb05"; };
17 };
18
19 metadata = assert platformMap ? ${stdenv.system}; platformMap.${stdenv.system};
20
21in stdenv.mkDerivation rec {
22 version = "4.5";
23 fullVersion = "${version}-201506032000";
24 name = "swt-${version}";
25
26 hardeningDisable = [ "format" ];
27
28 # Alas, the Eclipse Project apparently doesn't produce source-only
29 # releases of SWT. So we just grab a binary release and extract
30 # "src.zip" from that.
31 src = fetchurl {
32 url = "http://archive.eclipse.org/eclipse/downloads/drops4/R-${fullVersion}/${name}-${metadata.platform}.zip";
33 sha256 = metadata.sha256;
34 };
35
36 sourceRoot = ".";
37
38 nativeBuildInputs = [ unzip pkgconfig ];
39 buildInputs = [ jdk gtk2 libXt libXtst libXi libGLU_combined webkit libsoup ];
40
41 NIX_LFLAGS = (map (x: "-L${lib.getLib x}/lib") [ xorg.libX11 pango gdk_pixbuf glib ]) ++
42 [ "-lX11" "-lpango-1.0" "-lgdk_pixbuf-2.0" "-lglib-2.0" ];
43
44 buildPhase = ''
45 unzip src.zip -d src
46
47 cd src
48 sed -i "s#^LFLAGS =#LFLAGS = $NIX_LFLAGS #g" *.mak
49 export JAVA_HOME=${jdk}
50
51 sh ./build.sh
52
53 mkdir out
54 javac -d out/ $(find org/ -name "*.java")
55 '';
56
57 installPhase = ''
58 mkdir -p $out/lib
59 cp *.so $out/lib
60
61 mkdir -p $out/jars
62 cp version.txt out/
63 cd out && jar -c * > $out/jars/swt.jar
64 '';
65
66 meta = with stdenv.lib; {
67 homepage = http://www.eclipse.org/swt/;
68 description = "An widget toolkit for Java to access the user-interface facilities of the operating systems on which it is implemented";
69 license = licenses.epl10;
70 maintainers = with maintainers; [ pSub ];
71 platforms = with platforms; linux;
72 };
73}