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