2021-01-21 18:00:13 +01:00
|
|
|
{ config, lib, stdenv, fetchurl, fetchpatch, pkg-config, libiconv
|
2019-04-16 22:56:48 +02:00
|
|
|
, libintl, expat, zlib, libpng, pixman, fontconfig, freetype
|
|
|
|
, x11Support? !stdenv.isDarwin, libXext, libXrender
|
2011-09-20 08:22:14 +02:00
|
|
|
, gobjectSupport ? true, glib
|
2019-04-16 22:56:48 +02:00
|
|
|
, xcbSupport ? x11Support, libxcb, xcbutil # no longer experimental since 1.12
|
2021-01-23 18:15:07 +01:00
|
|
|
, libGLSupported ? lib.elem stdenv.hostPlatform.system lib.platforms.mesaPlatforms
|
2020-08-01 23:00:42 +02:00
|
|
|
, glSupport ? x11Support && config.cairo.gl or (libGLSupported && stdenv.isLinux)
|
2019-11-10 17:44:34 +01:00
|
|
|
, libGL ? null # libGLU libGL is no longer a big dependency
|
2013-06-13 22:11:34 +02:00
|
|
|
, pdfSupport ? true
|
2016-03-29 18:04:46 +02:00
|
|
|
, darwin
|
2005-10-12 16:00:20 +02:00
|
|
|
}:
|
|
|
|
|
2020-08-01 23:00:42 +02:00
|
|
|
assert glSupport -> x11Support && libGL != null;
|
2013-05-30 14:43:26 +02:00
|
|
|
|
2018-04-06 18:59:30 +02:00
|
|
|
let
|
2018-10-20 03:41:37 +02:00
|
|
|
version = "1.16.0";
|
2021-01-21 18:00:13 +01:00
|
|
|
inherit (lib) optional optionals;
|
2018-04-06 18:59:30 +02:00
|
|
|
in stdenv.mkDerivation rec {
|
2019-08-13 23:52:01 +02:00
|
|
|
pname = "cairo";
|
|
|
|
inherit version;
|
2012-08-27 04:53:19 +02:00
|
|
|
|
2005-10-12 16:00:20 +02:00
|
|
|
src = fetchurl {
|
2021-01-23 18:15:07 +01:00
|
|
|
url = "https://cairographics.org/${if lib.mod (builtins.fromJSON (lib.versions.minor version)) 2 == 0 then "releases" else "snapshots"}/${pname}-${version}.tar.xz";
|
2018-10-20 03:41:37 +02:00
|
|
|
sha256 = "0c930mk5xr2bshbdljv005j3j8zr47gqmkry3q6qgvqky6rjjysy";
|
2005-10-12 16:00:20 +02:00
|
|
|
};
|
2008-03-07 16:43:43 +01:00
|
|
|
|
2019-02-17 04:52:37 +01:00
|
|
|
patches = [
|
|
|
|
# Fixes CVE-2018-19876; see Nixpkgs issue #55384
|
|
|
|
# CVE information: https://nvd.nist.gov/vuln/detail/CVE-2018-19876
|
|
|
|
# Upstream PR: https://gitlab.freedesktop.org/cairo/cairo/merge_requests/5
|
|
|
|
#
|
|
|
|
# This patch is the merged commit from the above PR.
|
|
|
|
(fetchpatch {
|
|
|
|
name = "CVE-2018-19876.patch";
|
|
|
|
url = "https://gitlab.freedesktop.org/cairo/cairo/commit/6edf572ebb27b00d3c371ba5ae267e39d27d5b6d.patch";
|
|
|
|
sha256 = "112hgrrsmcwxh1r52brhi5lksq4pvrz4xhkzcf2iqp55jl2pb7n1";
|
|
|
|
})
|
2021-06-16 19:56:11 +02:00
|
|
|
|
|
|
|
# Fix PDF output.
|
|
|
|
# https://gitlab.freedesktop.org/cairo/cairo/issues/342
|
|
|
|
(fetchpatch {
|
|
|
|
url = "https://gitlab.freedesktop.org/cairo/cairo/commit/5e34c5a9640e49dcc29e6b954c4187cfc838dbd1.patch";
|
|
|
|
sha256 = "yCwsDUY7efVvOZkA6a0bPS+RrVc8Yk9bfPwWHeOjq5o=";
|
|
|
|
})
|
2021-07-29 14:48:00 +02:00
|
|
|
|
|
|
|
# Fixes CVE-2020-35492; see https://github.com/NixOS/nixpkgs/issues/120364.
|
|
|
|
# CVE information: https://nvd.nist.gov/vuln/detail/CVE-2020-35492
|
|
|
|
# Upstream PR: https://gitlab.freedesktop.org/cairo/cairo/merge_requests/85
|
|
|
|
(fetchpatch {
|
|
|
|
name = "CVE-2020-35492.patch";
|
|
|
|
includes = [ "src/cairo-image-compositor.c" ];
|
|
|
|
url = "https://github.com/freedesktop/cairo/commit/78266cc8c0f7a595cfe8f3b694bfb9bcc3700b38.patch";
|
|
|
|
sha256 = "048nzfz7rkgqb9xs0dfs56qdw7ckkxr87nbj3p0qziqdq4nb6wki";
|
|
|
|
})
|
2020-10-17 23:22:46 +02:00
|
|
|
] ++ optionals stdenv.hostPlatform.isDarwin [
|
|
|
|
# Workaround https://gitlab.freedesktop.org/cairo/cairo/-/issues/121
|
|
|
|
./skip-configure-stderr-check.patch
|
2019-02-17 04:52:37 +01:00
|
|
|
];
|
|
|
|
|
2016-09-01 11:07:23 +02:00
|
|
|
outputs = [ "out" "dev" "devdoc" ];
|
2015-10-28 19:38:17 +01:00
|
|
|
outputBin = "dev"; # very small
|
2012-08-27 04:53:19 +02:00
|
|
|
|
2016-03-29 18:04:46 +02:00
|
|
|
nativeBuildInputs = [
|
2021-01-19 07:50:56 +01:00
|
|
|
pkg-config
|
2019-03-02 08:17:21 +01:00
|
|
|
];
|
|
|
|
|
|
|
|
buildInputs = [
|
2016-03-29 18:04:46 +02:00
|
|
|
libiconv
|
2018-03-14 20:15:06 +01:00
|
|
|
libintl
|
|
|
|
] ++ optionals stdenv.isDarwin (with darwin.apple_sdk.frameworks; [
|
2016-03-29 18:04:46 +02:00
|
|
|
CoreGraphics
|
2016-12-23 22:10:06 +01:00
|
|
|
CoreText
|
2017-01-09 20:58:16 +01:00
|
|
|
ApplicationServices
|
2016-03-29 18:04:46 +02:00
|
|
|
Carbon
|
|
|
|
]);
|
2008-10-14 14:08:07 +02:00
|
|
|
|
2019-04-16 22:56:48 +02:00
|
|
|
propagatedBuildInputs = [ fontconfig expat freetype pixman zlib libpng ]
|
|
|
|
++ optionals x11Support [ libXext libXrender ]
|
2013-05-30 14:43:26 +02:00
|
|
|
++ optionals xcbSupport [ libxcb xcbutil ]
|
|
|
|
++ optional gobjectSupport glib
|
2018-02-24 13:06:44 +01:00
|
|
|
++ optional glSupport libGL
|
2015-10-06 19:57:45 +02:00
|
|
|
; # TODO: maybe liblzo but what would it be for here?
|
2013-05-30 14:43:26 +02:00
|
|
|
|
2021-06-27 12:47:40 +02:00
|
|
|
configureFlags = [
|
|
|
|
"--enable-tee"
|
|
|
|
] ++ (if stdenv.isDarwin then [
|
2016-03-29 18:04:46 +02:00
|
|
|
"--disable-dependency-tracking"
|
|
|
|
"--enable-quartz"
|
|
|
|
"--enable-quartz-font"
|
|
|
|
"--enable-quartz-image"
|
|
|
|
"--enable-ft"
|
2021-06-27 12:47:40 +02:00
|
|
|
] else (optional xcbSupport "--enable-xcb"
|
2013-05-30 14:43:26 +02:00
|
|
|
++ optional glSupport "--enable-gl"
|
2013-06-13 15:12:43 +02:00
|
|
|
++ optional pdfSupport "--enable-pdf"
|
2020-03-30 22:42:55 +02:00
|
|
|
)) ++ optional (!x11Support) "--disable-xlib";
|
2008-03-07 16:43:43 +01:00
|
|
|
|
2013-01-29 13:48:25 +01:00
|
|
|
preConfigure =
|
2012-10-18 10:53:05 +02:00
|
|
|
# On FreeBSD, `-ldl' doesn't exist.
|
2021-01-21 18:00:13 +01:00
|
|
|
lib.optionalString stdenv.isFreeBSD
|
2012-10-18 12:13:07 +02:00
|
|
|
'' for i in "util/"*"/Makefile.in" boilerplate/Makefile.in
|
|
|
|
do
|
|
|
|
cat "$i" | sed -es/-ldl//g > t
|
|
|
|
mv t "$i"
|
|
|
|
done
|
2015-10-06 19:57:45 +02:00
|
|
|
''
|
|
|
|
+
|
2013-06-13 15:12:43 +02:00
|
|
|
''
|
|
|
|
# Work around broken `Requires.private' that prevents Freetype
|
|
|
|
# `-I' flags to be propagated.
|
|
|
|
sed -i "src/cairo.pc.in" \
|
2015-10-28 19:38:17 +01:00
|
|
|
-es'|^Cflags:\(.*\)$|Cflags: \1 -I${freetype.dev}/include/freetype2 -I${freetype.dev}/include|g'
|
2019-03-28 22:23:31 +01:00
|
|
|
substituteInPlace configure --replace strings $STRINGS
|
2013-06-13 15:12:43 +02:00
|
|
|
'';
|
2009-01-25 12:50:29 +01:00
|
|
|
|
2012-05-16 22:49:31 +02:00
|
|
|
enableParallelBuilding = true;
|
2009-01-25 12:50:29 +01:00
|
|
|
|
2018-04-25 05:20:18 +02:00
|
|
|
doCheck = false; # fails
|
|
|
|
|
2021-01-21 18:00:13 +01:00
|
|
|
postInstall = lib.optionalString stdenv.isDarwin glib.flattenInclude;
|
2011-02-08 18:57:00 +01:00
|
|
|
|
2021-01-21 18:00:13 +01:00
|
|
|
meta = with lib; {
|
2008-03-07 16:43:43 +01:00
|
|
|
description = "A 2D graphics library with support for multiple output devices";
|
2009-01-24 22:32:25 +01:00
|
|
|
|
|
|
|
longDescription = ''
|
|
|
|
Cairo is a 2D graphics library with support for multiple output
|
|
|
|
devices. Currently supported output targets include the X
|
|
|
|
Window System, Quartz, Win32, image buffers, PostScript, PDF,
|
|
|
|
and SVG file output. Experimental backends include OpenGL
|
|
|
|
(through glitz), XCB, BeOS, OS/2, and DirectFB.
|
|
|
|
|
|
|
|
Cairo is designed to produce consistent output on all output
|
|
|
|
media while taking advantage of display hardware acceleration
|
|
|
|
when available (e.g., through the X Render Extension).
|
|
|
|
'';
|
|
|
|
|
2020-04-01 03:11:51 +02:00
|
|
|
homepage = "http://cairographics.org/";
|
2009-01-24 22:32:25 +01:00
|
|
|
|
2015-05-27 21:56:04 +02:00
|
|
|
license = with licenses; [ lgpl2Plus mpl10 ];
|
2011-09-26 14:07:24 +02:00
|
|
|
|
2015-05-27 21:56:04 +02:00
|
|
|
platforms = platforms.all;
|
2008-03-07 16:43:43 +01:00
|
|
|
};
|
2005-10-12 16:00:20 +02:00
|
|
|
}
|