2008-01-22 14:34:23 +00:00
|
|
|
# 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
|
|
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2007-10-29 10:52:04 +00:00
|
|
|
args: with args; with stringsWithDeps; with lib;
|
2007-11-12 16:42:13 +00:00
|
|
|
(rec
|
2007-10-29 10:52:04 +00:00
|
|
|
{
|
|
|
|
inherit writeScript;
|
|
|
|
|
2008-01-04 17:02:12 +00:00
|
|
|
addSbinPath = getAttr ["addSbinPath"] false args;
|
2007-12-01 16:20:23 +00:00
|
|
|
|
2007-10-29 10:52:04 +00:00
|
|
|
forceShare = if args ? forceShare then args.forceShare else ["man" "doc" "info"];
|
|
|
|
|
|
|
|
archiveType = s:
|
|
|
|
(if hasSuffixHack ".tar" s then "tar"
|
|
|
|
else if (hasSuffixHack ".tar.gz" s) || (hasSuffixHack ".tgz" s) then "tgz"
|
|
|
|
else if (hasSuffixHack ".tar.bz2" s) || (hasSuffixHack ".tbz2" s) then "tbz2"
|
2007-11-08 14:34:54 +00:00
|
|
|
else if (hasSuffixHack ".zip" s) || (hasSuffixHack ".ZIP" s) then "zip"
|
2007-12-04 22:06:13 +00:00
|
|
|
else if (hasSuffixHack "-cvs-export" s) then "cvs-dir"
|
2007-12-10 16:56:55 +00:00
|
|
|
else if (hasSuffixHack ".nar.bz2" s) then "narbz2"
|
2007-12-31 08:49:41 +00:00
|
|
|
|
|
|
|
# Last block - for single files!! It should be always after .tar.*
|
|
|
|
else if (hasSuffixHack ".bz2" s) then "plain-bz2"
|
|
|
|
|
2008-01-22 14:34:23 +00:00
|
|
|
else if (hasSuffixHack ".zip" s) || (hasSuffixHack ".ZIP" s) then "zip"
|
2007-10-29 10:52:04 +00:00
|
|
|
else (abort "unknown archive type : ${s}"));
|
|
|
|
|
2007-11-12 16:42:13 +00:00
|
|
|
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
|
|
|
|
}
|
2007-11-08 14:34:54 +00:00
|
|
|
|
2007-11-12 16:42:13 +00:00
|
|
|
addToSearchPath()
|
|
|
|
{
|
|
|
|
addToSearchPathWithCustomDelimiter \"\${PATH_DELIMITER}\" \"\$@\"
|
|
|
|
}
|
2008-01-22 14:34:23 +00:00
|
|
|
") [defNest];
|
2007-11-08 14:34:54 +00:00
|
|
|
|
2007-11-12 16:42:13 +00:00
|
|
|
defNest = noDepEntry ("
|
2007-11-08 14:34:54 +00:00
|
|
|
nestingLevel=0
|
|
|
|
|
|
|
|
startNest() {
|
|
|
|
nestingLevel=\$((\$nestingLevel + 1))
|
|
|
|
echo -en \"\\e[\$1p\"
|
|
|
|
}
|
|
|
|
|
|
|
|
stopNest() {
|
|
|
|
nestingLevel=\$((\$nestingLevel - 1))
|
|
|
|
echo -en \"\\e[q\"
|
|
|
|
}
|
|
|
|
|
|
|
|
header() {
|
|
|
|
startNest \"\$2\"
|
|
|
|
echo \"\$1\"
|
|
|
|
}
|
|
|
|
|
|
|
|
# Make sure that even when we exit abnormally, the original nesting
|
|
|
|
# level is properly restored.
|
|
|
|
closeNest() {
|
|
|
|
while test \$nestingLevel -gt 0; do
|
|
|
|
stopNest
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
trap \"closeNest\" EXIT
|
2007-11-12 16:42:13 +00:00
|
|
|
");
|
|
|
|
|
|
|
|
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}
|
2007-11-08 14:34:54 +00:00
|
|
|
|
2007-11-12 16:42:13 +00:00
|
|
|
export TZ=UTC
|
|
|
|
|
|
|
|
prefix=${if args ? prefix then (toString args.prefix) else "\$out"}
|
2007-11-08 14:34:54 +00:00
|
|
|
|
2007-10-29 10:52:04 +00:00
|
|
|
"
|
2008-01-22 14:34:23 +00:00
|
|
|
else "")) [defNest defAddToSearchPath];
|
2007-11-08 14:34:54 +00:00
|
|
|
|
2007-10-29 10:52:04 +00:00
|
|
|
addInputs = FullDepEntry ("
|
|
|
|
# Recursively find all build inputs.
|
|
|
|
findInputs()
|
|
|
|
{
|
|
|
|
local pkg=\$1
|
|
|
|
|
|
|
|
case \$pkgs in
|
|
|
|
*\\ \$pkg\\ *)
|
|
|
|
return 0
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
pkgs=\"\$pkgs \$pkg \"
|
|
|
|
|
|
|
|
echo \$pkg
|
|
|
|
if test -f \$pkg/nix-support/setup-hook; then
|
|
|
|
source \$pkg/nix-support/setup-hook
|
|
|
|
fi
|
2008-01-22 14:34:23 +00:00
|
|
|
|
|
|
|
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
|
2007-10-29 10:52:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
pkgs=\"\"
|
2007-12-01 16:20:23 +00:00
|
|
|
for i in \$NIX_GCC ${toString buildInputs}; do
|
2007-10-29 10:52:04 +00:00
|
|
|
findInputs \$i
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
|
|
# Set the relevant environment variables to point to the build inputs
|
|
|
|
# found above.
|
|
|
|
addToEnv()
|
|
|
|
{
|
|
|
|
local pkg=\$1
|
|
|
|
"+
|
|
|
|
(if !((args ? ignoreFailedInputs) && (args.ignoreFailedInputs == 1)) then "
|
|
|
|
if [ -e \$1/nix-support/failed ]; then
|
|
|
|
echo \"failed input \$1\" >&2
|
|
|
|
fail
|
|
|
|
fi
|
|
|
|
" else "")
|
2008-01-04 17:02:12 +00:00
|
|
|
+(if addSbinPath then "
|
|
|
|
if test -d \$1/sbin; then
|
|
|
|
export _PATH=\$_PATH\${_PATH:+:}\$1/sbin
|
|
|
|
fi
|
|
|
|
" else "")
|
2007-10-29 10:52:04 +00:00
|
|
|
+"
|
|
|
|
if test -d \$1/bin; then
|
|
|
|
export _PATH=\$_PATH\${_PATH:+:}\$1/bin
|
|
|
|
fi
|
|
|
|
|
|
|
|
for i in \"\${envHooks[@]}\"; do
|
|
|
|
\$i \$pkg
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
for i in \$pkgs; do
|
|
|
|
addToEnv \$i
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
|
|
# Add the output as an rpath.
|
|
|
|
if test \"\$NIX_NO_SELF_RPATH\" != \"1\"; then
|
|
|
|
export NIX_LDFLAGS=\"-rpath \$out/lib \$NIX_LDFLAGS\"
|
|
|
|
fi
|
|
|
|
|
|
|
|
PATH=\$_PATH\${_PATH:+:}\$PATH
|
2008-01-22 14:34:23 +00:00
|
|
|
") [minInit];
|
2007-10-29 10:52:04 +00:00
|
|
|
|
|
|
|
defEnsureDir = FullDepEntry ("
|
|
|
|
# Ensure that the given directories exists.
|
|
|
|
ensureDir() {
|
|
|
|
local dir
|
|
|
|
for dir in \"\$@\"; do
|
|
|
|
if ! test -x \"\$dir\"; then mkdir -p \"\$dir\"; fi
|
|
|
|
done
|
|
|
|
}
|
2008-01-22 14:34:23 +00:00
|
|
|
") [minInit];
|
2007-10-29 10:52:04 +00:00
|
|
|
|
2007-11-03 08:19:00 +00:00
|
|
|
toSrcDir = s : FullDepEntry ((if (archiveType s) == "tar" then "
|
2007-11-08 14:34:54 +00:00
|
|
|
tar xvf '${s}'
|
|
|
|
cd \"\$(tar tf '${s}' | head -1 | sed -e 's@/.*@@' )\"
|
2007-10-29 10:52:04 +00:00
|
|
|
" else if (archiveType s) == "tgz" then "
|
2007-11-08 14:34:54 +00:00
|
|
|
tar xvzf '${s}'
|
|
|
|
cd \"\$(tar tzf '${s}' | head -1 | sed -e 's@/.*@@' )\"
|
2007-10-29 10:52:04 +00:00
|
|
|
" else if (archiveType s) == "tbz2" then "
|
2007-11-08 14:34:54 +00:00
|
|
|
tar xvjf '${s}'
|
|
|
|
cd \"\$(tar tjf '${s}' | head -1 | sed -e 's@/.*@@' )\"
|
|
|
|
" else if (archiveType s) == "zip" then "
|
|
|
|
unzip '${s}'
|
|
|
|
cd \"$( unzip -lqq '${s}' | tail -1 |
|
|
|
|
sed -e 's@^\\(\\s\\+[-0-9:]\\+\\)\\{3,3\\}\\s\\+\\([^/]\\+\\)/.*@\\2@' )\"
|
2007-12-04 22:06:13 +00:00
|
|
|
" else if (archiveType s) == "cvs-dir" then "
|
|
|
|
cp -r '${s}' .
|
|
|
|
cd \$(basename ${s})
|
2007-12-06 00:32:21 +00:00
|
|
|
chmod u+rwX -R .
|
2007-12-10 16:56:55 +00:00
|
|
|
" else if (archiveType s) == "narbz2" then "
|
|
|
|
bzip2 <${s} | nix-store --restore \$PWD/\$(basename ${s} .nar.bz2)
|
|
|
|
cd \$(basename ${s} .nar.bz2)
|
2007-12-31 08:49:41 +00:00
|
|
|
" else if (archiveType s) == "plain-bz2" then "
|
|
|
|
mkdir \$PWD/\$(basename ${s} .bz2)
|
|
|
|
NAME=\$(basename ${s} .bz2)
|
|
|
|
bzip2 -d <${s} > \$PWD/\$(basename ${s} .bz2)/\${NAME#*-}
|
|
|
|
cd \$(basename ${s} .bz2)
|
2007-11-03 08:19:00 +00:00
|
|
|
" else (abort "unknown archive type : ${s}"))+
|
|
|
|
(if args ? goSrcDir then args.goSrcDir else "")
|
2008-01-22 14:34:23 +00:00
|
|
|
) [minInit];
|
2007-10-29 10:52:04 +00:00
|
|
|
|
|
|
|
doConfigure = FullDepEntry ("
|
2007-11-22 20:26:00 +00:00
|
|
|
./configure --prefix=\"\$prefix\" ${toString configureFlags}
|
2008-01-22 14:34:23 +00:00
|
|
|
") [minInit addInputs doUnpack];
|
2007-10-29 10:52:04 +00:00
|
|
|
|
2007-11-05 08:32:20 +00:00
|
|
|
doAutotools = FullDepEntry ("
|
|
|
|
mkdir -p config
|
|
|
|
libtoolize --copy --force
|
|
|
|
aclocal --force
|
|
|
|
#Some packages do not need this
|
|
|
|
autoheader || true;
|
|
|
|
automake --add-missing --copy
|
|
|
|
autoconf
|
2008-01-22 14:34:23 +00:00
|
|
|
")[minInit addInputs doUnpack];
|
2007-11-05 08:32:20 +00:00
|
|
|
|
2007-10-29 10:52:04 +00:00
|
|
|
doMake = FullDepEntry ("
|
2007-11-22 20:26:00 +00:00
|
|
|
make ${toString makeFlags}
|
2008-01-22 14:34:23 +00:00
|
|
|
") [minInit addInputs doUnpack];
|
2007-10-29 10:52:04 +00:00
|
|
|
|
|
|
|
doUnpack = toSrcDir (toString src);
|
|
|
|
|
2007-11-05 08:32:20 +00:00
|
|
|
installPythonPackage = FullDepEntry ("
|
|
|
|
python setup.py install --prefix=\"\$prefix\"
|
2008-01-22 14:34:23 +00:00
|
|
|
") [minInit addInputs doUnpack];
|
2007-11-05 08:32:20 +00:00
|
|
|
|
2007-10-29 10:52:04 +00:00
|
|
|
doMakeInstall = FullDepEntry ("
|
|
|
|
make ${toString (getAttr ["makeFlags"] "" args)} "+
|
2008-01-22 14:34:23 +00:00
|
|
|
"${toString (getAttr ["installFlags"] "" args)} install") [doMake];
|
2007-10-29 10:52:04 +00:00
|
|
|
|
|
|
|
doForceShare = FullDepEntry ("
|
2007-11-05 08:32:20 +00:00
|
|
|
ensureDir \"\$prefix/share\"
|
2007-10-29 10:52:04 +00:00
|
|
|
for d in ${toString forceShare}; do
|
2007-11-05 08:32:20 +00:00
|
|
|
if [ -d \"\$prefix/\$d\" -a ! -d \"\$prefix/share/\$d\" ]; then
|
|
|
|
mv -v \"\$prefix/\$d\" \"\$prefix/share\"
|
|
|
|
ln -sv share/\$d \"\$prefix\"
|
2007-10-29 10:52:04 +00:00
|
|
|
fi;
|
|
|
|
done;
|
2008-01-22 14:34:23 +00:00
|
|
|
") [minInit defEnsureDir];
|
2007-10-29 10:52:04 +00:00
|
|
|
|
|
|
|
doDump = n: noDepEntry "echo Dump number ${n}; set";
|
|
|
|
|
2007-11-05 08:32:20 +00:00
|
|
|
patchFlags = if args ? patchFlags then args.patchFlags else "-p1";
|
|
|
|
|
|
|
|
patches = getAttr ["patches"] [] args;
|
|
|
|
|
|
|
|
toPatchCommand = s: "cat ${toString s} | patch ${toString patchFlags}";
|
|
|
|
|
|
|
|
doPatch = FullDepEntry (concatStringsSep ";"
|
|
|
|
(map toPatchCommand patches)
|
2008-01-22 14:34:23 +00:00
|
|
|
) [minInit doUnpack];
|
2007-11-05 08:32:20 +00:00
|
|
|
|
|
|
|
envAdderInner = s: x: if x==null then s else y:
|
|
|
|
a: envAdderInner (s+"echo export ${x}='\"'\"\$${x}:${y}\";'\"'\n") a;
|
|
|
|
|
|
|
|
envAdder = envAdderInner "";
|
|
|
|
|
|
|
|
envAdderList = l: if l==[] then "" else
|
|
|
|
"echo export ${__head l}='\"'\"\\\$${__head l}:${__head (__tail l)}\"'\"';\n" +
|
|
|
|
envAdderList (__tail (__tail l));
|
|
|
|
|
|
|
|
wrapEnv = cmd: env: "
|
|
|
|
mv \"${cmd}\" \"${cmd}-orig\";
|
|
|
|
touch \"${cmd}\";
|
|
|
|
chmod a+rx \"${cmd}\";
|
|
|
|
(${envAdderList env}
|
|
|
|
echo '\"'\"${cmd}-orig\"'\"' '\"'\\\$@'\"' \n) > \"${cmd}\"";
|
|
|
|
|
2008-01-22 14:34:23 +00:00
|
|
|
doWrap = cmd: FullDepEntry (wrapEnv cmd (getAttr ["wrappedEnv"] [] args)) [minInit];
|
2007-11-05 08:32:20 +00:00
|
|
|
|
|
|
|
doPropagate = FullDepEntry ("
|
|
|
|
ensureDir \$out/nix-support
|
|
|
|
echo '${toString (getAttr ["propagatedBuildInputs"] [] args)}' >\$out/nix-support/propagated-build-inputs
|
2008-01-22 14:34:23 +00:00
|
|
|
") [minInit defEnsureDir];
|
2007-11-05 08:32:20 +00:00
|
|
|
|
2007-11-05 09:40:52 +00:00
|
|
|
/*debug = x:(__trace x x);
|
|
|
|
debugX = x:(__trace (__toXML x) x);*/
|
2007-11-05 08:32:20 +00:00
|
|
|
|
|
|
|
replaceScriptVar = file: name: value: ("sed -e 's`^${name}=.*`${name}='\\''${value}'\\''`' -i ${file}");
|
|
|
|
replaceInScript = file: l: (concatStringsSep "\n" ((pairMap (replaceScriptVar file) l)));
|
|
|
|
replaceScripts = l:(concatStringsSep "\n" (pairMap replaceInScript l));
|
|
|
|
doReplaceScripts = FullDepEntry (replaceScripts (getAttr ["shellReplacements"] [] args)) [minInit];
|
2007-11-12 16:42:13 +00:00
|
|
|
makeNest = x:(if x==defNest.text then x else "startNest\n" + x + "\nstopNest\n");
|
2008-01-22 14:34:23 +00:00
|
|
|
textClosure = textClosureMap makeNest;
|
2007-11-08 14:34:54 +00:00
|
|
|
|
|
|
|
inherit noDepEntry FullDepEntry PackEntry;
|
2007-11-22 20:26:00 +00:00
|
|
|
|
|
|
|
defList = (getAttr ["defList"] [] args);
|
|
|
|
getVal = getValue args defList;
|
|
|
|
check = checkFlag args;
|
|
|
|
reqsList = getAttr ["reqsList"] [] args;
|
|
|
|
buildInputsNames = filter (x: (null != getVal x))
|
|
|
|
(uniqList {inputList =
|
|
|
|
(concatLists (map
|
|
|
|
(x:(if (x==[]) then [] else builtins.tail x))
|
|
|
|
reqsList));});
|
|
|
|
configFlags = getAttr ["configFlags"] [] args;
|
|
|
|
buildFlags = getAttr ["buildFlags"] [] args;
|
|
|
|
nameSuffixes = getAttr ["nameSuffixes"] [] args;
|
|
|
|
autoBuildInputs = assert (checkReqs args defList reqsList);
|
|
|
|
filter (x: x!=null) (map getVal buildInputsNames);
|
|
|
|
autoConfigureFlags = condConcat "" configFlags check;
|
|
|
|
autoMakeFlags = condConcat "" buildFlags check;
|
|
|
|
useConfig = getAttr ["useConfig"] false args;
|
2007-12-01 16:20:23 +00:00
|
|
|
buildInputs =
|
|
|
|
lib.closePropagation ((if useConfig then
|
|
|
|
autoBuildInputs else
|
|
|
|
getAttr ["buildInputs"] [] args)++
|
|
|
|
(getAttr ["propagatedBuildInputs"] [] args));
|
2007-11-22 20:26:00 +00:00
|
|
|
configureFlags = if useConfig then autoConfigureFlags else
|
|
|
|
getAttr ["configureFlags"] "" args;
|
|
|
|
makeFlags = if useConfig then autoMakeFlags else getAttr ["makeFlags"] "" args;
|
|
|
|
|
|
|
|
inherit lib;
|
2007-12-31 08:49:41 +00:00
|
|
|
|
|
|
|
surroundWithCommands = x : before : after : {deps=x.deps; text = before + "\n" +
|
|
|
|
x.text + "\n" + after ;};
|
2008-01-22 14:34:23 +00:00
|
|
|
|
|
|
|
# some haskell stuff - untested!
|
|
|
|
# --------------------------------------------------------
|
|
|
|
# creates a setup hook
|
|
|
|
# adding the package database
|
|
|
|
# nix-support/package.conf to GHC_PACKAGE_PATH
|
|
|
|
# if not already contained
|
|
|
|
# using nix-support because user does'nt want to have it in it's
|
|
|
|
# nix-profile I think?
|
|
|
|
defSetupHookRegisteringPackageDatabase = noDepEntry (
|
|
|
|
"\nsetupHookRegisteringPackageDatabase(){" +
|
|
|
|
"\n ensureDir $out/nix-support;" +
|
|
|
|
"\n if test -n \"$1\"; then" +
|
|
|
|
"\n local pkgdb=$1" +
|
|
|
|
"\n else" +
|
|
|
|
"\n local pkgdb=$out/nix-support/package.conf" +
|
|
|
|
"\n fi" +
|
|
|
|
"\n cat >> $out/nix-support/setup-hook << EOF" +
|
|
|
|
"\n " +
|
|
|
|
"\n echo \$GHC_PACKAGE_PATH | grep -l $pkgdb &> /dev/null || \" "+
|
|
|
|
"\n export GHC_PACKAGE_PATH=\$GHC_PACKAGE_PATH\${GHC_PACKAGE_PATH:+$PATH_DELIMITER}$pkgdb;" +
|
|
|
|
"\nEOF" +
|
|
|
|
"\n}");
|
|
|
|
|
|
|
|
# Either rungghc or compile setup.hs
|
|
|
|
# / which one is better ? runghc had some trouble with ghc-6.6.1
|
|
|
|
defineCabalSetupCmd = noDepEntry "
|
|
|
|
CABAL_SETUP=\"runghc setup.hs\"
|
|
|
|
";
|
|
|
|
|
|
|
|
# create an empty package database in which the new library can be registered.
|
|
|
|
defCreateEmptyPackageDatabaseAndSetupHook = FullDepEntry "
|
|
|
|
createEmptyPackageDatabaseAndSetupHook(){
|
|
|
|
ensureDir $out/nix-support;
|
|
|
|
PACKAGE_DB=$out/nix-support/package.conf;
|
|
|
|
echo '[]' > \"$PACKAGE_DB\";
|
|
|
|
setupHookRegisteringPackageDatabase
|
|
|
|
}" [defSetupHookRegisteringPackageDatabase];
|
|
|
|
|
|
|
|
# Cabal does only support --user ($HOME/.ghc/** ) and --global (/nix/store/*-ghc/lib/...)
|
|
|
|
# But we need kind of --custom=my-package-db
|
|
|
|
# by accident cabal does support using multiple databases passed by GHC_PACKAGE_PATH
|
|
|
|
#
|
|
|
|
# Options:
|
|
|
|
# 1) create a local package db containing all dependencies
|
|
|
|
# 2) create a single db file for each package merging them using GHC_PACKAGE_PATH=db1:db2
|
|
|
|
# (no trailing : which would mean add global and user db)
|
|
|
|
# I prefer 2) (Marc Weber) so the most convinient way is
|
|
|
|
# using ./setup copy to install
|
|
|
|
# and ./setup register --gen-script to install to our local database
|
|
|
|
# after replacing /usr/lib etc with our pure $out path
|
|
|
|
defCabalBuild = FullDepEntry
|
|
|
|
(if (args ? subdir) then "cd ${args.subdir}" else "")+ "
|
|
|
|
createEmptyPackageDatabaseAndSetupHook
|
|
|
|
ghc --make setup.hs -o setup
|
|
|
|
\$CABAL_SETUP configure
|
|
|
|
\$CABAL_SETUP build
|
|
|
|
\$CABAL_SETUP copy --dest-dir=\$out
|
|
|
|
\$CABAL_SETUP register --gen-script
|
|
|
|
sed -e 's=/usr/local/lib=\$out=g' \\
|
|
|
|
-i register.sh
|
|
|
|
GHC_PACKAGE_PATH=\$PACKAGE_DB ./register.sh
|
|
|
|
" [defCreateEmptyPackageDatabaseAndSetupHook defineCabalSetupCmd];
|
|
|
|
|
2007-11-12 16:42:13 +00:00
|
|
|
}) // args
|