2021-02-05 17:12:51 +00:00
|
|
|
{ config, lib, stdenv, fetchurl, fetchpatch, pkg-config, libiconv
|
2020-04-24 23:36:52 +00:00
|
|
|
, libintl, expat, zlib, libpng, pixman, fontconfig, freetype
|
|
|
|
, x11Support? !stdenv.isDarwin, libXext, libXrender
|
|
|
|
, gobjectSupport ? true, glib
|
|
|
|
, xcbSupport ? x11Support, libxcb, xcbutil # no longer experimental since 1.12
|
2021-02-05 17:12:51 +00:00
|
|
|
, libGLSupported ? lib.elem stdenv.hostPlatform.system lib.platforms.mesaPlatforms
|
2020-08-20 17:08:02 +00:00
|
|
|
, glSupport ? x11Support && config.cairo.gl or (libGLSupported && stdenv.isLinux)
|
2020-04-24 23:36:52 +00:00
|
|
|
, libGL ? null # libGLU libGL is no longer a big dependency
|
|
|
|
, pdfSupport ? true
|
|
|
|
, darwin
|
|
|
|
}:
|
|
|
|
|
2020-08-20 17:08:02 +00:00
|
|
|
assert glSupport -> x11Support && libGL != null;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
let
|
|
|
|
version = "1.16.0";
|
2021-02-05 17:12:51 +00:00
|
|
|
inherit (lib) optional optionals;
|
2020-04-24 23:36:52 +00:00
|
|
|
in stdenv.mkDerivation rec {
|
|
|
|
pname = "cairo";
|
|
|
|
inherit version;
|
|
|
|
|
|
|
|
src = fetchurl {
|
2021-02-05 17:12:51 +00:00
|
|
|
url = "https://cairographics.org/${if lib.mod (builtins.fromJSON (lib.versions.minor version)) 2 == 0 then "releases" else "snapshots"}/${pname}-${version}.tar.xz";
|
2020-04-24 23:36:52 +00:00
|
|
|
sha256 = "0c930mk5xr2bshbdljv005j3j8zr47gqmkry3q6qgvqky6rjjysy";
|
|
|
|
};
|
|
|
|
|
|
|
|
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-07-14 22:03:04 +00: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-08-22 07:53:02 +00: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";
|
|
|
|
})
|
2022-08-12 12:06:08 +00:00
|
|
|
|
2020-10-19 09:53:12 +00:00
|
|
|
# Workaround https://gitlab.freedesktop.org/cairo/cairo/-/issues/121
|
|
|
|
./skip-configure-stderr-check.patch
|
2022-08-12 12:06:08 +00:00
|
|
|
|
|
|
|
# Fixes cairo crash on macOS Big Sur
|
|
|
|
# Upstream PR: https://gitlab.freedesktop.org/cairo/cairo/-/issues/420
|
|
|
|
(fetchpatch {
|
|
|
|
url = "https://gitlab.freedesktop.org/cairo/cairo/-/commit/e22d7212acb454daccc088619ee147af03883974.diff";
|
|
|
|
sha256 = "sha256-8G98nsPz3MLEWPDX9F0jKgXC4hC4NNdFQLSpmW3ay2s=";
|
|
|
|
})
|
2022-08-21 13:32:41 +00:00
|
|
|
|
|
|
|
# Fix unexpected color addition on grayscale images (usually text).
|
|
|
|
# Upstream fix: https://gitlab.freedesktop.org/cairo/cairo/-/merge_requests/114
|
|
|
|
# Can be removed after 1.18 release
|
|
|
|
(fetchpatch {
|
|
|
|
name = "fix-grayscale-anialias.patch";
|
|
|
|
url = "https://gitlab.freedesktop.org/cairo/cairo/-/commit/4f4d89506f58a64b4829b1bb239bab9e46d63727.diff";
|
|
|
|
sha256 = "sha256-mbTg67e7APfdELsuMAgXdY3xokWbGtHF7VDD5UyYqKM=";
|
|
|
|
})
|
2020-04-24 23:36:52 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
outputs = [ "out" "dev" "devdoc" ];
|
|
|
|
outputBin = "dev"; # very small
|
2021-09-26 12:46:18 +00:00
|
|
|
separateDebugInfo = true;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
nativeBuildInputs = [
|
2021-02-05 17:12:51 +00:00
|
|
|
pkg-config
|
2020-04-24 23:36:52 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
buildInputs = [
|
|
|
|
libiconv
|
|
|
|
libintl
|
|
|
|
] ++ optionals stdenv.isDarwin (with darwin.apple_sdk.frameworks; [
|
|
|
|
CoreGraphics
|
|
|
|
CoreText
|
|
|
|
ApplicationServices
|
|
|
|
Carbon
|
|
|
|
]);
|
|
|
|
|
|
|
|
propagatedBuildInputs = [ fontconfig expat freetype pixman zlib libpng ]
|
|
|
|
++ optionals x11Support [ libXext libXrender ]
|
|
|
|
++ optionals xcbSupport [ libxcb xcbutil ]
|
|
|
|
++ optional gobjectSupport glib
|
|
|
|
++ optional glSupport libGL
|
|
|
|
; # TODO: maybe liblzo but what would it be for here?
|
|
|
|
|
2021-07-03 03:11:41 +00:00
|
|
|
configureFlags = [
|
|
|
|
"--enable-tee"
|
|
|
|
] ++ (if stdenv.isDarwin then [
|
2020-04-24 23:36:52 +00:00
|
|
|
"--disable-dependency-tracking"
|
|
|
|
"--enable-quartz"
|
|
|
|
"--enable-quartz-font"
|
|
|
|
"--enable-quartz-image"
|
|
|
|
"--enable-ft"
|
2021-07-03 03:11:41 +00:00
|
|
|
] else (optional xcbSupport "--enable-xcb"
|
2020-04-24 23:36:52 +00:00
|
|
|
++ optional glSupport "--enable-gl"
|
|
|
|
++ optional pdfSupport "--enable-pdf"
|
|
|
|
)) ++ optional (!x11Support) "--disable-xlib";
|
|
|
|
|
|
|
|
preConfigure =
|
|
|
|
# On FreeBSD, `-ldl' doesn't exist.
|
2021-02-05 17:12:51 +00:00
|
|
|
lib.optionalString stdenv.isFreeBSD
|
2020-04-24 23:36:52 +00:00
|
|
|
'' for i in "util/"*"/Makefile.in" boilerplate/Makefile.in
|
|
|
|
do
|
|
|
|
cat "$i" | sed -es/-ldl//g > t
|
|
|
|
mv t "$i"
|
|
|
|
done
|
|
|
|
''
|
|
|
|
+
|
|
|
|
''
|
|
|
|
# Work around broken `Requires.private' that prevents Freetype
|
|
|
|
# `-I' flags to be propagated.
|
|
|
|
sed -i "src/cairo.pc.in" \
|
|
|
|
-es'|^Cflags:\(.*\)$|Cflags: \1 -I${freetype.dev}/include/freetype2 -I${freetype.dev}/include|g'
|
|
|
|
substituteInPlace configure --replace strings $STRINGS
|
|
|
|
'';
|
|
|
|
|
|
|
|
enableParallelBuilding = true;
|
|
|
|
|
|
|
|
doCheck = false; # fails
|
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
postInstall = lib.optionalString stdenv.isDarwin glib.flattenInclude;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
meta = with lib; {
|
2020-04-24 23:36:52 +00:00
|
|
|
description = "A 2D graphics library with support for multiple output devices";
|
|
|
|
|
|
|
|
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).
|
|
|
|
'';
|
|
|
|
|
|
|
|
homepage = "http://cairographics.org/";
|
|
|
|
|
|
|
|
license = with licenses; [ lgpl2Plus mpl10 ];
|
|
|
|
|
|
|
|
platforms = platforms.all;
|
|
|
|
};
|
|
|
|
}
|