1{ stdenv, fetchurl, pkgconfig, glib, freetype, cairo, libintlOrEmpty
2, icu, graphite2, harfbuzz # The icu variant uses and propagates the non-icu one.
3, withIcu ? false # recommended by upstream as default, but most don't needed and it's big
4, withGraphite2 ? true # it is small and major distros do include it
5}:
6
7let
8 version = "1.7.1";
9 inherit (stdenv.lib) optional optionals optionalString;
10in
11
12stdenv.mkDerivation {
13 name = "harfbuzz${optionalString withIcu "-icu"}-${version}";
14
15 src = fetchurl {
16 url = "http://www.freedesktop.org/software/harfbuzz/release/harfbuzz-${version}.tar.bz2";
17 sha256 = "9645a6e83313b690602017f18d4eb2adf81f2e54c6fc4471e19331304965154e";
18 };
19
20 outputs = [ "out" "dev" ];
21 outputBin = "dev";
22
23 configureFlags = [
24 ( "--with-graphite2=" + (if withGraphite2 then "yes" else "no") ) # not auto-detected by default
25 ( "--with-icu=" + (if withIcu then "yes" else "no") )
26 ];
27
28 nativeBuildInputs = [ pkgconfig ];
29 buildInputs = [ glib freetype cairo ] # recommended by upstream
30 ++ libintlOrEmpty;
31 propagatedBuildInputs = []
32 ++ optional withGraphite2 graphite2
33 ++ optionals withIcu [ icu harfbuzz ]
34 ;
35
36 # Slightly hacky; some pkgs expect them in a single directory.
37 postInstall = optionalString withIcu ''
38 rm "$out"/lib/libharfbuzz.* "$dev/lib/pkgconfig/harfbuzz.pc"
39 ln -s {'${harfbuzz.out}',"$out"}/lib/libharfbuzz.la
40 ln -s {'${harfbuzz.dev}',"$dev"}/lib/pkgconfig/harfbuzz.pc
41 ${optionalString stdenv.isDarwin ''
42 ln -s {'${harfbuzz.out}',"$out"}/lib/libharfbuzz.dylib
43 ln -s {'${harfbuzz.out}',"$out"}/lib/libharfbuzz.0.dylib
44 ''}
45 '';
46
47 meta = with stdenv.lib; {
48 description = "An OpenType text shaping engine";
49 homepage = http://www.freedesktop.org/wiki/Software/HarfBuzz;
50 downloadPage = "https://www.freedesktop.org/software/harfbuzz/release/";
51 maintainers = [ maintainers.eelco ];
52 platforms = with platforms; linux ++ darwin;
53 inherit version;
54 updateWalker = true;
55 };
56}