summary refs log tree commit diff
path: root/pkgs/development/tools/phantomjs/default.nix
blob: 33b99e12de554bdccb1c3e0d0fea5b8a0ead391a (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
{ stdenv, fetchurl, upx, freetype, fontconfig }:

assert stdenv.lib.elem stdenv.system [ "i686-linux" "x86_64-linux" ];

stdenv.mkDerivation rec {
  name = "phantomjs-1.7.0";

  # I chose to use the binary build for now.
  # The source version is quite nasty to compile
  # because it has bundled a lot of external libraries (like QT and Webkit)
  # and no easy/nice way to use the system versions of these

  src = if stdenv.system == "i686-linux" then
          fetchurl {
            url = "http://phantomjs.googlecode.com/files/${name}-linux-i686.tar.bz2";
            sha256 = "045d80lymjxnsssa0sgp5pgkahm651jk69ibk3mjczk3ykc1k91f";
          }
        else # x86_64-linux
          fetchurl {
            url = "http://phantomjs.googlecode.com/files/${name}-linux-x86_64.tar.bz2";
            sha256 = "1m14czhi3b388didn0a881glsx8bnsg9gnxgj5lghr4l5mgqyrd7";
          };

  buildNativeInputs = stdenv.lib.optional (stdenv.system == "x86_64-linux") upx;

  buildPhase = stdenv.lib.optionalString (stdenv.system == "x86_64-linux") ''
    upx -d bin/phantomjs
  '' + ''
    patchelf \
      --set-interpreter "$(cat $NIX_GCC/nix-support/dynamic-linker)" \
      --set-rpath ${freetype}/lib:${fontconfig}/lib:${stdenv.gcc.gcc}/lib64:${stdenv.gcc.gcc}/lib \
      bin/phantomjs
  '';

  dontStrip = true;

  installPhase = ''
    mkdir -p $out/share/doc/phantomjs
    cp -a bin $out
    cp -a ChangeLog examples LICENSE.BSD README.md third-party.txt $out/share/doc/phantomjs
  '';

  meta = {
    description = "Headless WebKit with JavaScript API";
    longDescription = ''
      PhantomJS is a headless WebKit with JavaScript API.
      It has fast and native support for various web standards:
      DOM handling, CSS selector, JSON, Canvas, and SVG.

      PhantomJS is an optimal solution for:
      - Headless Website Testing
      - Screen Capture
      - Page Automation
      - Network Monitoring
    '';

    homepage = http://phantomjs.org/;
    license = stdenv.lib.licenses.bsd3;

    maintainers = [ stdenv.lib.maintainers.bluescreen303 ];
    platforms = ["i686-linux" "x86_64-linux" ];
  };
}