core/pkgs/by-name/ca/cairo/default.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

165 lines
3.9 KiB
Nix
Raw Normal View History

2024-05-02 00:46:19 +00:00
{
lib,
stdenv,
fetchurl,
fetchpatch,
gtk-doc,
meson,
ninja,
pkg-config,
python3,
docbook_xsl,
fontconfig,
freetype,
libpng,
pixman,
zlib,
x11Support ? !stdenv.isDarwin || true,
libXext,
libXrender,
gobjectSupport ? true,
glib,
xcbSupport ? x11Support,
libxcb,
darwin,
testers,
}:
let
inherit (lib) optional optionals;
in
stdenv.mkDerivation (
finalAttrs:
let
inherit (finalAttrs) pname version;
in
{
pname = "cairo";
version = "1.18.0";
2024-06-30 08:16:52 +00:00
2024-05-02 00:46:19 +00:00
src = fetchurl {
url = "https://cairographics.org/${
if lib.mod (builtins.fromJSON (lib.versions.minor version)) 2 == 0 then "releases" else "snapshots"
}/${pname}-${version}.tar.xz";
hash = "sha256-JDoHNrl4oz3uKfnMp1IXM7eKZbVBggb+970cPUzxC2Q=";
};
2024-06-30 08:16:52 +00:00
2024-05-02 00:46:19 +00:00
outputs = [
"out"
"dev"
"devdoc"
];
outputBin = "dev"; # very small
separateDebugInfo = true;
2024-06-30 08:16:52 +00:00
2024-05-02 00:46:19 +00:00
nativeBuildInputs = [
gtk-doc
meson
ninja
pkg-config
python3
];
2024-06-30 08:16:52 +00:00
2024-05-02 00:46:19 +00:00
buildInputs =
[ docbook_xsl ]
++ optionals stdenv.isDarwin (
with darwin.apple_sdk.frameworks;
[
CoreGraphics
CoreText
ApplicationServices
Carbon
2024-06-30 08:16:52 +00:00
]
);
2024-05-02 00:46:19 +00:00
propagatedBuildInputs =
2024-06-30 08:16:52 +00:00
[
2024-05-02 00:46:19 +00:00
fontconfig
freetype
2024-06-30 08:16:52 +00:00
pixman
2024-05-02 00:46:19 +00:00
libpng
zlib
2024-06-30 08:16:52 +00:00
]
2024-05-02 00:46:19 +00:00
++ optionals x11Support [
2024-06-30 08:16:52 +00:00
libXext
2024-05-02 00:46:19 +00:00
libXrender
2024-06-30 08:16:52 +00:00
]
2024-05-02 00:46:19 +00:00
++ optionals xcbSupport [ libxcb ]
++ optional gobjectSupport glib; # TODO: maybe liblzo but what would it be for here?
2024-06-30 08:16:52 +00:00
2024-05-02 00:46:19 +00:00
mesonFlags =
2024-06-30 08:16:52 +00:00
[
2024-05-02 00:46:19 +00:00
"-Dgtk_doc=true"
2024-06-30 08:16:52 +00:00
2024-05-02 00:46:19 +00:00
# error: #error config.h must be included before this header
"-Dsymbol-lookup=disabled"
2024-06-30 08:16:52 +00:00
2024-05-02 00:46:19 +00:00
# Only used in tests, causes a dependency cycle
"-Dspectre=disabled"
2024-06-30 08:16:52 +00:00
2024-05-02 00:46:19 +00:00
(lib.mesonEnable "glib" gobjectSupport)
(lib.mesonEnable "tests" finalAttrs.finalPackage.doCheck)
(lib.mesonEnable "xlib" x11Support)
(lib.mesonEnable "xcb" xcbSupport)
2024-06-30 08:16:52 +00:00
]
2024-05-02 00:46:19 +00:00
++ lib.optionals (!stdenv.buildPlatform.canExecute stdenv.hostPlatform) [
"--cross-file=${builtins.toFile "cross-file.conf" ''
[properties]
ipc_rmid_deferred_release = ${
2024-06-30 08:16:52 +00:00
{
2024-05-02 00:46:19 +00:00
linux = "true";
freebsd = "true";
netbsd = "false";
2024-06-30 08:16:52 +00:00
}
2024-05-02 00:46:19 +00:00
.${stdenv.hostPlatform.parsed.kernel.name} or (throw "Unknown value for ipc_rmid_deferred_release")
2024-06-30 08:16:52 +00:00
}
''}"
];
2024-05-02 00:46:19 +00:00
preConfigure = ''
patchShebangs version.py
'';
2024-06-30 08:16:52 +00:00
2024-05-02 00:46:19 +00:00
enableParallelBuilding = true;
2024-06-30 08:16:52 +00:00
2024-05-02 00:46:19 +00:00
doCheck = false; # fails
2024-06-30 08:16:52 +00:00
2024-05-02 00:46:19 +00:00
postInstall =
2024-06-30 08:16:52 +00:00
''
2024-05-02 00:46:19 +00:00
# Work around broken `Requires.private' that prevents Freetype
# `-I' flags to be propagated.
sed -i "$out/lib/pkgconfig/cairo.pc" \
-es'|^Cflags:\(.*\)$|Cflags: \1 -I${freetype.dev}/include/freetype2 -I${freetype.dev}/include|g'
2024-06-30 08:16:52 +00:00
''
2024-05-02 00:46:19 +00:00
+ lib.optionalString stdenv.isDarwin glib.flattenInclude;
2024-06-30 08:16:52 +00:00
2024-05-02 00:46:19 +00:00
passthru.tests.pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage;
2024-06-30 08:16:52 +00:00
2024-05-02 00:46:19 +00:00
meta = with lib; {
description = "A 2D graphics library with support for multiple output devices";
mainProgram = "cairo-trace";
longDescription = ''
Cairo is a 2D graphics library with support for multiple output
devices. Currently supported output targets include the X
Window System, XCB, Quartz, Win32, image buffers, PostScript,
PDF, and SVG file output.
2024-06-30 08:16:52 +00:00
2024-05-02 00:46:19 +00:00
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).
2024-06-30 08:16:52 +00:00
'';
2024-05-02 00:46:19 +00:00
homepage = "http://cairographics.org/";
license = with licenses; [
lgpl2Plus
mpl10
];
pkgConfigModules = [
"cairo-pdf"
"cairo-ps"
"cairo-svg"
] ++ lib.optional gobjectSupport "cairo-gobject";
platforms = platforms.all;
};
}
)