forked from mirrors/nixpkgs
* Macros for building LaTeX documents using Nix.
svn path=/nixpkgs/trunk/; revision=3216
This commit is contained in:
parent
f029091023
commit
6fcee91442
20
pkgs/misc/tex/nix/default.nix
Normal file
20
pkgs/misc/tex/nix/default.nix
Normal file
|
@ -0,0 +1,20 @@
|
|||
pkgs:
|
||||
|
||||
rec {
|
||||
|
||||
runLaTeX =
|
||||
{ rootFile
|
||||
, generatePDF ? true
|
||||
}:
|
||||
|
||||
pkgs.stdenv.mkDerivation {
|
||||
name = "doc";
|
||||
builder = ./run-latex.sh;
|
||||
|
||||
inherit rootFile generatePDF;
|
||||
|
||||
buildInputs = [ pkgs.tetex ];
|
||||
};
|
||||
|
||||
|
||||
}
|
40
pkgs/misc/tex/nix/run-latex.sh
Normal file
40
pkgs/misc/tex/nix/run-latex.sh
Normal file
|
@ -0,0 +1,40 @@
|
|||
. $stdenv/setup
|
||||
|
||||
ensureDir $out
|
||||
|
||||
for i in $rootFile $sources; do
|
||||
if test -d $i; then
|
||||
cp $i/* .
|
||||
else
|
||||
cp $i $(stripHash $i; echo $strippedName)
|
||||
fi
|
||||
done
|
||||
|
||||
rootName=$(basename $(stripHash "$rootFile"; echo $strippedName))
|
||||
echo "root name is $rootName"
|
||||
|
||||
rootNameBase=$(echo "$rootName" | sed 's/\..*//')
|
||||
|
||||
if test -n "$generatePDF"; then
|
||||
latex=pdflatex
|
||||
else
|
||||
latex=latex
|
||||
fi
|
||||
|
||||
$latex $rootName
|
||||
|
||||
if grep -q '\\bibitem' $rootNameBase.bbl; then
|
||||
bibtex $rootNameBase
|
||||
fi
|
||||
|
||||
$latex $rootName
|
||||
|
||||
makeindex $rootNameBase.idx
|
||||
|
||||
$latex $rootName
|
||||
|
||||
if test -n "$generatePDF"; then
|
||||
cp $rootNameBase.pdf $out
|
||||
else
|
||||
cp $rootNameBase.dvi $out
|
||||
fi
|
Loading…
Reference in a new issue