From a829337ea662a8249ddbfd3ab35e4ddf6c7c02ec Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Vladim=C3=ADr=20=C4=8Cun=C3=A1t?= <vcunat@gmail.com>
Date: Sun, 24 Nov 2013 13:51:12 +0100
Subject: [PATCH] harfbuzz by default: don't use icu and do use graphite2

Also fix detection, so texLive builds now.
---
 .../libraries/harfbuzz/default.nix            | 20 +++++++++++++++----
 pkgs/top-level/all-packages.nix               |  6 ++----
 2 files changed, 18 insertions(+), 8 deletions(-)

diff --git a/pkgs/development/libraries/harfbuzz/default.nix b/pkgs/development/libraries/harfbuzz/default.nix
index 11cbd0dd1cda..4cee49bea517 100644
--- a/pkgs/development/libraries/harfbuzz/default.nix
+++ b/pkgs/development/libraries/harfbuzz/default.nix
@@ -1,5 +1,11 @@
-{ stdenv, fetchurl, pkgconfig, glib, freetype, cairo, icu
-, graphite2 ? null, libintlOrEmpty }:
+{ stdenv, fetchurl, pkgconfig, glib, freetype, cairo, libintlOrEmpty
+, icu, graphite2
+, withIcu ? false # recommended by upstream as default, but most don't needed and it's big
+, withGraphite2 ? true # it is small and major distros do include it
+}:
+
+# TODO: split non-icu and icu lib into different outputs?
+# (icu is a ~30 MB dependency, the rest is very small in comparison)
 
 stdenv.mkDerivation rec {
   name = "harfbuzz-0.9.24";
@@ -9,10 +15,16 @@ stdenv.mkDerivation rec {
     sha256 = "08i46xx92hvz2br2d9hdxjgi0g5jglwf5bdfsandxb0qlgc5vwpd";
   };
 
-  buildInputs = [ pkgconfig glib freetype cairo icu ] # recommended by upstream
+  configureFlags = [
+    ( "--with-graphite2=" + (if withGraphite2 then "yes" else "no") ) # not auto-detected by default
+    ( "--with-icu=" +       (if withIcu       then "yes" else "no") )
+  ];
+
+  buildInputs = [ pkgconfig glib freetype cairo ] # recommended by upstream
     ++ libintlOrEmpty;
   propagatedBuildInputs = []
-    ++ stdenv.lib.optional (graphite2 != null) graphite2
+    ++ stdenv.lib.optional withGraphite2 graphite2
+    ++ stdenv.lib.optional withIcu icu
     ;
 
   meta = {
diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix
index bcda69ca5986..52e9581a57ac 100644
--- a/pkgs/top-level/all-packages.nix
+++ b/pkgs/top-level/all-packages.nix
@@ -4501,9 +4501,7 @@ let
 
   heimdal = callPackage ../development/libraries/kerberos/heimdal.nix { };
 
-  harfbuzz = callPackage ../development/libraries/harfbuzz {
-    graphite2 = null;
-  };
+  harfbuzz = callPackage ../development/libraries/harfbuzz { };
 
   hawknl = callPackage ../development/libraries/hawknl { };
 
@@ -10196,7 +10194,7 @@ let
       libXmu libXext xextproto libSM libICE;
     ghostscript = ghostscriptX;
     harfbuzz = harfbuzz.override {
-      inherit icu graphite2;
+      withIcu = true; withGraphite2 = true;
     };
   };