@@ -0,0 +1,95 @@
1+{ lib, stdenv, fetchFromGitHub, fetchpatch, bison, flex, fontconfig, freetype
2+, gperf, icu, openssl, libjpeg, libpng, perl, python2, ruby, sqlite, qtwebkit
3+, qmake, qtbase, darwin, writeScriptBin, cups, makeWrapper, cmake }:
4+
5+let
6+ fakeClang = writeScriptBin "clang" ''
7+ #!${stdenv.shell}
8+ if [[ "$@" == *.c ]]; then
9+ exec "${stdenv.cc}/bin/clang" "$@"
10+ else
11+ exec "${stdenv.cc}/bin/clang++" "$@"
12+ fi
13+ '';
14+
15+in stdenv.mkDerivation {
16+ pname = "phantomjs";
17+ version = "3.0.0";
18+
19+ src = fetchFromGitHub {
20+ owner = "ariya";
21+ repo = "phantomjs";
22+ rev = "0a0b0facb16acfbabb7804822ecaf4f4b9dce3d2";
23+ sha256 = "sha256-xLCqi9l6AIdFXMuwcZcKB8pZ1hmUK9KQTAm0jzZKBEQ=";
24+ };
25+
26+ nativeBuildInputs = [ cmake qmake makeWrapper ];
27+ buildInputs = [
28+ bison
29+ flex
30+ fontconfig
31+ freetype
32+ gperf
33+ icu
34+ openssl
35+ libjpeg
36+ libpng
37+ perl
38+ python2
39+ ruby
40+ sqlite
41+ qtwebkit
42+ qtbase
43+ ] ++ lib.optionals stdenv.isDarwin (with darwin.apple_sdk.frameworks; [
44+ AGL
45+ ApplicationServices
46+ AppKit
47+ Cocoa
48+ OpenGL
49+ darwin.libobjc
50+ fakeClang
51+ cups
52+ ]);
53+
54+ __impureHostDeps = lib.optional stdenv.isDarwin "/usr/lib/libicucore.dylib";
55+
56+ dontWrapQtApps = true;
57+
58+ installPhase = ''
59+ mkdir -p $out/share/doc/phantomjs
60+ cp -a bin $out
61+ '' + lib.optionalString stdenv.isDarwin ''
62+ install_name_tool -change \
63+ ${darwin.CF}/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation \
64+ /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation \
65+ -change \
66+ ${darwin.configd}/Library/Frameworks/SystemConfiguration.framework/SystemConfiguration \
67+ /System/Library/Frameworks/SystemConfiguration.framework/Versions/A/SystemConfiguration \
68+ $out/bin/phantomjs
69+ '' + ''
70+ wrapProgram $out/bin/phantomjs \
71+ --set QT_QPA_PLATFORM offscreen \
72+ --prefix PATH : ${lib.makeBinPath [ qtbase ]}
73+ '';
74+
75+ meta = with lib; {
76+ description = "Headless WebKit with JavaScript API";
77+ longDescription = ''
78+ PhantomJS2 is a headless WebKit with JavaScript API.
79+ It has fast and native support for various web standards:
80+ DOM handling, CSS selector, JSON, Canvas, and SVG.
81+
82+ PhantomJS is an optimal solution for:
83+ - Headless Website Testing
84+ - Screen Capture
85+ - Page Automation
86+ - Network Monitoring
87+ '';
88+
89+ homepage = "https://phantomjs.org/";
90+ license = licenses.bsd3;
91+
92+ maintainers = [ maintainers.aflatter ];
93+ platforms = platforms.darwin ++ platforms.linux;
94+ };
95+}