reverted (10214) and merged my changes again because I had changed a lot of line by accident

svn path=/nixpkgs/trunk/; revision=10246
This commit is contained in:
Marc Weber 2008-01-22 15:13:35 +00:00
parent 22c7d08b6a
commit dffda95fdd

View File

@ -1,39 +1,3 @@
# see dep-strings.nix as well
/*
questions:
add some comments?
why is prefix used in doConfigure ? shouldn't that be out?
don't think toSrcDir should cd to the directory.
I'd prefer cd `toSrcDir xx.tar.gz`
Then you can use it to unpack files
suggestion:
deps before text? why?
It's kind of documentation and much less lines most of the time ?
remove noDepEntry, FullDepEntry, PackEntry all together and use { ... } ?
you only have to remember two words: text and deps which isn't hard
using noDepEntry FullDepEntry PackEntry you'll have to remember 3 words and argument order
You just have to learn it once.. ?
no way to override steps ?
separate settings from dep entries
(eg patchFlags / forceShare, patches) to get a better overview ? )
envAdderInner: What about a small example? It took quite some time to understand how to use it
eg envAdderInner "" "A" "B" "C" "D" null results in
echo export A="$A:B";
echo export C="$C:D";
does'nt handle the env has been empty don't add delimiter case
*/
args: with args; with stringsWithDeps; with lib; args: with args; with stringsWithDeps; with lib;
(rec (rec
{ {
@ -54,7 +18,6 @@ args: with args; with stringsWithDeps; with lib;
# Last block - for single files!! It should be always after .tar.* # Last block - for single files!! It should be always after .tar.*
else if (hasSuffixHack ".bz2" s) then "plain-bz2" else if (hasSuffixHack ".bz2" s) then "plain-bz2"
else if (hasSuffixHack ".zip" s) || (hasSuffixHack ".ZIP" s) then "zip"
else (abort "unknown archive type : ${s}")); else (abort "unknown archive type : ${s}"));
defAddToSearchPath = FullDepEntry (" defAddToSearchPath = FullDepEntry ("
@ -77,7 +40,7 @@ args: with args; with stringsWithDeps; with lib;
{ {
addToSearchPathWithCustomDelimiter \"\${PATH_DELIMITER}\" \"\$@\" addToSearchPathWithCustomDelimiter \"\${PATH_DELIMITER}\" \"\$@\"
} }
") [defNest]; ") ["defNest"];
defNest = noDepEntry (" defNest = noDepEntry ("
nestingLevel=0 nestingLevel=0
@ -132,7 +95,7 @@ args: with args; with stringsWithDeps; with lib;
prefix=${if args ? prefix then (toString args.prefix) else "\$out"} prefix=${if args ? prefix then (toString args.prefix) else "\$out"}
" "
else "")) [defNest defAddToSearchPath]; else "")) ["defNest" "defAddToSearchPath"];
addInputs = FullDepEntry (" addInputs = FullDepEntry ("
# Recursively find all build inputs. # Recursively find all build inputs.
@ -152,12 +115,6 @@ args: with args; with stringsWithDeps; with lib;
if test -f \$pkg/nix-support/setup-hook; then if test -f \$pkg/nix-support/setup-hook; then
source \$pkg/nix-support/setup-hook source \$pkg/nix-support/setup-hook
fi fi
if test -f \$pkg/nix-support/propagated-build-inputs; then
for i in \$(cat \$pkg/nix-support/propagated-build-inputs); do
findInputs \$i
done
fi
} }
pkgs=\"\" pkgs=\"\"
@ -204,7 +161,7 @@ args: with args; with stringsWithDeps; with lib;
fi fi
PATH=\$_PATH\${_PATH:+:}\$PATH PATH=\$_PATH\${_PATH:+:}\$PATH
") [minInit]; ") ["minInit"];
defEnsureDir = FullDepEntry (" defEnsureDir = FullDepEntry ("
# Ensure that the given directories exists. # Ensure that the given directories exists.
@ -214,7 +171,7 @@ args: with args; with stringsWithDeps; with lib;
if ! test -x \"\$dir\"; then mkdir -p \"\$dir\"; fi if ! test -x \"\$dir\"; then mkdir -p \"\$dir\"; fi
done done
} }
") [minInit]; ") ["minInit"];
toSrcDir = s : FullDepEntry ((if (archiveType s) == "tar" then " toSrcDir = s : FullDepEntry ((if (archiveType s) == "tar" then "
tar xvf '${s}' tar xvf '${s}'
@ -243,11 +200,11 @@ args: with args; with stringsWithDeps; with lib;
cd \$(basename ${s} .bz2) cd \$(basename ${s} .bz2)
" else (abort "unknown archive type : ${s}"))+ " else (abort "unknown archive type : ${s}"))+
(if args ? goSrcDir then args.goSrcDir else "") (if args ? goSrcDir then args.goSrcDir else "")
) [minInit]; ) ["minInit"];
doConfigure = FullDepEntry (" doConfigure = FullDepEntry ("
./configure --prefix=\"\$prefix\" ${toString configureFlags} ./configure --prefix=\"\$prefix\" ${toString configureFlags}
") [minInit addInputs doUnpack]; ") ["minInit" "addInputs" "doUnpack"];
doAutotools = FullDepEntry (" doAutotools = FullDepEntry ("
mkdir -p config mkdir -p config
@ -257,21 +214,21 @@ args: with args; with stringsWithDeps; with lib;
autoheader || true; autoheader || true;
automake --add-missing --copy automake --add-missing --copy
autoconf autoconf
")[minInit addInputs doUnpack]; ")["minInit" "addInputs" "doUnpack"];
doMake = FullDepEntry (" doMake = FullDepEntry ("
make ${toString makeFlags} make ${toString makeFlags}
") [minInit addInputs doUnpack]; ") ["minInit" "addInputs" "doUnpack"];
doUnpack = toSrcDir (toString src); doUnpack = toSrcDir (toString src);
installPythonPackage = FullDepEntry (" installPythonPackage = FullDepEntry ("
python setup.py install --prefix=\"\$prefix\" python setup.py install --prefix=\"\$prefix\"
") [minInit addInputs doUnpack]; ") ["minInit" "addInputs" "doUnpack"];
doMakeInstall = FullDepEntry (" doMakeInstall = FullDepEntry ("
make ${toString (getAttr ["makeFlags"] "" args)} "+ make ${toString (getAttr ["makeFlags"] "" args)} "+
"${toString (getAttr ["installFlags"] "" args)} install") [doMake]; "${toString (getAttr ["installFlags"] "" args)} install") ["doMake"];
doForceShare = FullDepEntry (" doForceShare = FullDepEntry ("
ensureDir \"\$prefix/share\" ensureDir \"\$prefix/share\"
@ -281,7 +238,7 @@ args: with args; with stringsWithDeps; with lib;
ln -sv share/\$d \"\$prefix\" ln -sv share/\$d \"\$prefix\"
fi; fi;
done; done;
") [minInit defEnsureDir]; ") ["minInit" "defEnsureDir"];
doDump = n: noDepEntry "echo Dump number ${n}; set"; doDump = n: noDepEntry "echo Dump number ${n}; set";
@ -293,7 +250,7 @@ args: with args; with stringsWithDeps; with lib;
doPatch = FullDepEntry (concatStringsSep ";" doPatch = FullDepEntry (concatStringsSep ";"
(map toPatchCommand patches) (map toPatchCommand patches)
) [minInit doUnpack]; ) ["minInit" "doUnpack"];
envAdderInner = s: x: if x==null then s else y: envAdderInner = s: x: if x==null then s else y:
a: envAdderInner (s+"echo export ${x}='\"'\"\$${x}:${y}\";'\"'\n") a; a: envAdderInner (s+"echo export ${x}='\"'\"\$${x}:${y}\";'\"'\n") a;
@ -311,12 +268,12 @@ args: with args; with stringsWithDeps; with lib;
(${envAdderList env} (${envAdderList env}
echo '\"'\"${cmd}-orig\"'\"' '\"'\\\$@'\"' \n) > \"${cmd}\""; echo '\"'\"${cmd}-orig\"'\"' '\"'\\\$@'\"' \n) > \"${cmd}\"";
doWrap = cmd: FullDepEntry (wrapEnv cmd (getAttr ["wrappedEnv"] [] args)) [minInit]; doWrap = cmd: FullDepEntry (wrapEnv cmd (getAttr ["wrappedEnv"] [] args)) ["minInit"];
doPropagate = FullDepEntry (" doPropagate = FullDepEntry ("
ensureDir \$out/nix-support ensureDir \$out/nix-support
echo '${toString (getAttr ["propagatedBuildInputs"] [] args)}' >\$out/nix-support/propagated-build-inputs echo '${toString (getAttr ["propagatedBuildInputs"] [] args)}' >\$out/nix-support/propagated-build-inputs
") [minInit defEnsureDir]; ") ["minInit" "defEnsureDir"];
/*debug = x:(__trace x x); /*debug = x:(__trace x x);
debugX = x:(__trace (__toXML x) x);*/ debugX = x:(__trace (__toXML x) x);*/
@ -326,7 +283,7 @@ args: with args; with stringsWithDeps; with lib;
replaceScripts = l:(concatStringsSep "\n" (pairMap replaceInScript l)); replaceScripts = l:(concatStringsSep "\n" (pairMap replaceInScript l));
doReplaceScripts = FullDepEntry (replaceScripts (getAttr ["shellReplacements"] [] args)) [minInit]; doReplaceScripts = FullDepEntry (replaceScripts (getAttr ["shellReplacements"] [] args)) [minInit];
makeNest = x:(if x==defNest.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; textClosure = textClosureMapOveridable makeNest;
inherit noDepEntry FullDepEntry PackEntry; inherit noDepEntry FullDepEntry PackEntry;
@ -361,6 +318,7 @@ args: with args; with stringsWithDeps; with lib;
surroundWithCommands = x : before : after : {deps=x.deps; text = before + "\n" + surroundWithCommands = x : before : after : {deps=x.deps; text = before + "\n" +
x.text + "\n" + after ;}; x.text + "\n" + after ;};
# some haskell stuff - untested! # some haskell stuff - untested!
# -------------------------------------------------------- # --------------------------------------------------------
# creates a setup hook # creates a setup hook
@ -386,7 +344,7 @@ args: with args; with stringsWithDeps; with lib;
# Either rungghc or compile setup.hs # Either rungghc or compile setup.hs
# / which one is better ? runghc had some trouble with ghc-6.6.1 # / which one is better ? runghc had some trouble with ghc-6.6.1
defineCabalSetupCmd = noDepEntry " defCabalSetupCmd = noDepEntry "
CABAL_SETUP=\"runghc setup.hs\" CABAL_SETUP=\"runghc setup.hs\"
"; ";
@ -411,7 +369,7 @@ args: with args; with stringsWithDeps; with lib;
# using ./setup copy to install # using ./setup copy to install
# and ./setup register --gen-script to install to our local database # and ./setup register --gen-script to install to our local database
# after replacing /usr/lib etc with our pure $out path # after replacing /usr/lib etc with our pure $out path
defCabalBuild = FullDepEntry cabalBuild = FullDepEntry
(if (args ? subdir) then "cd ${args.subdir}" else "")+ " (if (args ? subdir) then "cd ${args.subdir}" else "")+ "
createEmptyPackageDatabaseAndSetupHook createEmptyPackageDatabaseAndSetupHook
ghc --make setup.hs -o setup ghc --make setup.hs -o setup
@ -422,6 +380,6 @@ args: with args; with stringsWithDeps; with lib;
sed -e 's=/usr/local/lib=\$out=g' \\ sed -e 's=/usr/local/lib=\$out=g' \\
-i register.sh -i register.sh
GHC_PACKAGE_PATH=\$PACKAGE_DB ./register.sh GHC_PACKAGE_PATH=\$PACKAGE_DB ./register.sh
" [defCreateEmptyPackageDatabaseAndSetupHook defineCabalSetupCmd]; " [defCreateEmptyPackageDatabaseAndSetupHook defCabalSetupCmd];
}) // args }) // args