From f972b13ac5eff4b7a5c5053730b69c60c262ce53 Mon Sep 17 00:00:00 2001
From: Michael Raskin <7c6f434c@mail.ru>
Date: Wed, 20 Aug 2008 11:30:06 +0000
Subject: [PATCH] A paranoia-induced refactoring, a cleanup of buildInputs
 bypass in font-related part, fix for builderDefsPackage for cleaner
 overrides.

svn path=/nixpkgs/trunk/; revision=12671
---
 pkgs/top-level/builder-defs.nix | 21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/pkgs/top-level/builder-defs.nix b/pkgs/top-level/builder-defs.nix
index 1b2ba4e4226d..e3c27d072120 100644
--- a/pkgs/top-level/builder-defs.nix
+++ b/pkgs/top-level/builder-defs.nix
@@ -130,7 +130,7 @@ args: with args; with stringsWithDeps; with lib;
                 }
 
                 pkgs=\"\"
-                for i in \$NIX_GCC ${toString buildInputs}; do
+                for i in \$NIX_GCC ${toString realBuildInputs}; do
                     findInputs \$i
                 done
 
@@ -362,7 +362,7 @@ args: with args; with stringsWithDeps; with lib;
         autoConfigureFlags = condConcat "" configFlags check;
         autoMakeFlags = condConcat "" buildFlags check;
         useConfig = getAttr ["useConfig"] false args;
-        buildInputs = 
+        realBuildInputs = 
                 lib.closePropagation ((if useConfig then 
                         autoBuildInputs else 
                         getAttr ["buildInputs"] [] args)++
@@ -461,8 +461,8 @@ args: with args; with stringsWithDeps; with lib;
         # for overrides..
 	builderDefsArgs = args;
 
-        innerBuilderDefsPackage = bd: func: args: (
-        let localDefs = bd.meta.function ((func (bd // args)) // args); in
+        innerBuilderDefsPackage = bd: args: (
+        let localDefs = bd.meta.function args; in
 
         stdenv.mkDerivation ((rec {
           inherit (localDefs) name;
@@ -474,12 +474,15 @@ args: with args; with stringsWithDeps; with lib;
         } else {}) // extraDerivationAttrs)
         );
 
-	builderDefsPackage = bd: func: args: (composedArgsAndFun 
-	  (innerBuilderDefsPackage bd func) ((func (bd // args)) // args));
+	builderDefsPackage = bd: func:
+	  foldArgs 
+	    (x: y: ((func (bd // x // y)) // y))
+            (innerBuilderDefsPackage bd)
+	    {};
 
-   generateFontsFromSFD = noDepEntry(''
+   generateFontsFromSFD = FullDepEntry (''
            for i in *.sfd; do
-                ${args.fontforge}/bin/fontforge -c \
+                fontforge -c \
                         'Open($1);
                         ${optionalString (args ? extraFontForgeCommands) args.extraFontForgeCommands
                         }Reencode("unicode");
@@ -493,7 +496,7 @@ args: with args; with stringsWithDeps; with lib;
                          ${optionalString (getAttr ["createENC"] true args) ''Generate($1:r + ".enc");''}
                         ' $i; 
         done
-   '');
+   '') ["minInit" "addInputs" "doUnpack"];
 
    installFonts = FullDepEntry (''
            ensureDir $out/share/fonts/truetype/public/${args.name}