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