linux_xanmod: 5.11.14 -> 5.11.15
[NixPkgs.git] / pkgs / development / libraries / cairo / default.nix
blob839b7e9f40b94c91c4839c530b6d8feb1025eb31
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
9 , pdfSupport ? true
10 , darwin
13 assert glSupport -> x11Support && libGL != null;
15 let
16   version = "1.16.0";
17   inherit (lib) optional optionals;
18 in stdenv.mkDerivation rec {
19   pname = "cairo";
20   inherit version;
22   src = fetchurl {
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";
25   };
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   ] ++ optionals stdenv.hostPlatform.isDarwin [
39     # Workaround https://gitlab.freedesktop.org/cairo/cairo/-/issues/121
40     ./skip-configure-stderr-check.patch
41   ];
43   outputs = [ "out" "dev" "devdoc" ];
44   outputBin = "dev"; # very small
46   nativeBuildInputs = [
47     pkg-config
48   ];
50   buildInputs = [
51     libiconv
52     libintl
53   ] ++ optionals stdenv.isDarwin (with darwin.apple_sdk.frameworks; [
54     CoreGraphics
55     CoreText
56     ApplicationServices
57     Carbon
58   ]);
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"
69     "--enable-quartz"
70     "--enable-quartz-font"
71     "--enable-quartz-image"
72     "--enable-ft"
73   ] else ([ "--enable-tee" ]
74     ++ optional xcbSupport "--enable-xcb"
75     ++ optional glSupport "--enable-gl"
76     ++ optional pdfSupport "--enable-pdf"
77   )) ++ optional (!x11Support) "--disable-xlib";
79   preConfigure =
80   # On FreeBSD, `-ldl' doesn't exist.
81     lib.optionalString stdenv.isFreeBSD
82        '' for i in "util/"*"/Makefile.in" boilerplate/Makefile.in
83           do
84             cat "$i" | sed -es/-ldl//g > t
85             mv t "$i"
86           done
87        ''
88     +
89     ''
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
95     '';
97   enableParallelBuilding = true;
99   doCheck = false; # fails
101   postInstall = lib.optionalString stdenv.isDarwin glib.flattenInclude;
103   meta = with lib; {
104     description = "A 2D graphics library with support for multiple output devices";
106     longDescription = ''
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).
116     '';
118     homepage = "http://cairographics.org/";
120     license = with licenses; [ lgpl2Plus mpl10 ];
122     platforms = platforms.all;
123   };