From e18c7cec9d3de145c715c76797de0e8792ccccb5 Mon Sep 17 00:00:00 2001 From: Michael Raskin <7c6f434c@mail.ru> Date: Mon, 12 Nov 2007 16:42:13 +0000 Subject: [PATCH] Beta-version of builderDefs fixes. svn path=/nixpkgs/trunk/; revision=9657 --- .../audio/ladspa-plugins/default.nix | 3 +- pkgs/lib/default.nix | 4 + pkgs/top-level/builder-defs.nix | 74 ++++++++++++------- 3 files changed, 54 insertions(+), 27 deletions(-) diff --git a/pkgs/applications/audio/ladspa-plugins/default.nix b/pkgs/applications/audio/ladspa-plugins/default.nix index 9a033a42b878..70dc36240c65 100644 --- a/pkgs/applications/audio/ladspa-plugins/default.nix +++ b/pkgs/applications/audio/ladspa-plugins/default.nix @@ -17,7 +17,8 @@ in stdenv.mkDerivation { name = "swh-plugins-0.4.15"; builder = writeScript "swh-plugins-0.4.15-builder" - (textClosure [doConfigure doMakeInstall postInstall doForceShare]); + (textClosure [doConfigure doMakeInstall + postInstall doForceShare]); meta = { description = " LADSPA format audio plugins. diff --git a/pkgs/lib/default.nix b/pkgs/lib/default.nix index 33b7b3d6c9e5..ce4fbf12cf46 100644 --- a/pkgs/lib/default.nix +++ b/pkgs/lib/default.nix @@ -244,4 +244,8 @@ rec { (l + (if l=="" then "" else ".") + s) (builtins.getAttr s attrs))) (builtins.attrNames attrs))))); + innerModifySumArgs = f: x: a: b: if b == null then (f a b) // x else + innerModifySumArgs f x (a // b); + modifySumArgs = f: x: innerModifySumArgs f x {}; + } diff --git a/pkgs/top-level/builder-defs.nix b/pkgs/top-level/builder-defs.nix index 3337d6dc8a23..ae5224f71011 100644 --- a/pkgs/top-level/builder-defs.nix +++ b/pkgs/top-level/builder-defs.nix @@ -1,5 +1,5 @@ args: with args; with stringsWithDeps; with lib; -rec +(rec { inherit writeScript; @@ -12,30 +12,29 @@ rec else if (hasSuffixHack ".zip" s) || (hasSuffixHack ".ZIP" s) then "zip" else (abort "unknown archive type : ${s}")); - minInit = noDepEntry (" - set -e - NIX_GCC=${stdenv.gcc} - export SHELL=${stdenv.shell} - # Set up the initial path. - PATH= - for i in \$NIX_GCC ${toString stdenv.initialPath}; do - PATH=\$PATH\${PATH:+:}\$i/bin - done - " + (if ((stdenv ? preHook) && (stdenv.preHook != null) && - ((toString stdenv.preHook) != "")) then - " - param1=${stdenv.param1} - param2=${stdenv.param2} - param3=${stdenv.param3} - param4=${stdenv.param4} - param5=${stdenv.param5} - source ${stdenv.preHook} - - export TZ=UTC - - prefix=${if args ? prefix then (toString args.prefix) else "\$out"} + defAddToSearchPath = FullDepEntry (" + addToSearchPathWithCustomDelimiter() { + local delimiter=\$1 + local varName=\$2 + local needDir=\$3 + local addDir=\${4:-\$needDir} + local prefix=\$5 + if [ -d \$prefix\$needDir ]; then + if [ -z \${!varName} ]; then + eval export \${varName}=\${prefix}\$addDir + else + eval export \${varName}=\${!varName}\${delimiter}\${prefix}\$addDir + fi + fi + } + addToSearchPath() + { + addToSearchPathWithCustomDelimiter \"\${PATH_DELIMITER}\" \"\$@\" + } + ") [defNest]; + defNest = noDepEntry (" nestingLevel=0 startNest() { @@ -62,10 +61,33 @@ rec } trap \"closeNest\" EXIT + "); + minInit = FullDepEntry (" + set -e + NIX_GCC=${stdenv.gcc} + export SHELL=${stdenv.shell} + # Set up the initial path. + PATH= + for i in \$NIX_GCC ${toString stdenv.initialPath}; do + PATH=\$PATH\${PATH:+:}\$i/bin + done + " + (if ((stdenv ? preHook) && (stdenv.preHook != null) && + ((toString stdenv.preHook) != "")) then + " + param1=${stdenv.param1} + param2=${stdenv.param2} + param3=${stdenv.param3} + param4=${stdenv.param4} + param5=${stdenv.param5} + source ${stdenv.preHook} + + export TZ=UTC + + prefix=${if args ? prefix then (toString args.prefix) else "\$out"} " - else "")); + else "")) [defNest defAddToSearchPath]; addInputs = FullDepEntry (" # Recursively find all build inputs. @@ -243,8 +265,8 @@ rec replaceInScript = file: l: (concatStringsSep "\n" ((pairMap (replaceScriptVar file) l))); replaceScripts = l:(concatStringsSep "\n" (pairMap replaceInScript l)); doReplaceScripts = FullDepEntry (replaceScripts (getAttr ["shellReplacements"] [] args)) [minInit]; - makeNest = x:(if x==minInit.text then x else "startNest\n" + x + "\nstopNest\n"); + makeNest = x:(if x==defNest.text then x else "startNest\n" + x + "\nstopNest\n"); textClosure = textClosureMap makeNest; inherit noDepEntry FullDepEntry PackEntry; -} +}) // args