2007-10-29 10:52:04 +00:00
|
|
|
args: with args; with stringsWithDeps; with lib;
|
2009-05-24 11:57:46 +01:00
|
|
|
let inherit (builtins) head tail trace; in
|
2007-11-12 16:42:13 +00:00
|
|
|
(rec
|
2007-10-29 10:52:04 +00:00
|
|
|
{
|
2008-07-17 14:39:58 +01:00
|
|
|
inherit writeScript;
|
|
|
|
|
2009-05-24 11:57:41 +01:00
|
|
|
src = attrByPath ["src"] "" args;
|
2008-07-17 14:39:58 +01:00
|
|
|
|
2009-05-24 11:57:41 +01:00
|
|
|
addSbinPath = attrByPath ["addSbinPath"] false args;
|
2008-07-17 14:39:58 +01:00
|
|
|
|
|
|
|
forceShare = if args ? forceShare then args.forceShare else ["man" "doc" "info"];
|
|
|
|
forceCopy = ["COPYING" "LICENSE" "DISTRIBUTION" "LEGAL"
|
2008-12-14 14:54:47 +00:00
|
|
|
"README" "AUTHORS" "ChangeLog" "CHANGES" "LICENCE" "COPYRIGHT"] ++
|
2009-05-24 11:57:41 +01:00
|
|
|
(optional (attrByPath ["forceCopyDoc"] true args) "doc");
|
2008-07-17 14:39:58 +01:00
|
|
|
|
2009-02-09 16:51:03 +00:00
|
|
|
hasSuffixHack = a: b: hasSuffix (a+(substring 0 0 b)) ((substring 0 0 a)+b);
|
|
|
|
|
2008-07-17 14:39:58 +01:00
|
|
|
archiveType = s:
|
|
|
|
(if hasSuffixHack ".tar" s then "tar"
|
|
|
|
else if (hasSuffixHack ".tar.gz" s) || (hasSuffixHack ".tgz" s) then "tgz"
|
2009-03-25 16:06:00 +00:00
|
|
|
else if (hasSuffixHack ".tar.bz2" s) || (hasSuffixHack ".tbz2" s) ||
|
|
|
|
(hasSuffixHack ".tbz" s) then "tbz2"
|
2012-12-28 18:54:15 +00:00
|
|
|
else if hasSuffixHack ".tar.Z" s then "tZ"
|
|
|
|
else if hasSuffixHack ".tar.lzma" s then "tar.lzma"
|
|
|
|
else if hasSuffixHack ".tar.xz" s then "tar.xz"
|
2008-07-17 14:39:58 +01:00
|
|
|
else if (hasSuffixHack ".zip" s) || (hasSuffixHack ".ZIP" s) then "zip"
|
2012-12-28 18:54:15 +00:00
|
|
|
else if hasSuffixHack "-cvs-export" s then "cvs-dir"
|
|
|
|
else if hasSuffixHack "-git-export" s then "git-dir"
|
|
|
|
else if hasSuffixHack ".nar.bz2" s then "narbz2"
|
|
|
|
else if hasSuffixHack ".rpm" s then "rpm"
|
2008-07-17 14:39:58 +01:00
|
|
|
|
|
|
|
# Mostly for manually specified directories..
|
2012-12-28 18:54:15 +00:00
|
|
|
else if hasSuffixHack "/" s then "dir"
|
2008-07-17 14:39:58 +01:00
|
|
|
|
|
|
|
# Last block - for single files!! It should be always after .tar.*
|
2012-12-28 18:54:15 +00:00
|
|
|
else if hasSuffixHack ".bz2" s then "plain-bz2"
|
|
|
|
else if hasSuffixHack ".gz" s then "plain-gz"
|
2008-07-17 14:39:58 +01:00
|
|
|
|
2010-08-17 17:51:12 +01:00
|
|
|
# For bootstrap calls
|
|
|
|
else if (s ==("" + (substring 0 0 s))) then "empty"
|
|
|
|
|
2008-07-17 14:39:58 +01:00
|
|
|
else (abort "unknown archive type : ${s}"));
|
|
|
|
|
2009-09-10 17:57:29 +01:00
|
|
|
# changing this ? see [1]
|
2009-05-20 00:25:58 +01:00
|
|
|
defAddToSearchPath = fullDepEntry ("
|
2008-07-17 14:39:58 +01:00
|
|
|
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"];
|
|
|
|
|
2009-09-10 17:57:29 +01:00
|
|
|
# changing this ? see [1]
|
2008-07-17 14:39:58 +01:00
|
|
|
defNest = noDepEntry ("
|
|
|
|
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
|
|
|
|
");
|
|
|
|
|
2009-09-10 17:57:29 +01:00
|
|
|
|
|
|
|
# changing this ? see [1]
|
2009-05-20 00:25:58 +01:00
|
|
|
minInit = fullDepEntry ("
|
2012-01-20 15:10:56 +00:00
|
|
|
${stdenv.preHook}
|
|
|
|
|
2008-07-17 14:39:58 +01:00
|
|
|
set -e
|
2014-12-17 18:11:30 +00:00
|
|
|
NIX_CC=${stdenv.cc}
|
2008-07-17 14:39:58 +01:00
|
|
|
export SHELL=${stdenv.shell}
|
|
|
|
PATH_DELIMITER=':'
|
2012-01-20 15:10:56 +00:00
|
|
|
|
2008-07-17 14:39:58 +01:00
|
|
|
# Set up the initial path.
|
|
|
|
PATH=
|
2014-12-17 18:11:30 +00:00
|
|
|
for i in \$NIX_CC ${toString stdenv.initialPath}; do
|
2008-07-17 14:39:58 +01:00
|
|
|
PATH=\$PATH\${PATH:+\"\${PATH_DELIMITER}\"}\$i/bin
|
|
|
|
done
|
|
|
|
|
|
|
|
export TZ=UTC
|
|
|
|
|
|
|
|
prefix=${if args ? prefix then (toString args.prefix) else "\$out"}
|
|
|
|
|
2012-01-20 15:10:56 +00:00
|
|
|
") ["defNest" "defAddToSearchPath"];
|
2008-07-17 14:39:58 +01:00
|
|
|
|
2009-09-10 17:57:29 +01:00
|
|
|
# if you change this rewrite using '' instead of "" to get rid of indentation in builder scripts
|
2009-05-20 00:25:58 +01:00
|
|
|
addInputs = fullDepEntry ("
|
2008-07-17 14:39:58 +01:00
|
|
|
# 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
|
|
|
|
}
|
|
|
|
|
|
|
|
pkgs=\"\"
|
2014-12-17 18:11:30 +00:00
|
|
|
for i in \$NIX_CC ${toString realBuildInputs}; do
|
2008-07-17 14:39:58 +01: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 "")
|
|
|
|
+(if addSbinPath then "
|
|
|
|
if test -d \$1/sbin; then
|
|
|
|
export _PATH=\$_PATH\${_PATH:+\"\${PATH_DELIMITER}\"}\$1/sbin
|
|
|
|
fi
|
|
|
|
" else "")
|
|
|
|
+"
|
|
|
|
if test -d \$1/bin; then
|
|
|
|
export _PATH=\$_PATH\${_PATH:+\"\${PATH_DELIMITER}\"}\$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_DELIMITER}\"}\$PATH
|
|
|
|
") ["minInit"];
|
|
|
|
|
2009-09-10 17:57:29 +01:00
|
|
|
# changing this ? see [1]
|
2009-05-20 00:25:58 +01:00
|
|
|
defEnsureDir = fullDepEntry ("
|
2008-07-17 14:39:58 +01:00
|
|
|
# Ensure that the given directories exists.
|
|
|
|
ensureDir() {
|
|
|
|
local dir
|
|
|
|
for dir in \"\$@\"; do
|
|
|
|
if ! test -x \"\$dir\"; then mkdir -p \"\$dir\"; fi
|
|
|
|
done
|
|
|
|
}
|
|
|
|
") ["minInit"];
|
|
|
|
|
2009-09-10 17:57:29 +01:00
|
|
|
# changing this ? see [1]
|
2009-05-20 00:25:58 +01:00
|
|
|
toSrcDir = s : fullDepEntry ((if (archiveType s) == "tar" then "
|
2008-07-17 14:39:58 +01:00
|
|
|
tar xvf '${s}'
|
|
|
|
cd \"\$(tar tf '${s}' | head -1 | sed -e 's@/.*@@' )\"
|
|
|
|
" else if (archiveType s) == "tgz" then "
|
|
|
|
tar xvzf '${s}'
|
|
|
|
cd \"\$(tar tzf '${s}' | head -1 | sed -e 's@/.*@@' )\"
|
|
|
|
" else if (archiveType s) == "tbz2" then "
|
|
|
|
tar xvjf '${s}'
|
|
|
|
cd \"\$(tar tjf '${s}' | head -1 | sed -e 's@/.*@@' )\"
|
2009-05-10 10:13:25 +01:00
|
|
|
" else if (archiveType s) == "tZ" then "
|
|
|
|
uncompress < '${s}' | tar x
|
|
|
|
cd \"\$(uncompress < '${s}' | tar t | head -1 | sed -e 's@/.*@@' )\"
|
2008-07-17 14:39:58 +01:00
|
|
|
" else if (archiveType s) == "tar.lzma" then "
|
|
|
|
unlzma -d -c <'${s}' | tar xv
|
|
|
|
cd \"\$(unlzma -d -c <'${s}' | tar t | head -1 | sed -e 's@/.*@@' )\"
|
2009-10-17 06:26:52 +01:00
|
|
|
" else if (archiveType s) == "tar.xz" then "
|
|
|
|
xz -d -c <'${s}' | tar xv
|
|
|
|
cd \"\$(xz -d -c <'${s}' | tar t | head -1 | sed -e 's@/.*@@' )\"
|
2008-07-17 14:39:58 +01:00
|
|
|
" else if (archiveType s) == "zip" then "
|
|
|
|
unzip '${s}'
|
|
|
|
cd \"$( unzip -lqq '${s}' | tail -1 |
|
|
|
|
sed -e 's@^\\(\\s\\+[-0-9:]\\+\\)\\{3,3\\}\\s\\+\\([^/]\\+\\)/.*@\\2@' )\"
|
|
|
|
" else if (archiveType s) == "cvs-dir" then "
|
|
|
|
cp -r '${s}' .
|
|
|
|
cd \$(basename ${s})
|
2011-12-11 19:39:16 +00:00
|
|
|
chmod u+rwX -R .
|
|
|
|
" else if (archiveType s) == "git-dir" then "
|
|
|
|
cp -r '${s}' .
|
|
|
|
cd \$(basename ${s})
|
2008-07-17 14:39:58 +01:00
|
|
|
chmod u+rwX -R .
|
|
|
|
" else if (archiveType s) == "dir" then "
|
|
|
|
cp -r '${s}' .
|
|
|
|
cd \$(basename ${s})
|
|
|
|
chmod u+rwX -R .
|
|
|
|
" else if (archiveType s) == "narbz2" then "
|
|
|
|
bzip2 <${s} | nix-store --restore \$PWD/\$(basename ${s} .nar.bz2)
|
|
|
|
cd \$(basename ${s} .nar.bz2)
|
2011-05-28 16:36:56 +01:00
|
|
|
" else if (archiveType s) == "rpm" then ''
|
|
|
|
rpm2cpio ${s} > ${s}.cpio
|
|
|
|
cpio -iv < ${s}.cpio
|
|
|
|
test -f *.tar.* && tar -xvf *.tar.*
|
|
|
|
test -d */ && cd */
|
|
|
|
'' else if (archiveType s) == "plain-bz2" then "
|
2008-07-17 14:39:58 +01:00
|
|
|
mkdir \$PWD/\$(basename ${s} .bz2)
|
|
|
|
NAME=\$(basename ${s} .bz2)
|
|
|
|
bzip2 -d <${s} > \$PWD/\$(basename ${s} .bz2)/\${NAME#*-}
|
|
|
|
cd \$(basename ${s} .bz2)
|
2009-05-10 10:13:25 +01:00
|
|
|
" else if (archiveType s) == "plain-gz" then "
|
|
|
|
mkdir \$PWD/\$(basename ${s} .gz)
|
|
|
|
NAME=\$(basename ${s} .gz)
|
|
|
|
gzip -d <${s} > \$PWD/\$(basename ${s} .gz)/\${NAME#*-}
|
|
|
|
cd \$(basename ${s} .gz)
|
2010-08-17 17:51:12 +01:00
|
|
|
" else if (archiveType s) == "empty" then "
|
|
|
|
echo No source to unpack - doing nothing ..
|
2008-07-17 14:39:58 +01:00
|
|
|
" else (abort "unknown archive type : ${s}"))+
|
2008-01-29 13:26:18 +00:00
|
|
|
# goSrcDir is typically something like "cd mysubdir" .. but can be anything else
|
2008-07-17 14:39:58 +01:00
|
|
|
(if args ? goSrcDir then args.goSrcDir else "")
|
|
|
|
) ["minInit"];
|
|
|
|
|
2009-05-24 11:57:41 +01:00
|
|
|
configureCommand = attrByPath ["configureCommand"] "./configure" args;
|
2008-07-17 14:39:58 +01:00
|
|
|
|
2009-09-10 17:57:29 +01:00
|
|
|
# changing this ? see [1]
|
2009-05-20 00:25:58 +01:00
|
|
|
doConfigure = fullDepEntry ("
|
2008-07-17 14:39:58 +01:00
|
|
|
${configureCommand} --prefix=\"\$prefix\" ${toString configureFlags}
|
|
|
|
") ["minInit" "addInputs" "doUnpack"];
|
|
|
|
|
2009-09-10 17:57:29 +01:00
|
|
|
# changing this ? see [1]
|
2009-05-20 00:25:58 +01:00
|
|
|
doIntltool = fullDepEntry ("
|
2008-10-26 11:58:42 +00:00
|
|
|
mkdir -p config
|
|
|
|
intltoolize --copy --force
|
|
|
|
") ["minInit" "addInputs" "doUnpack"];
|
|
|
|
|
2009-09-10 17:57:29 +01:00
|
|
|
# changing this ? see [1]
|
2009-05-20 00:25:58 +01:00
|
|
|
doAutotools = fullDepEntry ("
|
2008-07-17 14:39:58 +01:00
|
|
|
mkdir -p config
|
|
|
|
libtoolize --copy --force
|
|
|
|
aclocal --force
|
|
|
|
#Some packages do not need this
|
|
|
|
autoheader || true;
|
|
|
|
automake --add-missing --copy
|
|
|
|
autoconf
|
|
|
|
")["minInit" "addInputs" "doUnpack"];
|
|
|
|
|
2010-11-16 07:38:33 +00:00
|
|
|
# changing this ? see [1]
|
|
|
|
doAutogen = fullDepEntry (''
|
|
|
|
./autogen.sh
|
|
|
|
'')["minInit" "addInputs" "doUnpack"];
|
|
|
|
|
2009-09-10 17:57:29 +01:00
|
|
|
# changing this ? see [1]
|
2009-05-20 00:25:58 +01:00
|
|
|
doMake = fullDepEntry ("
|
2008-07-17 14:39:58 +01:00
|
|
|
make ${toString makeFlags}
|
|
|
|
") ["minInit" "addInputs" "doUnpack"];
|
|
|
|
|
|
|
|
doUnpack = toSrcDir (toString src);
|
|
|
|
|
2009-09-10 17:57:29 +01:00
|
|
|
# changing this ? see [1]
|
2009-05-20 00:25:58 +01:00
|
|
|
installPythonPackage = fullDepEntry ("
|
2008-07-17 14:39:58 +01:00
|
|
|
python setup.py install --prefix=\"\$prefix\"
|
|
|
|
") ["minInit" "addInputs" "doUnpack"];
|
|
|
|
|
2009-05-20 00:25:58 +01:00
|
|
|
doPythonConfigure = fullDepEntry (''
|
2008-07-17 14:39:58 +01:00
|
|
|
pythonVersion=$(toPythonPath "$prefix")
|
|
|
|
pythonVersion=''${pythonVersion#*/lib/python}
|
|
|
|
pythonVersion=''${pythonVersion%%/site-packages}
|
|
|
|
${if args ? extraPythonConfigureCommand then
|
|
|
|
args.extraPythonConfigureCommand
|
|
|
|
else ""}
|
|
|
|
python configure.py -b "$prefix/bin" -d "$(toPythonPath "$prefix")" -v "$prefix/share/sip" ${toString configureFlags}
|
|
|
|
'') ["minInit" "addInputs" "doUnpack"];
|
|
|
|
|
2009-09-10 17:57:29 +01:00
|
|
|
# changing this ? see [1]
|
2009-05-20 00:25:58 +01:00
|
|
|
doMakeInstall = fullDepEntry ("
|
2009-05-24 11:57:41 +01:00
|
|
|
make ${toString (attrByPath ["makeFlags"] "" args)} "+
|
|
|
|
"${toString (attrByPath ["installFlags"] "" args)} install") ["doMake"];
|
2008-07-17 14:39:58 +01:00
|
|
|
|
2009-09-10 17:57:29 +01:00
|
|
|
# changing this ? see [1]
|
2009-05-20 00:25:58 +01:00
|
|
|
doForceShare = fullDepEntry ("
|
2012-01-18 20:16:00 +00:00
|
|
|
mkdir -p \"\$prefix/share\"
|
2008-07-17 14:39:58 +01:00
|
|
|
for d in ${toString forceShare}; do
|
|
|
|
if [ -d \"\$prefix/\$d\" -a ! -d \"\$prefix/share/\$d\" ]; then
|
|
|
|
mv -v \"\$prefix/\$d\" \"\$prefix/share\"
|
|
|
|
ln -sv share/\$d \"\$prefix\"
|
|
|
|
fi;
|
|
|
|
done;
|
|
|
|
") ["minInit" "defEnsureDir"];
|
|
|
|
|
2009-05-20 00:25:58 +01:00
|
|
|
doForceCopy = fullDepEntry (''
|
2008-12-14 14:54:47 +00:00
|
|
|
name="$(basename $out)"
|
|
|
|
name="''${name#*-}"
|
2012-01-18 20:16:00 +00:00
|
|
|
mkdir -p "$prefix/share/$name"
|
2008-07-17 14:39:58 +01:00
|
|
|
for f in ${toString forceCopy}; do
|
|
|
|
cp -r "$f" "$prefix/share/$name/$f" || true
|
|
|
|
done;
|
|
|
|
'') ["minInit" "defEnsureDir"];
|
|
|
|
|
|
|
|
doDump = n: noDepEntry "echo Dump number ${n}; set";
|
|
|
|
|
2011-05-31 20:30:10 +01:00
|
|
|
saveEnv = noDepEntry ''export > $TMP/env-vars'';
|
|
|
|
|
2010-02-18 10:29:40 +00:00
|
|
|
doDumpBuildInputs = noDepEntry (''
|
|
|
|
echo "${toString realBuildInputs}"
|
|
|
|
'');
|
|
|
|
|
2008-07-17 14:39:58 +01:00
|
|
|
patchFlags = if args ? patchFlags then args.patchFlags else "-p1";
|
|
|
|
|
2009-05-24 11:57:41 +01:00
|
|
|
patches = attrByPath ["patches"] [] args;
|
2008-07-17 14:39:58 +01:00
|
|
|
|
2008-09-23 01:52:05 +01:00
|
|
|
toPatchCommand = s: "cat ${s} | patch ${toString patchFlags}";
|
2008-07-17 14:39:58 +01:00
|
|
|
|
2009-05-20 00:25:58 +01:00
|
|
|
doPatch = fullDepEntry (concatStringsSep ";"
|
2008-07-17 14:39:58 +01:00
|
|
|
(map toPatchCommand patches)
|
|
|
|
) ["minInit" "doUnpack"];
|
|
|
|
|
|
|
|
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
|
2009-05-24 11:57:46 +01:00
|
|
|
"echo export ${head l}='\"'\"\\\$${head l}:${head (tail l)}\"'\"';\n" +
|
|
|
|
envAdderList (tail (tail l));
|
2008-07-17 14:39:58 +01:00
|
|
|
|
2009-09-10 17:57:29 +01:00
|
|
|
# changing this ? see [1]
|
2008-07-17 14:39:58 +01:00
|
|
|
wrapEnv = cmd: env: "
|
|
|
|
mv \"${cmd}\" \"${cmd}-orig\";
|
|
|
|
touch \"${cmd}\";
|
|
|
|
chmod a+rx \"${cmd}\";
|
|
|
|
(${envAdderList env}
|
|
|
|
echo '\"'\"${cmd}-orig\"'\"' '\"'\\\$@'\"' \n) > \"${cmd}\"";
|
|
|
|
|
2009-05-24 11:57:41 +01:00
|
|
|
doWrap = cmd: fullDepEntry (wrapEnv cmd (attrByPath ["wrappedEnv"] [] args)) ["minInit"];
|
2008-07-17 14:39:58 +01:00
|
|
|
|
2009-05-20 00:25:58 +01:00
|
|
|
makeManyWrappers = wildcard : wrapperFlags : fullDepEntry (''
|
2008-07-17 14:39:58 +01:00
|
|
|
for i in ${wildcard}; do
|
|
|
|
wrapProgram "$i" ${wrapperFlags}
|
|
|
|
done
|
|
|
|
'') ["minInit" "addInputs" "defEnsureDir"];
|
|
|
|
|
|
|
|
wrapBinContentsPython = (makeManyWrappers
|
|
|
|
''$out/bin/*''
|
|
|
|
pythonWrapperArguments
|
|
|
|
);
|
|
|
|
|
|
|
|
pythonWrapperArguments =
|
|
|
|
(''--prefix PYTHONPATH : $(toPythonPath $out)'' +
|
|
|
|
''''${PYTHONPATH:+ --prefix PYTHONPATH : $PYTHONPATH}'');
|
|
|
|
|
|
|
|
preservePathWrapperArguments = ''''${PATH:+ --prefix PATH : $PATH }'';
|
|
|
|
|
2009-05-20 00:25:58 +01:00
|
|
|
doPropagate = fullDepEntry ("
|
2012-01-18 20:16:00 +00:00
|
|
|
mkdir -p \$out/nix-support
|
2009-05-24 11:57:41 +01:00
|
|
|
echo '${toString (attrByPath ["propagatedBuildInputs"] [] args)}' >\$out/nix-support/propagated-build-inputs
|
2008-07-17 14:39:58 +01:00
|
|
|
") ["minInit" "defEnsureDir"];
|
|
|
|
|
2011-04-09 16:50:33 +01:00
|
|
|
cmakeFlags = attrByPath ["cmakeFlags"] [] args;
|
|
|
|
|
2012-12-28 18:54:15 +00:00
|
|
|
cmakeRPathFlag = if attrByPath ["cmakeSkipRpath "] true args then " -DCMAKE_SKIP_BUILD_RPATH=ON " else "";
|
2010-12-22 14:50:13 +00:00
|
|
|
|
2011-06-28 10:45:09 +01:00
|
|
|
cmakeBuildDir = attrByPath ["cmakeBuildDir"] "build" args;
|
|
|
|
|
2010-12-22 14:50:13 +00:00
|
|
|
doCmake = fullDepEntry (''
|
2011-06-28 10:45:09 +01:00
|
|
|
mkdir ${cmakeBuildDir}
|
|
|
|
cd ${cmakeBuildDir}
|
2011-04-09 16:50:33 +01:00
|
|
|
cmake -D CMAKE_INSTALL_PREFIX="$out" ${cmakeRPathFlag}${toString cmakeFlags} ..
|
2010-12-22 14:50:13 +00:00
|
|
|
'') ["minInit" "addInputs" "doUnpack"];
|
|
|
|
|
2011-04-18 08:41:54 +01:00
|
|
|
doScons = fullDepEntry (''
|
2012-01-18 20:16:00 +00:00
|
|
|
mkdir -p $out
|
2011-04-18 08:41:54 +01:00
|
|
|
${if (attrByPath ["sconsCleanEnv"] false args)
|
|
|
|
then ""
|
|
|
|
else ''
|
|
|
|
sed -e '1iimport os' -i SConstruct
|
|
|
|
sed -e 's/env *= *Environment *.*/&; env['"'"'ENV'"'"']=os.environ;/' -i SConstruct
|
|
|
|
''
|
|
|
|
}
|
2011-04-19 17:02:29 +01:00
|
|
|
scons ${toString (attrByPath ["sconsFlags"] [] args)} PREFIX=$out
|
|
|
|
scons ${toString (attrByPath ["sconsFlags"] [] args)} PREFIX=$out install
|
2011-04-18 08:41:54 +01:00
|
|
|
'') ["minInit" "doUnpack" "addInputs" "defEnsureDir"];
|
|
|
|
|
2009-05-24 11:57:46 +01:00
|
|
|
/*debug = x:(trace x x);
|
|
|
|
debugX = x:(trace (toXML x) x);*/
|
2008-07-17 14:39:58 +01:00
|
|
|
|
2009-05-11 16:21:42 +01:00
|
|
|
makeNest = x: if x == defNest.text then x else "startNest\n" + x + "\nstopNest\n";
|
|
|
|
textClosure = a: steps: textClosureMap makeNest a (["defNest"] ++ steps);
|
2007-11-08 14:34:54 +00:00
|
|
|
|
2009-05-20 00:25:58 +01:00
|
|
|
inherit noDepEntry fullDepEntry packEntry;
|
2008-07-17 14:39:58 +01:00
|
|
|
|
2009-05-24 11:57:41 +01:00
|
|
|
defList = attrByPath ["defList"] [] args;
|
2008-07-17 14:39:58 +01:00
|
|
|
getVal = getValue args defList;
|
|
|
|
check = checkFlag args;
|
2009-05-24 11:57:41 +01:00
|
|
|
reqsList = attrByPath ["reqsList"] [] args;
|
2009-05-11 16:21:42 +01:00
|
|
|
buildInputsNames = filter (x: null != getVal x)
|
2008-07-17 14:39:58 +01:00
|
|
|
(uniqList {inputList =
|
2009-05-11 16:21:42 +01:00
|
|
|
(concatLists (map
|
|
|
|
(x: if x==[] then [] else builtins.tail x)
|
|
|
|
reqsList));});
|
2009-05-24 11:57:41 +01:00
|
|
|
configFlags = attrByPath ["configFlags"] [] args;
|
|
|
|
buildFlags = attrByPath ["buildFlags"] [] args;
|
|
|
|
nameSuffixes = attrByPath ["nameSuffixes"] [] args;
|
2008-07-17 14:39:58 +01:00
|
|
|
autoBuildInputs = assert (checkReqs args defList reqsList);
|
|
|
|
filter (x: x!=null) (map getVal buildInputsNames);
|
|
|
|
autoConfigureFlags = condConcat "" configFlags check;
|
|
|
|
autoMakeFlags = condConcat "" buildFlags check;
|
2009-05-24 11:57:41 +01:00
|
|
|
useConfig = attrByPath ["useConfig"] false args;
|
2008-08-20 12:30:06 +01:00
|
|
|
realBuildInputs =
|
2008-07-17 14:39:58 +01:00
|
|
|
lib.closePropagation ((if useConfig then
|
|
|
|
autoBuildInputs else
|
2009-05-24 11:57:41 +01:00
|
|
|
attrByPath ["buildInputs"] [] args)++
|
|
|
|
(attrByPath ["propagatedBuildInputs"] [] args));
|
2008-07-17 14:39:58 +01:00
|
|
|
configureFlags = if useConfig then autoConfigureFlags else
|
2009-05-24 11:57:41 +01:00
|
|
|
attrByPath ["configureFlags"] "" args;
|
|
|
|
makeFlags = if useConfig then autoMakeFlags else attrByPath ["makeFlags"] "" args;
|
2008-07-17 14:39:58 +01:00
|
|
|
|
|
|
|
inherit lib;
|
|
|
|
|
|
|
|
surroundWithCommands = x : before : after : {deps=x.deps; text = before + "\n" +
|
|
|
|
x.text + "\n" + after ;};
|
2008-01-22 14:34:23 +00:00
|
|
|
|
2009-05-20 00:25:58 +01:00
|
|
|
createDirs = fullDepEntry (concatStringsSep ";"
|
2012-01-18 20:16:00 +00:00
|
|
|
(map (x: "mkdir -p ${x}") (attrByPath ["neededDirs"] [] args))
|
2008-12-14 14:54:47 +00:00
|
|
|
) ["minInit" "defEnsureDir"];
|
|
|
|
|
2009-05-20 00:25:58 +01:00
|
|
|
copyExtraDoc = fullDepEntry (''
|
2008-12-14 14:54:47 +00:00
|
|
|
name="$(basename $out)"
|
|
|
|
name="''${name#*-}"
|
2012-01-18 20:16:00 +00:00
|
|
|
mkdir -p "$out/share/doc/$name"
|
2008-12-14 14:54:47 +00:00
|
|
|
'' + (concatStringsSep ";"
|
|
|
|
(map
|
2008-12-14 17:10:11 +00:00
|
|
|
(x: ''cp "${x}" "$out/share/doc/$name" || true;'')
|
2009-05-24 11:57:41 +01:00
|
|
|
(attrByPath ["extraDoc"] [] args)))) ["minInit" "defEnsureDir" "doUnpack"];
|
2008-12-14 14:54:47 +00:00
|
|
|
|
|
|
|
realPhaseNames =
|
2009-05-24 11:57:41 +01:00
|
|
|
(optional ([] != attrByPath ["neededDirs"] [] args) "createDirs")
|
2008-12-14 14:54:47 +00:00
|
|
|
++
|
2010-08-17 18:00:20 +01:00
|
|
|
(attrByPath ["phaseNames"] [] args)
|
2008-12-14 14:54:47 +00:00
|
|
|
++
|
2008-07-17 14:39:58 +01:00
|
|
|
["doForceShare" "doPropagate" "doForceCopy"]
|
2008-12-14 14:54:47 +00:00
|
|
|
++
|
2009-05-24 11:57:41 +01:00
|
|
|
(optional ([] != attrByPath ["extraDoc"] [] args) "copyExtraDoc")
|
2008-07-17 14:39:58 +01:00
|
|
|
++
|
2009-05-24 11:57:41 +01:00
|
|
|
(optional (attrByPath ["doCheck"] false args) "doMakeCheck")
|
2008-07-17 14:39:58 +01:00
|
|
|
++
|
2009-05-24 11:57:41 +01:00
|
|
|
(optional (attrByPath ["alwaysFail"] false args) "doFail")
|
2008-07-17 14:39:58 +01:00
|
|
|
;
|
|
|
|
|
|
|
|
doFail = noDepEntry "
|
|
|
|
echo 'Failing to keep builddir (and to invalidate result).'
|
|
|
|
a() { return 127; } ; a ;
|
|
|
|
";
|
|
|
|
|
2009-05-20 00:25:58 +01:00
|
|
|
doMakeCheck = fullDepEntry (''
|
2008-07-23 14:40:03 +01:00
|
|
|
make check
|
|
|
|
'') ["minInit"];
|
2008-05-18 06:12:39 +01:00
|
|
|
|
2009-05-24 11:57:41 +01:00
|
|
|
extraDerivationAttrs = lib.attrByPath ["extraDerivationAttrs"] {} args;
|
2008-03-20 15:40:26 +00:00
|
|
|
|
2008-08-19 06:54:09 +01:00
|
|
|
# for overrides..
|
|
|
|
builderDefsArgs = args;
|
|
|
|
|
2008-08-20 12:30:06 +01:00
|
|
|
innerBuilderDefsPackage = bd: args: (
|
2008-11-04 21:24:10 +00:00
|
|
|
let localDefs = bd.passthru.function args; in
|
2008-03-20 15:40:26 +00:00
|
|
|
|
2008-07-17 14:39:58 +01:00
|
|
|
stdenv.mkDerivation ((rec {
|
|
|
|
inherit (localDefs) name;
|
2009-05-11 16:21:42 +01:00
|
|
|
buildCommand = textClosure localDefs localDefs.realPhaseNames;
|
2008-12-14 10:40:03 +00:00
|
|
|
meta = localDefs.meta;
|
|
|
|
passthru = localDefs.passthru // {inherit (localDefs) src; };
|
2008-07-17 14:39:58 +01:00
|
|
|
}) // (if localDefs ? propagatedBuildInputs then {
|
|
|
|
inherit (localDefs) propagatedBuildInputs;
|
|
|
|
} else {}) // extraDerivationAttrs)
|
|
|
|
);
|
2008-03-20 15:40:26 +00:00
|
|
|
|
2008-08-20 12:30:06 +01:00
|
|
|
builderDefsPackage = bd: func:
|
2012-12-28 18:54:15 +00:00
|
|
|
if builtins.isFunction func then
|
2009-08-04 08:14:43 +01:00
|
|
|
(foldArgs
|
|
|
|
(x: y: ((func (bd // x // y)) // y))
|
|
|
|
(innerBuilderDefsPackage bd)
|
|
|
|
{})
|
|
|
|
else
|
|
|
|
(builderDefsPackage bd (import (toString func)))
|
|
|
|
;
|
2008-08-19 06:54:09 +01:00
|
|
|
|
2009-05-20 00:25:58 +01:00
|
|
|
generateFontsFromSFD = fullDepEntry (''
|
2008-07-17 14:39:58 +01:00
|
|
|
for i in *.sfd; do
|
2010-11-11 12:59:31 +00:00
|
|
|
echo $i;
|
2008-08-20 12:30:06 +01:00
|
|
|
fontforge -c \
|
2008-07-17 14:39:58 +01:00
|
|
|
'Open($1);
|
|
|
|
${optionalString (args ? extraFontForgeCommands) args.extraFontForgeCommands
|
|
|
|
}Reencode("unicode");
|
2009-05-24 11:57:41 +01:00
|
|
|
${optionalString (attrByPath ["createTTF"] true args) ''Generate($1:r + ".ttf");''}
|
|
|
|
${optionalString (attrByPath ["createOTF"] true args) ''Generate($1:r + ".otf");''}
|
2008-07-17 14:39:58 +01:00
|
|
|
Reencode("TeX-Base-Encoding");
|
2009-05-24 11:57:41 +01:00
|
|
|
${optionalString (attrByPath ["createAFM"] true args) ''Generate($1:r + ".afm");''}
|
|
|
|
${optionalString (attrByPath ["createPFM"] true args) ''Generate($1:r + ".pfm");''}
|
|
|
|
${optionalString (attrByPath ["createPFB"] true args) ''Generate($1:r + ".pfb");''}
|
|
|
|
${optionalString (attrByPath ["createMAP"] true args) ''Generate($1:r + ".map");''}
|
|
|
|
${optionalString (attrByPath ["createENC"] true args) ''Generate($1:r + ".enc");''}
|
2008-07-17 14:39:58 +01:00
|
|
|
' $i;
|
|
|
|
done
|
2008-08-20 12:30:06 +01:00
|
|
|
'') ["minInit" "addInputs" "doUnpack"];
|
2008-04-28 11:10:44 +01:00
|
|
|
|
2010-08-17 18:00:20 +01:00
|
|
|
installFonts =
|
|
|
|
let retrievedName = (if args ? name then args.name else ""); in
|
|
|
|
fullDepEntry (''
|
2012-01-18 20:16:00 +00:00
|
|
|
mkdir -p $out/share/fonts/truetype/public/${retrievedName}
|
|
|
|
mkdir -p $out/share/fonts/opentype/public/${retrievedName}
|
|
|
|
mkdir -p $out/share/fonts/type1/public/${retrievedName}
|
|
|
|
mkdir -p $out/share/texmf/fonts/enc/${retrievedName}
|
|
|
|
mkdir -p $out/share/texmf/fonts/map/${retrievedName}
|
2010-08-17 18:00:20 +01:00
|
|
|
|
2014-05-07 08:52:21 +01:00
|
|
|
find -name '*.ttf' -exec cp {} $out/share/fonts/truetype/public/${retrievedName} \;
|
|
|
|
find -name '*.otf' -exec cp {} $out/share/fonts/opentype/public/${retrievedName} \;
|
|
|
|
find -name '*.pfm' -o -name '*.afm' -o -name '*.pfb' -exec cp {} $out/share/fonts/type1/public/${retrievedName} \;
|
|
|
|
find -name '*.enc' -exec cp {} $out/share/texmf/fonts/enc/${retrievedName} \;
|
|
|
|
find -name '*.map' -exec cp {} $out/share/texmf/fonts/map/${retrievedName} \;
|
2008-04-28 11:10:44 +01:00
|
|
|
'') ["minInit" "defEnsureDir"];
|
|
|
|
|
2009-05-20 00:25:58 +01:00
|
|
|
simplyShare = shareName: fullDepEntry (''
|
2012-01-18 20:16:00 +00:00
|
|
|
mkdir -p $out/share
|
2008-05-26 12:39:08 +01:00
|
|
|
cp -r . $out/share/${shareName}
|
|
|
|
'') ["doUnpack" "defEnsureDir"];
|
|
|
|
|
2009-05-20 00:25:58 +01:00
|
|
|
doPatchShebangs = dir: fullDepEntry (''
|
2008-06-12 08:17:37 +01:00
|
|
|
patchShebangFun() {
|
|
|
|
# Rewrite all script interpreter file names (`#! /path') under the
|
|
|
|
# specified directory tree to paths found in $PATH. E.g.,
|
|
|
|
# /bin/sh will be rewritten to /nix/store/<hash>-some-bash/bin/sh.
|
|
|
|
# Interpreters that are already in the store are left untouched.
|
2008-06-12 09:37:07 +01:00
|
|
|
echo "patching script interpreter paths"
|
2008-06-12 08:17:37 +01:00
|
|
|
local f
|
2013-10-14 07:36:39 +01:00
|
|
|
for f in $(find "${dir}" -xtype f -perm +0100); do
|
2008-06-12 08:17:37 +01:00
|
|
|
local oldPath=$(sed -ne '1 s,^#![ ]*\([^ ]*\).*$,\1,p' "$f")
|
|
|
|
if test -n "$oldPath" -a "''${oldPath:0:''${#NIX_STORE}}" != "$NIX_STORE"; then
|
|
|
|
local newPath=$(type -P $(basename $oldPath) || true)
|
|
|
|
if test -n "$newPath" -a "$newPath" != "$oldPath"; then
|
|
|
|
echo "$f: interpreter changed from $oldPath to $newPath"
|
|
|
|
sed -i "1 s,$oldPath,$newPath," "$f"
|
2013-10-14 07:36:39 +01:00
|
|
|
else
|
|
|
|
echo "$f: not changing interpreter from $oldPath"
|
2008-06-12 08:17:37 +01:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
}
|
|
|
|
patchShebangFun;
|
|
|
|
'') ["minInit"];
|
|
|
|
|
2009-05-20 00:25:58 +01:00
|
|
|
createPythonInstallationTarget = fullDepEntry (''
|
2012-01-18 20:16:00 +00:00
|
|
|
mkdir -p $(toPythonPath $out)
|
2008-06-12 16:59:59 +01:00
|
|
|
export PYTHONPATH=$PYTHONPATH''${PYTHONPATH:+:}$(toPythonPath $out)
|
|
|
|
'') ["minInit" "addInputs" "defEnsureDir"];
|
2009-08-26 12:13:36 +01:00
|
|
|
|
2010-06-17 06:19:26 +01:00
|
|
|
fetchUrlFromSrcInfo = srcInfo: fetchurl ({
|
2009-08-26 12:13:36 +01:00
|
|
|
url = srcInfo.url;
|
|
|
|
sha256 = srcInfo.hash;
|
2010-06-17 06:19:26 +01:00
|
|
|
} //
|
2012-12-28 18:54:15 +00:00
|
|
|
(if srcInfo ? downloadName then {name = srcInfo.downloadName;} else {}));
|
2009-09-08 10:35:21 +01:00
|
|
|
|
2009-11-08 01:51:20 +00:00
|
|
|
fetchGitFromSrcInfo = srcInfo: fetchgit {
|
2009-09-08 10:35:21 +01:00
|
|
|
url = srcInfo.url;
|
|
|
|
rev = srcInfo.rev;
|
|
|
|
sha256 = srcInfo.hash;
|
2009-11-08 01:51:20 +00:00
|
|
|
};
|
2007-11-12 16:42:13 +00:00
|
|
|
}) // args
|
2009-09-10 17:57:29 +01:00
|
|
|
|
|
|
|
# [1]: rewrite using '' instead of " so that indentation gets stripped. It's
|
|
|
|
# only about some spaces but in the end they will sum up
|