1 { lib, stdenv, fetchurl, gtk-doc, meson, ninja, pkg-config, python3
2 , docbook_xsl, fontconfig, freetype, libpng, pixman, zlib
3 , x11Support? !stdenv.hostPlatform.isDarwin || true, libXext, libXrender
4 , gobjectSupport ? true, glib
5 , xcbSupport ? x11Support, libxcb
11 inherit (lib) optional optionals;
12 in stdenv.mkDerivation (finalAttrs: let
13 inherit (finalAttrs) pname version;
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-piubtCQl6ETMPW3d4EP/Odur7dFULrpXout5+FiJ1Fo=";
23 outputs = [ "out" "dev" "devdoc" ];
24 outputBin = "dev"; # very small
25 separateDebugInfo = true;
37 ] ++ optionals stdenv.hostPlatform.isDarwin (with darwin.apple_sdk.frameworks; [
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?
53 # error: #error config.h must be included before this header
54 "-Dsymbol-lookup=disabled"
56 # Only used in tests, causes a dependency cycle
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" ''
66 ipc_rmid_deferred_release = ${
71 }.${stdenv.hostPlatform.parsed.kernel.name} or
72 (throw "Unknown value for ipc_rmid_deferred_release")
78 patchShebangs version.py
81 enableParallelBuilding = true;
83 doCheck = false; # fails
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'
92 passthru.tests.pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage;
95 description = "2D graphics library with support for multiple output devices";
96 mainProgram = "cairo-trace";
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.
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).
107 homepage = "http://cairographics.org/";
108 license = with licenses; [ lgpl2Plus mpl10 ];
113 ] ++ lib.optional gobjectSupport "cairo-gobject";
114 platforms = platforms.all;