nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at 17.09 127 lines 4.3 kB view raw
1{ stdenv, fetchFromGitHub, fetchpatch 2, bison2, flex, fontconfig, freetype, gperf, icu, openssl, libjpeg 3, libpng, perl, python, ruby, sqlite, qtwebkit, qmake, qtbase 4, darwin, writeScriptBin, cups 5}: 6 7let 8 fakeXcrun = writeScriptBin "xcrun" '' 9 #!${stdenv.shell} 10 echo >&2 "Fake xcrun: ''$@" 11 args=() 12 while (("$#")); do 13 case "$1" in 14 -sdk*) shift;; 15 -find*) shift;; 16 *) args+=("$1");; 17 esac 18 shift 19 done 20 21 if [ "''${#args[@]}" -gt "0" ]; then 22 echo >&2 "Fake xcrun: ''${args[@]}" 23 exec "''${args[@]}" 24 fi 25 ''; 26 fakeClang = writeScriptBin "clang" '' 27 #!${stdenv.shell} 28 if [[ "$@" == *.c ]]; then 29 exec "${stdenv.cc}/bin/clang" "$@" 30 else 31 exec "${stdenv.cc}/bin/clang++" "$@" 32 fi 33 ''; 34 35in stdenv.mkDerivation rec { 36 name = "phantomjs-${version}"; 37 version = "2.1.1"; 38 39 src = fetchFromGitHub { 40 owner = "ariya"; 41 repo = "phantomjs"; 42 rev = version; 43 sha256 = "1zsbpk1sgh9a16f1a5nx3qvk77ibjn812wqkxqck8n6fia85m5iq"; 44 }; 45 46 nativeBuildInputs = [ qmake ]; 47 buildInputs = [ 48 bison2 flex fontconfig freetype gperf icu openssl 49 libjpeg libpng perl python ruby sqlite qtwebkit qtbase 50 ] ++ stdenv.lib.optionals stdenv.isDarwin (with darwin.apple_sdk.frameworks; [ 51 AGL ApplicationServices AppKit Cocoa OpenGL 52 darwin.libobjc fakeClang cups 53 ]); 54 55 patches = [ 56 (fetchpatch { 57 url = "https://anonscm.debian.org/cgit/collab-maint/phantomjs.git/plain/debian/patches/build-hardening.patch?id=42c9154d8c87c9fe434908259b0eddde4d892ca3"; 58 sha256 = "1qs1r76w90qgpw742i7lf0y3b7m9zh5wxcbrhrak6mq1kqaphqb5"; 59 }) 60 (fetchpatch { 61 url = "https://anonscm.debian.org/cgit/collab-maint/phantomjs.git/plain/debian/patches/build-qt-components.patch?id=9b5c1ce95a7044ebffc634f773edf7d4eb9b6cd3"; 62 sha256 = "1fw2q59aqcks3abvwkqg9903yif6aivdsznc0h6frhhjvpp19vsb"; 63 }) 64 (fetchpatch { 65 url = "https://anonscm.debian.org/cgit/collab-maint/phantomjs.git/plain/debian/patches/build-qt55-evaluateJavaScript.patch?id=9b5c1ce95a7044ebffc634f773edf7d4eb9b6cd3"; 66 sha256 = "1avig9cfny8kv3s4mf3mdzvf3xlzgyh351yzwc4bkpnjvzv4fmq6"; 67 }) 68 (fetchpatch { 69 url = "https://anonscm.debian.org/cgit/collab-maint/phantomjs.git/plain/debian/patches/build-qt55-no-websecurity.patch?id=9b5c1ce95a7044ebffc634f773edf7d4eb9b6cd3"; 70 sha256 = "1nykqpxa7lcf9iarz5lywgg3v3b1h19iwvjdg4kgq0ai6idhcab8"; 71 }) 72 (fetchpatch { 73 url = "https://anonscm.debian.org/cgit/collab-maint/phantomjs.git/plain/debian/patches/build-qt55-print.patch?id=9b5c1ce95a7044ebffc634f773edf7d4eb9b6cd3"; 74 sha256 = "1fydmdjxnplglpbd3ypaih5l237jkxjirpdhzz92mcpy29yla6jw"; 75 }) 76 ./system-qtbase.patch 77 ]; 78 79 postPatch = '' 80 patchShebangs . 81 substituteInPlace src/phantomjs.pro \ 82 --replace "QT_MINOR_VERSION, 5" "QT_MINOR_VERSION, 9" 83 ''; 84 85 __impureHostDeps = stdenv.lib.optional stdenv.isDarwin "/usr/lib/libicucore.dylib"; 86 87 enableParallelBuilding = true; 88 89 installPhase = '' 90 mkdir -p $out/share/doc/phantomjs 91 cp -a bin $out 92 cp -a ChangeLog examples LICENSE.BSD README.md third-party.txt $out/share/doc/phantomjs 93 '' + stdenv.lib.optionalString stdenv.isDarwin '' 94 install_name_tool -change \ 95 ${darwin.CF}/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation \ 96 /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation \ 97 -change \ 98 ${darwin.configd}/Library/Frameworks/SystemConfiguration.framework/SystemConfiguration \ 99 /System/Library/Frameworks/SystemConfiguration.framework/Versions/A/SystemConfiguration \ 100 $out/bin/phantomjs 101 ''; 102 103 preFixup = '' 104 rm -r ../__nix_qt5__ 105 ''; 106 107 meta = with stdenv.lib; { 108 description = "Headless WebKit with JavaScript API"; 109 longDescription = '' 110 PhantomJS2 is a headless WebKit with JavaScript API. 111 It has fast and native support for various web standards: 112 DOM handling, CSS selector, JSON, Canvas, and SVG. 113 114 PhantomJS is an optimal solution for: 115 - Headless Website Testing 116 - Screen Capture 117 - Page Automation 118 - Network Monitoring 119 ''; 120 121 homepage = http://phantomjs.org/; 122 license = licenses.bsd3; 123 124 maintainers = [ maintainers.aflatter ]; 125 platforms = platforms.darwin ++ platforms.linux; 126 }; 127}