nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{ config, stdenv, fetchurl, fetchpatch, pkgconfig, 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 ? stdenv.lib.elem stdenv.hostPlatform.system stdenv.lib.platforms.mesaPlatforms
7, glSupport ? x11Support && config.cairo.gl or (libGLSupported && stdenv.isLinux)
8, libGL ? null # libGLU libGL is no longer a big dependency
9, pdfSupport ? true
10, darwin
11}:
12
13assert glSupport -> x11Support && libGL != null;
14
15let
16 version = "1.16.0";
17 inherit (stdenv.lib) optional optionals;
18in stdenv.mkDerivation rec {
19 pname = "cairo";
20 inherit version;
21
22 src = fetchurl {
23 url = "https://cairographics.org/${if stdenv.lib.mod (builtins.fromJSON (stdenv.lib.versions.minor version)) 2 == 0 then "releases" else "snapshots"}/${pname}-${version}.tar.xz";
24 sha256 = "0c930mk5xr2bshbdljv005j3j8zr47gqmkry3q6qgvqky6rjjysy";
25 };
26
27 patches = [
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
31 #
32 # This patch is the merged commit from the above PR.
33 (fetchpatch {
34 name = "CVE-2018-19876.patch";
35 url = "https://gitlab.freedesktop.org/cairo/cairo/commit/6edf572ebb27b00d3c371ba5ae267e39d27d5b6d.patch";
36 sha256 = "112hgrrsmcwxh1r52brhi5lksq4pvrz4xhkzcf2iqp55jl2pb7n1";
37 })
38 ];
39
40 outputs = [ "out" "dev" "devdoc" ];
41 outputBin = "dev"; # very small
42
43 nativeBuildInputs = [
44 pkgconfig
45 ];
46
47 buildInputs = [
48 libiconv
49 libintl
50 ] ++ optionals stdenv.isDarwin (with darwin.apple_sdk.frameworks; [
51 CoreGraphics
52 CoreText
53 ApplicationServices
54 Carbon
55 ]);
56
57 propagatedBuildInputs = [ fontconfig expat freetype pixman zlib libpng ]
58 ++ optionals x11Support [ libXext libXrender ]
59 ++ optionals xcbSupport [ libxcb xcbutil ]
60 ++ optional gobjectSupport glib
61 ++ optional glSupport libGL
62 ; # TODO: maybe liblzo but what would it be for here?
63
64 configureFlags = (if stdenv.isDarwin then [
65 "--disable-dependency-tracking"
66 "--enable-quartz"
67 "--enable-quartz-font"
68 "--enable-quartz-image"
69 "--enable-ft"
70 ] else ([ "--enable-tee" ]
71 ++ optional xcbSupport "--enable-xcb"
72 ++ optional glSupport "--enable-gl"
73 ++ optional pdfSupport "--enable-pdf"
74 )) ++ optional (!x11Support) "--disable-xlib";
75
76 preConfigure =
77 # On FreeBSD, `-ldl' doesn't exist.
78 stdenv.lib.optionalString stdenv.isFreeBSD
79 '' for i in "util/"*"/Makefile.in" boilerplate/Makefile.in
80 do
81 cat "$i" | sed -es/-ldl//g > t
82 mv t "$i"
83 done
84 ''
85 +
86 ''
87 # Work around broken `Requires.private' that prevents Freetype
88 # `-I' flags to be propagated.
89 sed -i "src/cairo.pc.in" \
90 -es'|^Cflags:\(.*\)$|Cflags: \1 -I${freetype.dev}/include/freetype2 -I${freetype.dev}/include|g'
91 substituteInPlace configure --replace strings $STRINGS
92 '';
93
94 enableParallelBuilding = true;
95
96 doCheck = false; # fails
97
98 postInstall = stdenv.lib.optionalString stdenv.isDarwin glib.flattenInclude;
99
100 meta = with stdenv.lib; {
101 description = "A 2D graphics library with support for multiple output devices";
102
103 longDescription = ''
104 Cairo is a 2D graphics library with support for multiple output
105 devices. Currently supported output targets include the X
106 Window System, Quartz, Win32, image buffers, PostScript, PDF,
107 and SVG file output. Experimental backends include OpenGL
108 (through glitz), XCB, BeOS, OS/2, and DirectFB.
109
110 Cairo is designed to produce consistent output on all output
111 media while taking advantage of display hardware acceleration
112 when available (e.g., through the X Render Extension).
113 '';
114
115 homepage = "http://cairographics.org/";
116
117 license = with licenses; [ lgpl2Plus mpl10 ];
118
119 platforms = platforms.all;
120 };
121}