nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 stdenv,
4 fetchurl,
5 pkg-config,
6 glib,
7 freetype,
8 libintl,
9 meson,
10 ninja,
11 gobject-introspection,
12 buildPackages,
13 withIntrospection ?
14 lib.meta.availableOn stdenv.hostPlatform gobject-introspection
15 && stdenv.hostPlatform.emulatorAvailable buildPackages,
16 icu,
17 graphite2,
18 harfbuzz, # The icu variant uses and propagates the non-icu one.
19 withCoreText ? stdenv.hostPlatform.isDarwin, # withCoreText is required for macOS
20 withIcu ? false, # recommended by upstream as default, but most don't needed and it's big
21 withGraphite2 ? true, # it is small and major distros do include it
22 python3,
23 gtk-doc,
24 docbook-xsl-nons,
25 docbook_xml_dtd_43,
26 # for passthru.tests
27 gimp,
28 gtk3,
29 gtk4,
30 mapnik,
31 qt5,
32 testers,
33}:
34
35stdenv.mkDerivation (finalAttrs: {
36 pname = "harfbuzz${lib.optionalString withIcu "-icu"}";
37 version = "11.2.1";
38
39 src = fetchurl {
40 url = "https://github.com/harfbuzz/harfbuzz/releases/download/${finalAttrs.version}/harfbuzz-${finalAttrs.version}.tar.xz";
41 hash = "sha256-CTcUyFSKKFCUaF8L3JmeIC1ma1nus98v+SGraLgzakk=";
42 };
43
44 postPatch = ''
45 patchShebangs src/*.py test
46 ''
47 + lib.optionalString stdenv.hostPlatform.isDarwin ''
48 # ApplicationServices.framework headers have cast-align warnings.
49 substituteInPlace src/hb.hh \
50 --replace '#pragma GCC diagnostic error "-Wcast-align"' ""
51 '';
52
53 outputs = [
54 "out"
55 "dev"
56 "devdoc"
57 ];
58 outputBin = "dev";
59
60 mesonFlags = [
61 # upstream recommends cairo, but it is only used for development purposes
62 # and is not part of the library.
63 # Cairo causes transitive (build) dependencies on various X11 or other
64 # GUI-related libraries, so it shouldn't be re-added lightly.
65 (lib.mesonEnable "cairo" false)
66 # chafa is only used in a development utility, not in the library
67 (lib.mesonEnable "chafa" false)
68 (lib.mesonEnable "coretext" withCoreText)
69 (lib.mesonEnable "graphite" withGraphite2)
70 (lib.mesonEnable "icu" withIcu)
71 (lib.mesonEnable "introspection" withIntrospection)
72 (lib.mesonOption "cmakepackagedir" "${placeholder "dev"}/lib/cmake")
73 ];
74
75 depsBuildBuild = [
76 pkg-config
77 ];
78
79 nativeBuildInputs = [
80 meson
81 ninja
82 libintl
83 pkg-config
84 python3
85 glib
86 gtk-doc
87 docbook-xsl-nons
88 docbook_xml_dtd_43
89 ]
90 ++ lib.optional withIntrospection gobject-introspection;
91
92 buildInputs = [
93 glib
94 freetype
95 ];
96
97 propagatedBuildInputs =
98 lib.optional withGraphite2 graphite2
99 ++ lib.optionals withIcu [
100 icu
101 harfbuzz
102 ];
103
104 doCheck = true;
105
106 # Slightly hacky; some pkgs expect them in a single directory.
107 postFixup = lib.optionalString withIcu ''
108 rm "$out"/lib/libharfbuzz.* "$dev/lib/pkgconfig/harfbuzz.pc"
109 ln -s {'${harfbuzz.dev}',"$dev"}/lib/pkgconfig/harfbuzz.pc
110 ${lib.optionalString stdenv.hostPlatform.isDarwin ''
111 ln -s {'${harfbuzz.out}',"$out"}/lib/libharfbuzz.dylib
112 ln -s {'${harfbuzz.out}',"$out"}/lib/libharfbuzz.0.dylib
113 ''}
114 '';
115
116 passthru.tests = {
117 inherit
118 gimp
119 gtk3
120 gtk4
121 mapnik
122 ;
123 inherit (qt5) qtbase;
124 pkg-config = testers.hasPkgConfigModules {
125 package = finalAttrs.finalPackage;
126 };
127 };
128
129 meta = with lib; {
130 description = "OpenType text shaping engine";
131 homepage = "https://harfbuzz.github.io/";
132 changelog = "https://github.com/harfbuzz/harfbuzz/raw/${finalAttrs.version}/NEWS";
133 maintainers = [ ];
134 license = licenses.mit;
135 platforms = platforms.unix ++ platforms.windows;
136 pkgConfigModules = [
137 "harfbuzz"
138 "harfbuzz-gobject"
139 "harfbuzz-subset"
140 ];
141 };
142})