Added doCheck support to builder-defs.nix

svn path=/nixpkgs/trunk/; revision=12371
This commit is contained in:
Michael Raskin 2008-07-17 13:39:58 +00:00
parent ecefcac4d7
commit 622634d6dd
1 changed files with 364 additions and 358 deletions

View File

@ -1,380 +1,380 @@
args: with args; with stringsWithDeps; with lib; args: with args; with stringsWithDeps; with lib;
(rec (rec
{ {
inherit writeScript; inherit writeScript;
src = getAttr ["src"] "" args; src = getAttr ["src"] "" args;
addSbinPath = getAttr ["addSbinPath"] false args; addSbinPath = getAttr ["addSbinPath"] false args;
forceShare = if args ? forceShare then args.forceShare else ["man" "doc" "info"]; forceShare = if args ? forceShare then args.forceShare else ["man" "doc" "info"];
forceCopy = ["COPYING" "LICENSE" "DISTRIBUTION" "LEGAL" forceCopy = ["COPYING" "LICENSE" "DISTRIBUTION" "LEGAL"
"README" "AUTHORS" "ChangeLog" "CHANGES"] ++ "README" "AUTHORS" "ChangeLog" "CHANGES"] ++
(optional (getAttr ["forceCopyDoc"] true args) "doc"); (optional (getAttr ["forceCopyDoc"] true args) "doc");
archiveType = s: archiveType = s:
(if hasSuffixHack ".tar" s then "tar" (if hasSuffixHack ".tar" s then "tar"
else if (hasSuffixHack ".tar.gz" s) || (hasSuffixHack ".tgz" s) then "tgz" else if (hasSuffixHack ".tar.gz" s) || (hasSuffixHack ".tgz" s) then "tgz"
else if (hasSuffixHack ".tar.bz2" s) || (hasSuffixHack ".tbz2" s) then "tbz2" else if (hasSuffixHack ".tar.bz2" s) || (hasSuffixHack ".tbz2" s) then "tbz2"
else if (hasSuffixHack ".tar.lzma" s) then "tar.lzma" else if (hasSuffixHack ".tar.lzma" s) then "tar.lzma"
else if (hasSuffixHack ".zip" s) || (hasSuffixHack ".ZIP" s) then "zip" else if (hasSuffixHack ".zip" s) || (hasSuffixHack ".ZIP" s) then "zip"
else if (hasSuffixHack "-cvs-export" s) then "cvs-dir" else if (hasSuffixHack "-cvs-export" s) then "cvs-dir"
else if (hasSuffixHack ".nar.bz2" s) then "narbz2" else if (hasSuffixHack ".nar.bz2" s) then "narbz2"
# Mostly for manually specified directories.. # Mostly for manually specified directories..
else if (hasSuffixHack "/" s) then "dir" else if (hasSuffixHack "/" s) then "dir"
# 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 (abort "unknown archive type : ${s}")); else (abort "unknown archive type : ${s}"));
defAddToSearchPath = FullDepEntry (" defAddToSearchPath = FullDepEntry ("
addToSearchPathWithCustomDelimiter() { addToSearchPathWithCustomDelimiter() {
local delimiter=\$1 local delimiter=\$1
local varName=\$2 local varName=\$2
local needDir=\$3 local needDir=\$3
local addDir=\${4:-\$needDir} local addDir=\${4:-\$needDir}
local prefix=\$5 local prefix=\$5
if [ -d \$prefix\$needDir ]; then if [ -d \$prefix\$needDir ]; then
if [ -z \${!varName} ]; then if [ -z \${!varName} ]; then
eval export \${varName}=\${prefix}\$addDir eval export \${varName}=\${prefix}\$addDir
else else
eval export \${varName}=\${!varName}\${delimiter}\${prefix}\$addDir eval export \${varName}=\${!varName}\${delimiter}\${prefix}\$addDir
fi fi
fi fi
} }
addToSearchPath() addToSearchPath()
{ {
addToSearchPathWithCustomDelimiter \"\${PATH_DELIMITER}\" \"\$@\" addToSearchPathWithCustomDelimiter \"\${PATH_DELIMITER}\" \"\$@\"
} }
") ["defNest"]; ") ["defNest"];
defNest = noDepEntry (" defNest = noDepEntry ("
nestingLevel=0 nestingLevel=0
startNest() { startNest() {
nestingLevel=\$((\$nestingLevel + 1)) nestingLevel=\$((\$nestingLevel + 1))
echo -en \"\\e[\$1p\" echo -en \"\\e[\$1p\"
} }
stopNest() { stopNest() {
nestingLevel=\$((\$nestingLevel - 1)) nestingLevel=\$((\$nestingLevel - 1))
echo -en \"\\e[q\" echo -en \"\\e[q\"
} }
header() { header() {
startNest \"\$2\" startNest \"\$2\"
echo \"\$1\" echo \"\$1\"
} }
# Make sure that even when we exit abnormally, the original nesting # Make sure that even when we exit abnormally, the original nesting
# level is properly restored. # level is properly restored.
closeNest() { closeNest() {
while test \$nestingLevel -gt 0; do while test \$nestingLevel -gt 0; do
stopNest stopNest
done done
} }
trap \"closeNest\" EXIT trap \"closeNest\" EXIT
"); ");
minInit = FullDepEntry (" minInit = FullDepEntry ("
set -e set -e
NIX_GCC=${stdenv.gcc} NIX_GCC=${stdenv.gcc}
export SHELL=${stdenv.shell} export SHELL=${stdenv.shell}
PATH_DELIMITER=':' PATH_DELIMITER=':'
" + (if ((stdenv ? preHook) && (stdenv.preHook != null) && " + (if ((stdenv ? preHook) && (stdenv.preHook != null) &&
((toString stdenv.preHook) != "")) then ((toString stdenv.preHook) != "")) then
" "
param1=${stdenv.param1} param1=${stdenv.param1}
param2=${stdenv.param2} param2=${stdenv.param2}
param3=${stdenv.param3} param3=${stdenv.param3}
param4=${stdenv.param4} param4=${stdenv.param4}
param5=${stdenv.param5} param5=${stdenv.param5}
source ${stdenv.preHook} source ${stdenv.preHook}
" + " +
" "
# Set up the initial path. # Set up the initial path.
PATH= PATH=
for i in \$NIX_GCC ${toString stdenv.initialPath}; do for i in \$NIX_GCC ${toString stdenv.initialPath}; do
PATH=\$PATH\${PATH:+\"\${PATH_DELIMITER}\"}\$i/bin PATH=\$PATH\${PATH:+\"\${PATH_DELIMITER}\"}\$i/bin
done done
export TZ=UTC export TZ=UTC
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.
findInputs() findInputs()
{ {
local pkg=\$1 local pkg=\$1
case \$pkgs in case \$pkgs in
*\\ \$pkg\\ *) *\\ \$pkg\\ *)
return 0 return 0
;; ;;
esac esac
pkgs=\"\$pkgs \$pkg \" pkgs=\"\$pkgs \$pkg \"
echo \$pkg echo \$pkg
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
} }
pkgs=\"\" pkgs=\"\"
for i in \$NIX_GCC ${toString buildInputs}; do for i in \$NIX_GCC ${toString buildInputs}; do
findInputs \$i findInputs \$i
done done
# Set the relevant environment variables to point to the build inputs # Set the relevant environment variables to point to the build inputs
# found above. # found above.
addToEnv() addToEnv()
{ {
local pkg=\$1 local pkg=\$1
"+ "+
(if !((args ? ignoreFailedInputs) && (args.ignoreFailedInputs == 1)) then " (if !((args ? ignoreFailedInputs) && (args.ignoreFailedInputs == 1)) then "
if [ -e \$1/nix-support/failed ]; then if [ -e \$1/nix-support/failed ]; then
echo \"failed input \$1\" >&2 echo \"failed input \$1\" >&2
fail fail
fi fi
" else "") " else "")
+(if addSbinPath then " +(if addSbinPath then "
if test -d \$1/sbin; then if test -d \$1/sbin; then
export _PATH=\$_PATH\${_PATH:+\"\${PATH_DELIMITER}\"}\$1/sbin export _PATH=\$_PATH\${_PATH:+\"\${PATH_DELIMITER}\"}\$1/sbin
fi fi
" else "") " else "")
+" +"
if test -d \$1/bin; then if test -d \$1/bin; then
export _PATH=\$_PATH\${_PATH:+\"\${PATH_DELIMITER}\"}\$1/bin export _PATH=\$_PATH\${_PATH:+\"\${PATH_DELIMITER}\"}\$1/bin
fi fi
for i in \"\${envHooks[@]}\"; do for i in \"\${envHooks[@]}\"; do
\$i \$pkg \$i \$pkg
done done
} }
for i in \$pkgs; do for i in \$pkgs; do
addToEnv \$i addToEnv \$i
done done
# Add the output as an rpath. # Add the output as an rpath.
if test \"\$NIX_NO_SELF_RPATH\" != \"1\"; then if test \"\$NIX_NO_SELF_RPATH\" != \"1\"; then
export NIX_LDFLAGS=\"-rpath \$out/lib \$NIX_LDFLAGS\" export NIX_LDFLAGS=\"-rpath \$out/lib \$NIX_LDFLAGS\"
fi fi
PATH=\$_PATH\${_PATH:+\"\${PATH_DELIMITER}\"}\$PATH PATH=\$_PATH\${_PATH:+\"\${PATH_DELIMITER}\"}\$PATH
") ["minInit"]; ") ["minInit"];
defEnsureDir = FullDepEntry (" defEnsureDir = FullDepEntry ("
# Ensure that the given directories exists. # Ensure that the given directories exists.
ensureDir() { ensureDir() {
local dir local dir
for dir in \"\$@\"; do for dir in \"\$@\"; do
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}'
cd \"\$(tar tf '${s}' | head -1 | sed -e 's@/.*@@' )\" cd \"\$(tar tf '${s}' | head -1 | sed -e 's@/.*@@' )\"
" else if (archiveType s) == "tgz" then " " else if (archiveType s) == "tgz" then "
tar xvzf '${s}' tar xvzf '${s}'
cd \"\$(tar tzf '${s}' | head -1 | sed -e 's@/.*@@' )\" cd \"\$(tar tzf '${s}' | head -1 | sed -e 's@/.*@@' )\"
" else if (archiveType s) == "tbz2" then " " else if (archiveType s) == "tbz2" then "
tar xvjf '${s}' tar xvjf '${s}'
cd \"\$(tar tjf '${s}' | head -1 | sed -e 's@/.*@@' )\" cd \"\$(tar tjf '${s}' | head -1 | sed -e 's@/.*@@' )\"
" else if (archiveType s) == "tar.lzma" then " " else if (archiveType s) == "tar.lzma" then "
unlzma -d -c <'${s}' | tar xv unlzma -d -c <'${s}' | tar xv
cd \"\$(unlzma -d -c <'${s}' | tar t | head -1 | sed -e 's@/.*@@' )\" cd \"\$(unlzma -d -c <'${s}' | tar t | head -1 | sed -e 's@/.*@@' )\"
" else if (archiveType s) == "zip" then " " else if (archiveType s) == "zip" then "
unzip '${s}' unzip '${s}'
cd \"$( unzip -lqq '${s}' | tail -1 | cd \"$( unzip -lqq '${s}' | tail -1 |
sed -e 's@^\\(\\s\\+[-0-9:]\\+\\)\\{3,3\\}\\s\\+\\([^/]\\+\\)/.*@\\2@' )\" sed -e 's@^\\(\\s\\+[-0-9:]\\+\\)\\{3,3\\}\\s\\+\\([^/]\\+\\)/.*@\\2@' )\"
" else if (archiveType s) == "cvs-dir" then " " else if (archiveType s) == "cvs-dir" then "
cp -r '${s}' . cp -r '${s}' .
cd \$(basename ${s}) cd \$(basename ${s})
chmod u+rwX -R . chmod u+rwX -R .
" else if (archiveType s) == "dir" then " " else if (archiveType s) == "dir" then "
cp -r '${s}' . cp -r '${s}' .
cd \$(basename ${s}) cd \$(basename ${s})
chmod u+rwX -R . chmod u+rwX -R .
" else if (archiveType s) == "narbz2" then " " else if (archiveType s) == "narbz2" then "
bzip2 <${s} | nix-store --restore \$PWD/\$(basename ${s} .nar.bz2) bzip2 <${s} | nix-store --restore \$PWD/\$(basename ${s} .nar.bz2)
cd \$(basename ${s} .nar.bz2) cd \$(basename ${s} .nar.bz2)
" else if (archiveType s) == "plain-bz2" then " " else if (archiveType s) == "plain-bz2" then "
mkdir \$PWD/\$(basename ${s} .bz2) mkdir \$PWD/\$(basename ${s} .bz2)
NAME=\$(basename ${s} .bz2) NAME=\$(basename ${s} .bz2)
bzip2 -d <${s} > \$PWD/\$(basename ${s} .bz2)/\${NAME#*-} bzip2 -d <${s} > \$PWD/\$(basename ${s} .bz2)/\${NAME#*-}
cd \$(basename ${s} .bz2) cd \$(basename ${s} .bz2)
" else (abort "unknown archive type : ${s}"))+ " else (abort "unknown archive type : ${s}"))+
# goSrcDir is typically something like "cd mysubdir" .. but can be anything else # goSrcDir is typically something like "cd mysubdir" .. but can be anything else
(if args ? goSrcDir then args.goSrcDir else "") (if args ? goSrcDir then args.goSrcDir else "")
) ["minInit"]; ) ["minInit"];
configureCommand = getAttr ["configureCommand"] "./configure" args; configureCommand = getAttr ["configureCommand"] "./configure" args;
doConfigure = FullDepEntry (" doConfigure = FullDepEntry ("
${configureCommand} --prefix=\"\$prefix\" ${toString configureFlags} ${configureCommand} --prefix=\"\$prefix\" ${toString configureFlags}
") ["minInit" "addInputs" "doUnpack"]; ") ["minInit" "addInputs" "doUnpack"];
doAutotools = FullDepEntry (" doAutotools = FullDepEntry ("
mkdir -p config mkdir -p config
libtoolize --copy --force libtoolize --copy --force
aclocal --force aclocal --force
#Some packages do not need this #Some packages do not need this
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"];
doPythonConfigure = FullDepEntry ('' doPythonConfigure = FullDepEntry (''
pythonVersion=$(toPythonPath "$prefix") pythonVersion=$(toPythonPath "$prefix")
pythonVersion=''${pythonVersion#*/lib/python} pythonVersion=''${pythonVersion#*/lib/python}
pythonVersion=''${pythonVersion%%/site-packages} pythonVersion=''${pythonVersion%%/site-packages}
${if args ? extraPythonConfigureCommand then ${if args ? extraPythonConfigureCommand then
args.extraPythonConfigureCommand args.extraPythonConfigureCommand
else ""} else ""}
python configure.py -b "$prefix/bin" -d "$(toPythonPath "$prefix")" -v "$prefix/share/sip" ${toString configureFlags} python configure.py -b "$prefix/bin" -d "$(toPythonPath "$prefix")" -v "$prefix/share/sip" ${toString configureFlags}
'') ["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\"
for d in ${toString forceShare}; do for d in ${toString forceShare}; do
if [ -d \"\$prefix/\$d\" -a ! -d \"\$prefix/share/\$d\" ]; then if [ -d \"\$prefix/\$d\" -a ! -d \"\$prefix/share/\$d\" ]; then
mv -v \"\$prefix/\$d\" \"\$prefix/share\" mv -v \"\$prefix/\$d\" \"\$prefix/share\"
ln -sv share/\$d \"\$prefix\" ln -sv share/\$d \"\$prefix\"
fi; fi;
done; done;
") ["minInit" "defEnsureDir"]; ") ["minInit" "defEnsureDir"];
doForceCopy = FullDepEntry ('' doForceCopy = FullDepEntry (''
name=$(basename $out) name=$(basename $out)
name=''${name#*-} name=''${name#*-}
ensureDir "$prefix/share/$name" ensureDir "$prefix/share/$name"
for f in ${toString forceCopy}; do for f in ${toString forceCopy}; do
cp -r "$f" "$prefix/share/$name/$f" || true cp -r "$f" "$prefix/share/$name/$f" || true
done; done;
'') ["minInit" "defEnsureDir"]; '') ["minInit" "defEnsureDir"];
doDump = n: noDepEntry "echo Dump number ${n}; set"; doDump = n: noDepEntry "echo Dump number ${n}; set";
patchFlags = if args ? patchFlags then args.patchFlags else "-p1"; patchFlags = if args ? patchFlags then args.patchFlags else "-p1";
patches = getAttr ["patches"] [] args; patches = getAttr ["patches"] [] args;
toPatchCommand = s: "cat ${toString s} | patch ${toString patchFlags}"; toPatchCommand = s: "cat ${toString s} | patch ${toString patchFlags}";
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;
envAdder = envAdderInner ""; envAdder = envAdderInner "";
envAdderList = l: if l==[] then "" else envAdderList = l: if l==[] then "" else
"echo export ${__head l}='\"'\"\\\$${__head l}:${__head (__tail l)}\"'\"';\n" + "echo export ${__head l}='\"'\"\\\$${__head l}:${__head (__tail l)}\"'\"';\n" +
envAdderList (__tail (__tail l)); envAdderList (__tail (__tail l));
wrapEnv = cmd: env: " wrapEnv = cmd: env: "
mv \"${cmd}\" \"${cmd}-orig\"; mv \"${cmd}\" \"${cmd}-orig\";
touch \"${cmd}\"; touch \"${cmd}\";
chmod a+rx \"${cmd}\"; chmod a+rx \"${cmd}\";
(${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"];
makeManyWrappers = wildcard : wrapperFlags : FullDepEntry ('' makeManyWrappers = wildcard : wrapperFlags : FullDepEntry (''
for i in ${wildcard}; do for i in ${wildcard}; do
wrapProgram "$i" ${wrapperFlags} wrapProgram "$i" ${wrapperFlags}
done done
'') ["minInit" "addInputs" "defEnsureDir"]; '') ["minInit" "addInputs" "defEnsureDir"];
wrapBinContentsPython = (makeManyWrappers wrapBinContentsPython = (makeManyWrappers
''$out/bin/*'' ''$out/bin/*''
pythonWrapperArguments pythonWrapperArguments
); );
pythonWrapperArguments = pythonWrapperArguments =
(''--prefix PYTHONPATH : $(toPythonPath $out)'' + (''--prefix PYTHONPATH : $(toPythonPath $out)'' +
''''${PYTHONPATH:+ --prefix PYTHONPATH : $PYTHONPATH}''); ''''${PYTHONPATH:+ --prefix PYTHONPATH : $PYTHONPATH}'');
preservePathWrapperArguments = ''''${PATH:+ --prefix PATH : $PATH }''; preservePathWrapperArguments = ''''${PATH:+ --prefix PATH : $PATH }'';
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);*/
replaceScriptVar = file: name: value: ("sed -e 's`^${name}=.*`${name}='\\''${value}'\\''`' -i ${file}"); replaceScriptVar = file: name: value: ("sed -e 's`^${name}=.*`${name}='\\''${value}'\\''`' -i ${file}");
replaceInScript = file: l: (concatStringsSep "\n" ((pairMap (replaceScriptVar file) l))); replaceInScript = file: l: (concatStringsSep "\n" ((pairMap (replaceScriptVar file) l)));
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 = a : steps : textClosureMapOveridable makeNest a (["defNest"] ++ steps); textClosure = a : steps : textClosureMapOveridable makeNest a (["defNest"] ++ steps);
inherit noDepEntry FullDepEntry PackEntry; inherit noDepEntry FullDepEntry PackEntry;
defList = (getAttr ["defList"] [] args); defList = (getAttr ["defList"] [] args);
getVal = getValue args defList; getVal = getValue args defList;
check = checkFlag args; check = checkFlag args;
reqsList = getAttr ["reqsList"] [] args; reqsList = getAttr ["reqsList"] [] args;
buildInputsNames = filter (x: (null != getVal x)) buildInputsNames = filter (x: (null != getVal x))
(uniqList {inputList = (uniqList {inputList =
(concatLists (map (concatLists (map
(x:(if (x==[]) then [] else builtins.tail x)) (x:(if (x==[]) then [] else builtins.tail x))
reqsList));}); reqsList));});
configFlags = getAttr ["configFlags"] [] args; configFlags = getAttr ["configFlags"] [] args;
buildFlags = getAttr ["buildFlags"] [] args; buildFlags = getAttr ["buildFlags"] [] args;
nameSuffixes = getAttr ["nameSuffixes"] [] args; nameSuffixes = getAttr ["nameSuffixes"] [] args;
autoBuildInputs = assert (checkReqs args defList reqsList); autoBuildInputs = assert (checkReqs args defList reqsList);
filter (x: x!=null) (map getVal buildInputsNames); filter (x: x!=null) (map getVal buildInputsNames);
autoConfigureFlags = condConcat "" configFlags check; autoConfigureFlags = condConcat "" configFlags check;
autoMakeFlags = condConcat "" buildFlags check; autoMakeFlags = condConcat "" buildFlags check;
useConfig = getAttr ["useConfig"] false args; useConfig = getAttr ["useConfig"] false args;
buildInputs = buildInputs =
lib.closePropagation ((if useConfig then lib.closePropagation ((if useConfig then
autoBuildInputs else autoBuildInputs else
getAttr ["buildInputs"] [] args)++ getAttr ["buildInputs"] [] args)++
(getAttr ["propagatedBuildInputs"] [] args)); (getAttr ["propagatedBuildInputs"] [] args));
configureFlags = if useConfig then autoConfigureFlags else configureFlags = if useConfig then autoConfigureFlags else
getAttr ["configureFlags"] "" args; getAttr ["configureFlags"] "" args;
makeFlags = if useConfig then autoMakeFlags else getAttr ["makeFlags"] "" args; makeFlags = if useConfig then autoMakeFlags else getAttr ["makeFlags"] "" args;
inherit lib; inherit 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!
@ -439,62 +439,68 @@ args: with args; with stringsWithDeps; with lib;
GHC_PACKAGE_PATH=\$PACKAGE_DB ./register.sh GHC_PACKAGE_PATH=\$PACKAGE_DB ./register.sh
" ["defCreateEmptyPackageDatabaseAndSetupHook" "defCabalSetupCmd"]; " ["defCreateEmptyPackageDatabaseAndSetupHook" "defCabalSetupCmd"];
realPhaseNames = args.phaseNames ++ realPhaseNames = args.phaseNames ++
["doForceShare" "doPropagate" "doForceCopy"] ["doForceShare" "doPropagate" "doForceCopy"]
++ ++
(optional (getAttr ["alwaysFail"] false args) "doFail") (optional (getAttr ["doCheck"] false args) "doMakeCheck")
; ++
(optional (getAttr ["alwaysFail"] false args) "doFail")
;
doFail = noDepEntry " doFail = noDepEntry "
echo 'Failing to keep builddir (and to invalidate result).' echo 'Failing to keep builddir (and to invalidate result).'
a() { return 127; } ; a ; a() { return 127; } ; a ;
"; ";
extraDerivationAttrs = lib.getAttr ["extraDerivationAttrs"] {} args; doMakeCheck = FullDepEntry (''
make check
'') ["minInit"];
builderDefsPackage = bd: func: args: ( extraDerivationAttrs = lib.getAttr ["extraDerivationAttrs"] {} args;
let localDefs = bd (func ((bd null) // args)) args null; in
stdenv.mkDerivation ((rec { builderDefsPackage = bd: func: args: (
inherit (localDefs) name; let localDefs = bd (func ((bd null) // args)) args null; in
builder = writeScript (name + "-builder")
(textClosure localDefs localDefs.realPhaseNames); stdenv.mkDerivation ((rec {
meta = localDefs.meta // {inherit src;}; inherit (localDefs) name;
}) // (if localDefs ? propagatedBuildInputs then { builder = writeScript (name + "-builder")
inherit (localDefs) propagatedBuildInputs; (textClosure localDefs localDefs.realPhaseNames);
} else {}) // extraDerivationAttrs) meta = localDefs.meta // {inherit src;};
); }) // (if localDefs ? propagatedBuildInputs then {
inherit (localDefs) propagatedBuildInputs;
} else {}) // extraDerivationAttrs)
);
generateFontsFromSFD = noDepEntry('' generateFontsFromSFD = noDepEntry(''
for i in *.sfd; do for i in *.sfd; do
${args.fontforge}/bin/fontforge -c \ ${args.fontforge}/bin/fontforge -c \
'Open($1); 'Open($1);
${optionalString (args ? extraFontForgeCommands) args.extraFontForgeCommands ${optionalString (args ? extraFontForgeCommands) args.extraFontForgeCommands
}Reencode("unicode"); }Reencode("unicode");
${optionalString (getAttr ["createTTF"] true args) ''Generate($1:r + ".ttf");''} ${optionalString (getAttr ["createTTF"] true args) ''Generate($1:r + ".ttf");''}
${optionalString (getAttr ["createOTF"] true args) ''Generate($1:r + ".otf");''} ${optionalString (getAttr ["createOTF"] true args) ''Generate($1:r + ".otf");''}
Reencode("TeX-Base-Encoding"); Reencode("TeX-Base-Encoding");
${optionalString (getAttr ["createAFM"] true args) ''Generate($1:r + ".afm");''} ${optionalString (getAttr ["createAFM"] true args) ''Generate($1:r + ".afm");''}
${optionalString (getAttr ["createPFM"] true args) ''Generate($1:r + ".pfm");''} ${optionalString (getAttr ["createPFM"] true args) ''Generate($1:r + ".pfm");''}
${optionalString (getAttr ["createPFB"] true args) ''Generate($1:r + ".pfb");''} ${optionalString (getAttr ["createPFB"] true args) ''Generate($1:r + ".pfb");''}
${optionalString (getAttr ["createMAP"] true args) ''Generate($1:r + ".map");''} ${optionalString (getAttr ["createMAP"] true args) ''Generate($1:r + ".map");''}
${optionalString (getAttr ["createENC"] true args) ''Generate($1:r + ".enc");''} ${optionalString (getAttr ["createENC"] true args) ''Generate($1:r + ".enc");''}
' $i; ' $i;
done done
''); '');
installFonts = FullDepEntry ('' installFonts = FullDepEntry (''
ensureDir $out/share/fonts/truetype/public/${args.name} ensureDir $out/share/fonts/truetype/public/${args.name}
ensureDir $out/share/fonts/opentype/public/${args.name} ensureDir $out/share/fonts/opentype/public/${args.name}
ensureDir $out/share/fonts/type1/public/${args.name} ensureDir $out/share/fonts/type1/public/${args.name}
ensureDir $out/share/texmf/fonts/enc/${args.name} ensureDir $out/share/texmf/fonts/enc/${args.name}
ensureDir $out/share/texmf/fonts/map/${args.name} ensureDir $out/share/texmf/fonts/map/${args.name}
cp *.ttf $out/share/fonts/truetype/public/${args.name} || echo No TrueType fonts cp *.ttf $out/share/fonts/truetype/public/${args.name} || echo No TrueType fonts
cp *.otf $out/share/fonts/opentype/public/${args.name} || echo No OpenType fonts cp *.otf $out/share/fonts/opentype/public/${args.name} || echo No OpenType fonts
cp *.{pfm,afm,pfb} $out/share/fonts/type1/public/${args.name} || echo No Type1 Fonts cp *.{pfm,afm,pfb} $out/share/fonts/type1/public/${args.name} || echo No Type1 Fonts
cp *.enc $out/share/texmf/fonts/enc/${args.name} || echo No fontenc data cp *.enc $out/share/texmf/fonts/enc/${args.name} || echo No fontenc data
cp *.map $out/share/texmf/fonts/map/${args.name} || echo No fontmap data cp *.map $out/share/texmf/fonts/map/${args.name} || echo No fontmap data
'') ["minInit" "defEnsureDir"]; '') ["minInit" "defEnsureDir"];
simplyShare = shareName: FullDepEntry ('' simplyShare = shareName: FullDepEntry (''