summary refs log tree commit diff
path: root/pkgs/misc/tex
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/misc/tex')
-rw-r--r--pkgs/misc/tex/nix/copy-includes.pl1
-rw-r--r--pkgs/misc/tex/nix/default.nix20
-rw-r--r--pkgs/misc/tex/nix/dot2pdf.sh20
-rw-r--r--pkgs/misc/tex/nix/run-latex.sh14
4 files changed, 45 insertions, 10 deletions
diff --git a/pkgs/misc/tex/nix/copy-includes.pl b/pkgs/misc/tex/nix/copy-includes.pl
index 26a9ab916022..b81bf27f86a4 100644
--- a/pkgs/misc/tex/nix/copy-includes.pl
+++ b/pkgs/misc/tex/nix/copy-includes.pl
@@ -5,7 +5,6 @@ sub createDirs;
 sub createDirs {
     my $path = shift;
     return unless $path =~ /^(.*)\/([^\/]*)$/;
-    print "$1 BLA $2\n";
     return if -d $1;
     createDirs $1;
     mkdir $1 or die "cannot create directory `$1'";
diff --git a/pkgs/misc/tex/nix/default.nix b/pkgs/misc/tex/nix/default.nix
index d371014e1ff0..8509562d90c3 100644
--- a/pkgs/misc/tex/nix/default.nix
+++ b/pkgs/misc/tex/nix/default.nix
@@ -6,6 +6,7 @@ rec {
   runLaTeX =
     { rootFile
     , generatePDF ? true
+    , extraFiles ? []
     }:
     
     pkgs.stdenv.mkDerivation {
@@ -14,7 +15,7 @@ rec {
       builder = ./run-latex.sh;
       copyIncludes = ./copy-includes.pl;
       
-      inherit rootFile generatePDF;
+      inherit rootFile generatePDF extraFiles;
 
       includes = import (findLaTeXIncludes {inherit rootFile;});
       
@@ -37,5 +38,20 @@ rec {
       # Forces rebuilds.
       hack = __currentTime;
     };
-    
+
+
+  dot2pdf =
+    { dotGraph
+    }:
+
+    pkgs.stdenv.mkDerivation {
+      name = "pdf";
+      builder = ./dot2pdf.sh;
+      inherit dotGraph;
+      buildInputs = [
+        pkgs.perl pkgs.tetex pkgs.graphviz pkgs.ghostscript
+      ];
+    };
+  
+       
 }
\ No newline at end of file
diff --git a/pkgs/misc/tex/nix/dot2pdf.sh b/pkgs/misc/tex/nix/dot2pdf.sh
new file mode 100644
index 000000000000..755cc6457105
--- /dev/null
+++ b/pkgs/misc/tex/nix/dot2pdf.sh
@@ -0,0 +1,20 @@
+. $stdenv/setup
+
+ensureDir $out
+
+dot2pdf() {
+    sourceFile=$1
+    targetName=$out/$(basename $(stripHash $sourceFile; echo $strippedName) .dot).pdf
+    echo "convering $sourceFile to $targetName..."
+    dot -Tps $sourceFile > tmp.ps
+    epstopdf --outfile $targetName tmp.ps
+}
+
+for i in $dotGraph; do
+    if test -d $i; then
+        for j in $i/*; do dot2pdf $j; done
+    else
+        dot2pdf $i
+    fi
+done
+
diff --git a/pkgs/misc/tex/nix/run-latex.sh b/pkgs/misc/tex/nix/run-latex.sh
index 07db6e9c42aa..b36df234df1c 100644
--- a/pkgs/misc/tex/nix/run-latex.sh
+++ b/pkgs/misc/tex/nix/run-latex.sh
@@ -4,13 +4,13 @@ ensureDir $out
 
 perl $copyIncludes $includes
 
-#for i in $includes; do
-#    if test -d $i; then
-#        cp $i/* .
-#    else
-#        cp $i $(stripHash $i; echo $strippedName)
-#    fi
-#done
+for i in $extraFiles; do
+    if test -d $i; then
+        ln -s $i/* .
+    else
+        ln -s $i $(stripHash $i; echo $strippedName)
+    fi
+done
 
 rootName=$(basename $(stripHash "$rootFile"; echo $strippedName))
 echo "root name is $rootName"