Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at fix-function-merge 116 lines 3.5 kB view raw
1{ lib, stdenv, fetchurl, gtk-doc, meson, ninja, pkg-config, python3 2, docbook_xsl, fontconfig, freetype, libpng, pixman, zlib 3, x11Support? !stdenv.isDarwin || true, libXext, libXrender 4, gobjectSupport ? true, glib 5, xcbSupport ? x11Support, libxcb 6, darwin 7, testers 8}: 9 10let 11 inherit (lib) optional optionals; 12in stdenv.mkDerivation (finalAttrs: let 13 inherit (finalAttrs) pname version; 14in { 15 pname = "cairo"; 16 version = "1.18.0"; 17 18 src = fetchurl { 19 url = "https://cairographics.org/${if lib.mod (builtins.fromJSON (lib.versions.minor version)) 2 == 0 then "releases" else "snapshots"}/${pname}-${version}.tar.xz"; 20 hash = "sha256-JDoHNrl4oz3uKfnMp1IXM7eKZbVBggb+970cPUzxC2Q="; 21 }; 22 23 outputs = [ "out" "dev" "devdoc" ]; 24 outputBin = "dev"; # very small 25 separateDebugInfo = true; 26 27 nativeBuildInputs = [ 28 gtk-doc 29 meson 30 ninja 31 pkg-config 32 python3 33 ]; 34 35 buildInputs = [ 36 docbook_xsl 37 ] ++ optionals stdenv.isDarwin (with darwin.apple_sdk.frameworks; [ 38 CoreGraphics 39 CoreText 40 ApplicationServices 41 Carbon 42 ]); 43 44 propagatedBuildInputs = [ fontconfig freetype pixman libpng zlib ] 45 ++ optionals x11Support [ libXext libXrender ] 46 ++ optionals xcbSupport [ libxcb ] 47 ++ optional gobjectSupport glib 48 ; # TODO: maybe liblzo but what would it be for here? 49 50 mesonFlags = [ 51 "-Dgtk_doc=true" 52 53 # error: #error config.h must be included before this header 54 "-Dsymbol-lookup=disabled" 55 56 # Only used in tests, causes a dependency cycle 57 "-Dspectre=disabled" 58 59 (lib.mesonEnable "glib" gobjectSupport) 60 (lib.mesonEnable "tests" finalAttrs.finalPackage.doCheck) 61 (lib.mesonEnable "xlib" x11Support) 62 (lib.mesonEnable "xcb" xcbSupport) 63 ] ++ lib.optionals (!stdenv.buildPlatform.canExecute stdenv.hostPlatform) [ 64 "--cross-file=${builtins.toFile "cross-file.conf" '' 65 [properties] 66 ipc_rmid_deferred_release = ${ 67 { 68 linux = "true"; 69 freebsd = "true"; 70 netbsd = "false"; 71 }.${stdenv.hostPlatform.parsed.kernel.name} or 72 (throw "Unknown value for ipc_rmid_deferred_release") 73 } 74 ''}" 75 ]; 76 77 preConfigure = '' 78 patchShebangs version.py 79 ''; 80 81 enableParallelBuilding = true; 82 83 doCheck = false; # fails 84 85 postInstall = '' 86 # Work around broken `Requires.private' that prevents Freetype 87 # `-I' flags to be propagated. 88 sed -i "$out/lib/pkgconfig/cairo.pc" \ 89 -es'|^Cflags:\(.*\)$|Cflags: \1 -I${freetype.dev}/include/freetype2 -I${freetype.dev}/include|g' 90 '' + lib.optionalString stdenv.isDarwin glib.flattenInclude; 91 92 passthru.tests.pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage; 93 94 meta = with lib; { 95 description = "2D graphics library with support for multiple output devices"; 96 mainProgram = "cairo-trace"; 97 longDescription = '' 98 Cairo is a 2D graphics library with support for multiple output 99 devices. Currently supported output targets include the X 100 Window System, XCB, Quartz, Win32, image buffers, PostScript, 101 PDF, and SVG file output. 102 103 Cairo is designed to produce consistent output on all output 104 media while taking advantage of display hardware acceleration 105 when available (e.g., through the X Render Extension). 106 ''; 107 homepage = "http://cairographics.org/"; 108 license = with licenses; [ lgpl2Plus mpl10 ]; 109 pkgConfigModules = [ 110 "cairo-pdf" 111 "cairo-ps" 112 "cairo-svg" 113 ] ++ lib.optional gobjectSupport "cairo-gobject"; 114 platforms = platforms.all; 115 }; 116})