1{ stdenv, fetchurl, freetype, fontconfig, openssl, unzip }:
2
3assert stdenv.lib.elem stdenv.system [ "i686-linux" "x86_64-linux" "x86_64-darwin" ];
4
5stdenv.mkDerivation rec {
6 name = "phantomjs-1.9.8";
7
8 # I chose to use the binary build for now.
9 # The source version is quite nasty to compile
10 # because it has bundled a lot of external libraries (like QT and Webkit)
11 # and no easy/nice way to use the system versions of these
12
13 src = if stdenv.system == "i686-linux" then
14 fetchurl {
15 url = "https://bitbucket.org/ariya/phantomjs/downloads/${name}-linux-i686.tar.bz2";
16 sha256 = "11fzmssz9pqf3arh4f36w06sl2nyz8l9h8iyxyd7w5aqnq5la0j1";
17 }
18 else
19 if stdenv.system == "x86_64-linux" then
20 fetchurl {
21 url = "https://bitbucket.org/ariya/phantomjs/downloads/${name}-linux-x86_64.tar.bz2";
22 sha256 = "0fhnqxxsxhy125fmif1lwgnlhfx908spy7fx9mng4w72320n5nd1";
23 }
24 else # x86_64-darwin
25 fetchurl {
26 url = "https://bitbucket.org/ariya/phantomjs/downloads/${name}-macosx.zip";
27 sha256 = "0j0aq8dgzmb210xdrh0v3d4nblskl3zsckl8bzf1a603wcx085cg";
28 };
29
30 buildInputs = if stdenv.isDarwin then [ unzip ] else [];
31
32 buildPhase = if stdenv.isDarwin then "" else ''
33 patchelf \
34 --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
35 --set-rpath "${freetype}/lib:${fontconfig}/lib:${stdenv.cc.cc}/lib64:${stdenv.cc.cc}/lib:${openssl}/lib" \
36 bin/phantomjs
37 '';
38
39 dontPatchELF = true;
40 dontStrip = true;
41
42 installPhase = ''
43 mkdir -p $out/share/doc/phantomjs
44 cp -a bin $out
45 cp -a ChangeLog examples LICENSE.BSD README.md third-party.txt $out/share/doc/phantomjs
46 '';
47
48 meta = {
49 description = "Headless WebKit with JavaScript API";
50 longDescription = ''
51 PhantomJS is a headless WebKit with JavaScript API.
52 It has fast and native support for various web standards:
53 DOM handling, CSS selector, JSON, Canvas, and SVG.
54
55 PhantomJS is an optimal solution for:
56 - Headless Website Testing
57 - Screen Capture
58 - Page Automation
59 - Network Monitoring
60 '';
61
62 homepage = http://phantomjs.org/;
63 license = stdenv.lib.licenses.bsd3;
64
65 maintainers = [ stdenv.lib.maintainers.bluescreen303 ];
66 platforms = ["i686-linux" "x86_64-linux" "x86_64-darwin" ];
67 };
68}