Added lhs2TeX support to LaTeX builder.

svn path=/nixpkgs/trunk/; revision=16439
This commit is contained in:
Andres Löh 2009-07-23 14:13:09 +00:00
parent 9f59fb9377
commit 5164d2ec62
5 changed files with 65 additions and 0 deletions

View File

@ -76,6 +76,29 @@ rec {
};
findLhs2TeXIncludes =
{ rootFile
}:
builtins.genericClosure {
startSet = [{key = rootFile;}];
operator =
{key, ...}:
let
trace = x: builtins.trace x x;
deps = import (pkgs.runCommand "lhs2tex-includes"
{ src = trace key; }
"${pkgs.stdenv.bash}/bin/bash ${./find-lhs2tex-includes.sh}");
in pkgs.lib.concatMap (x : if builtins.pathExists x then [{key = x;}]
else builtins.trace ("not found: ${toString x}") [])
(map (x : trace "${dirOf key}/${x}") deps);
};
dot2pdf =
{ dotGraph
}:
@ -103,6 +126,17 @@ rec {
];
};
lhs2tex =
{ source, flags ? null } :
pkgs.stdenv.mkDerivation {
name = "tex";
builder = ./lhs2tex.sh;
inherit source flags;
buildInputs = [ pkgs.lhs2tex pkgs.perl ];
copyIncludes = ./copy-includes.pl;
includes = map (x: [x.key (baseNameOf (toString x.key))])
(findLhs2TeXIncludes {rootFile = source;});
};
animateDot = dotGraph: nrFrames: pkgs.stdenv.mkDerivation {
name = "dot-frames";

View File

@ -20,6 +20,14 @@ while (<FILE>) {
my $fn2 = $1;
die "absolute path! $fn2" if substr($fn2, 0, 1) eq "/";
addName "tex", "$fn2";
} elsif (/\\input (.*)$/) {
my $fn2 = $1;
die "absolute path! $fn2" if substr($fn2, 0, 1) eq "/";
addName "tex", "$fn2";
} elsif (/\\RequirePackage(\[.*\])?\{(.*)\}/) {
my $fn2 = $2;
die "absolute path! $fn2" if substr($fn2, 0, 1) eq "/";
addName "misc", "$fn2.sty";
} elsif (/\\usepackage(\[.*\])?\{(.*)\}/) {
my $fn2 = $2;
die "absolute path! $fn2" if substr($fn2, 0, 1) eq "/";

View File

@ -0,0 +1,3 @@
echo '[' > $out
grep '^%include ' $src | cut -d ' ' -f 2 | sed 's/^\(.*\)$/"\1"/' >> $out
echo ']' >> $out

View File

@ -0,0 +1,19 @@
source $stdenv/setup
ensureDir $out
mkdir root
cd root
startDir=$(perl $copyIncludes $includes)
cd $startDir
lhstex() {
sourceFile=$1
targetName=$out/$(basename $(stripHash $sourceFile; echo $strippedName) .lhs).tex
echo "converting $sourceFile to $targetName..."
lhs2TeX -o "$targetName" $flags "$sourceFile"
}
lhstex $source

View File

@ -7871,6 +7871,7 @@ let
texFunctions = import ../misc/tex/nix {
inherit stdenv perl tetex graphviz ghostscript makeFontsConf imagemagick runCommand lib;
inherit (haskellPackages) lhs2tex;
};
texLive = builderDefsPackage (import ../misc/tex/texlive) {