summary refs log tree commit diff
path: root/pkgs/misc/tex/nix
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2007-03-12 17:55:08 +0000
committerEelco Dolstra <eelco.dolstra@logicblox.com>2007-03-12 17:55:08 +0000
commitead48be2296a47a8533b1854792f354cc2c1337a (patch)
tree202eeff606f2951d2c53f379e73480dcb3126396 /pkgs/misc/tex/nix
parentc9c70b8d75a44e43b6d0c1e375792cc8f030e83e (diff)
downloadnixpkgs-ead48be2296a47a8533b1854792f354cc2c1337a.tar
nixpkgs-ead48be2296a47a8533b1854792f354cc2c1337a.tar.gz
nixpkgs-ead48be2296a47a8533b1854792f354cc2c1337a.tar.bz2
nixpkgs-ead48be2296a47a8533b1854792f354cc2c1337a.tar.lz
nixpkgs-ead48be2296a47a8533b1854792f354cc2c1337a.tar.xz
nixpkgs-ead48be2296a47a8533b1854792f354cc2c1337a.tar.zst
nixpkgs-ead48be2296a47a8533b1854792f354cc2c1337a.zip
* runLaTeX: support generation of Postscript.
* findLaTeXIncludes: handle the case where the input is already in the
  Nix store, and allow a different prefix to be used for searching
  included files.

svn path=/nixpkgs/trunk/; revision=8268
Diffstat (limited to 'pkgs/misc/tex/nix')
-rw-r--r--pkgs/misc/tex/nix/default.nix13
-rw-r--r--pkgs/misc/tex/nix/find-includes.pl24
-rw-r--r--pkgs/misc/tex/nix/run-latex.sh5
3 files changed, 28 insertions, 14 deletions
diff --git a/pkgs/misc/tex/nix/default.nix b/pkgs/misc/tex/nix/default.nix
index 89db336029c..f2834805818 100644
--- a/pkgs/misc/tex/nix/default.nix
+++ b/pkgs/misc/tex/nix/default.nix
@@ -5,11 +5,15 @@ rec {
 
   runLaTeX =
     { rootFile
-    , generatePDF ? true
+    , generatePDF ? true # generate PDF, not DVI
+    , generatePS ? false # generate PS in addition to DVI
     , extraFiles ? []
     , compressBlanksInIndex ? true
     , packages ? []
+    , searchRelativeTo ? dirOf (toString rootFile) # !!! duplication
     }:
+
+    assert generatePDF -> !generatePS;
     
     pkgs.stdenv.mkDerivation {
       name = "doc";
@@ -17,10 +21,10 @@ rec {
       builder = ./run-latex.sh;
       copyIncludes = ./copy-includes.pl;
       
-      inherit rootFile generatePDF extraFiles
+      inherit rootFile generatePDF generatePS extraFiles
         compressBlanksInIndex;
 
-      includes = import (findLaTeXIncludes {inherit rootFile;});
+      includes = import (findLaTeXIncludes {inherit rootFile searchRelativeTo;});
       
       buildInputs = [ pkgs.tetex pkgs.perl ] ++ packages;
     };
@@ -28,6 +32,7 @@ rec {
     
   findLaTeXIncludes =
     { rootFile
+    , searchRelativeTo ? dirOf (toString rootFile)
     }:
 
     pkgs.stdenv.mkDerivation {
@@ -38,6 +43,8 @@ rec {
 
       rootFile = toString rootFile; # !!! hacky
 
+      inherit searchRelativeTo;
+
       # Forces rebuilds.
       hack = __currentTime;
     };
diff --git a/pkgs/misc/tex/nix/find-includes.pl b/pkgs/misc/tex/nix/find-includes.pl
index 7750f63af19..e4424a3ecd6 100644
--- a/pkgs/misc/tex/nix/find-includes.pl
+++ b/pkgs/misc/tex/nix/find-includes.pl
@@ -3,17 +3,12 @@ use File::Basename;
 
 my $root = $ENV{"rootFile"};
 my $out = $ENV{"out"};
+my $path = $ENV{"searchRelativeTo"};
+my $store = $ENV{"NIX_STORE"};
 
 open OUT, ">$out" or die;
 print OUT "[\n";
 
-# We search for files relative to the root file.  TODO: search
-# relative to the paths in $TEXINPUTS.
-die unless substr($root, 0, 1) eq "/";
-my ($x, $path, $y) = fileparse($root);
-
-$path =~ s/\/$//;
-
 my @workset = ();
 my %doneset = ();
 
@@ -37,11 +32,18 @@ while (scalar @workset > 0) {
     
     
     # Print out the full path *and* its relative path to $root.
-    
-    die if substr($fn, 0, length $path) ne $path;
-    my $relFN = substr($fn, (length $path) + 1);
 
-    print OUT "$fn \"$relFN\"\n";
+    if (substr($fn, 0, length $path) eq $path) {
+        my $relFN = substr($fn, (length $path) + 1);
+        print OUT "$fn \"$relFN\"\n";
+    } else {
+        my $base = basename $fn;
+        my $x = substr($fn, 0, length($store) + 1);
+        if (substr($fn, 0, length($store) + 1) eq "$store/") {
+            $base = substr($base, 33);
+        }
+        print OUT "$fn \"$base\"\n";
+    }
 
     
     # If this is a TeX file, recursively find include in $fn.
diff --git a/pkgs/misc/tex/nix/run-latex.sh b/pkgs/misc/tex/nix/run-latex.sh
index 7127206606b..f7d642f6ea0 100644
--- a/pkgs/misc/tex/nix/run-latex.sh
+++ b/pkgs/misc/tex/nix/run-latex.sh
@@ -94,6 +94,11 @@ if test -n "$generatePDF"; then
     cp $rootNameBase.pdf $out
 else
     cp $rootNameBase.dvi $out
+    if test -n "$generatePS"; then
+        echo "CONVERTING TO POSTSCRIPT..."
+        dvips $rootNameBase.dvi -o $out/$rootNameBase.ps
+        echo
+    fi
 fi