1 { config, lib, stdenv, fetchurl, fetchpatch, pkg-config, libiconv
2 , libintl, expat, zlib, libpng, pixman, fontconfig, freetype
3 , x11Support? !stdenv.isDarwin, libXext, libXrender
4 , gobjectSupport ? true, glib
5 , xcbSupport ? x11Support, libxcb, xcbutil # no longer experimental since 1.12
6 , libGLSupported ? lib.elem stdenv.hostPlatform.system lib.platforms.mesaPlatforms
7 , glSupport ? x11Support && config.cairo.gl or (libGLSupported && stdenv.isLinux)
8 , libGL ? null # libGLU libGL is no longer a big dependency
13 assert glSupport -> x11Support && libGL != null;
17 inherit (lib) optional optionals;
18 in stdenv.mkDerivation rec {
23 url = "https://cairographics.org/${if lib.mod (builtins.fromJSON (lib.versions.minor version)) 2 == 0 then "releases" else "snapshots"}/${pname}-${version}.tar.xz";
24 sha256 = "0c930mk5xr2bshbdljv005j3j8zr47gqmkry3q6qgvqky6rjjysy";
28 # Fixes CVE-2018-19876; see Nixpkgs issue #55384
29 # CVE information: https://nvd.nist.gov/vuln/detail/CVE-2018-19876
30 # Upstream PR: https://gitlab.freedesktop.org/cairo/cairo/merge_requests/5
32 # This patch is the merged commit from the above PR.
34 name = "CVE-2018-19876.patch";
35 url = "https://gitlab.freedesktop.org/cairo/cairo/commit/6edf572ebb27b00d3c371ba5ae267e39d27d5b6d.patch";
36 sha256 = "112hgrrsmcwxh1r52brhi5lksq4pvrz4xhkzcf2iqp55jl2pb7n1";
38 ] ++ optionals stdenv.hostPlatform.isDarwin [
39 # Workaround https://gitlab.freedesktop.org/cairo/cairo/-/issues/121
40 ./skip-configure-stderr-check.patch
43 outputs = [ "out" "dev" "devdoc" ];
44 outputBin = "dev"; # very small
53 ] ++ optionals stdenv.isDarwin (with darwin.apple_sdk.frameworks; [
60 propagatedBuildInputs = [ fontconfig expat freetype pixman zlib libpng ]
61 ++ optionals x11Support [ libXext libXrender ]
62 ++ optionals xcbSupport [ libxcb xcbutil ]
63 ++ optional gobjectSupport glib
64 ++ optional glSupport libGL
65 ; # TODO: maybe liblzo but what would it be for here?
67 configureFlags = (if stdenv.isDarwin then [
68 "--disable-dependency-tracking"
70 "--enable-quartz-font"
71 "--enable-quartz-image"
73 ] else ([ "--enable-tee" ]
74 ++ optional xcbSupport "--enable-xcb"
75 ++ optional glSupport "--enable-gl"
76 ++ optional pdfSupport "--enable-pdf"
77 )) ++ optional (!x11Support) "--disable-xlib";
80 # On FreeBSD, `-ldl' doesn't exist.
81 lib.optionalString stdenv.isFreeBSD
82 '' for i in "util/"*"/Makefile.in" boilerplate/Makefile.in
84 cat "$i" | sed -es/-ldl//g > t
90 # Work around broken `Requires.private' that prevents Freetype
91 # `-I' flags to be propagated.
92 sed -i "src/cairo.pc.in" \
93 -es'|^Cflags:\(.*\)$|Cflags: \1 -I${freetype.dev}/include/freetype2 -I${freetype.dev}/include|g'
94 substituteInPlace configure --replace strings $STRINGS
97 enableParallelBuilding = true;
99 doCheck = false; # fails
101 postInstall = lib.optionalString stdenv.isDarwin glib.flattenInclude;
104 description = "A 2D graphics library with support for multiple output devices";
107 Cairo is a 2D graphics library with support for multiple output
108 devices. Currently supported output targets include the X
109 Window System, Quartz, Win32, image buffers, PostScript, PDF,
110 and SVG file output. Experimental backends include OpenGL
111 (through glitz), XCB, BeOS, OS/2, and DirectFB.
113 Cairo is designed to produce consistent output on all output
114 media while taking advantage of display hardware acceleration
115 when available (e.g., through the X Render Extension).
118 homepage = "http://cairographics.org/";
120 license = with licenses; [ lgpl2Plus mpl10 ];
122 platforms = platforms.all;