summary refs log tree commit diff
path: root/pkgs/misc/tex/texlive/default.nix
blob: eadabb9b3391d431e46157bc7d94e12491679094 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
args : with args; 
rec {
  src = fetchurl { 
    url = mirror://debian/pool/main/t/texlive-bin/texlive-bin_2009.orig.tar.gz;
    sha256 = "0ywc8h4jnig53fs0bji2ivw5f9j6zlgdy477jqw7xvpc7migjpw7";
  };
  
  texmfSrc = fetchurl { 
    url = mirror://debian/pool/main/t/texlive-base/texlive-base_2009.orig.tar.gz;
    sha256 = "130z907xcxr10yrzbbmp9l8a00dabvi4bi702s5jxamjzav17cmf";
  };

  langTexmfSrc = fetchurl {
    url = mirror://debian/pool/main/t/texlive-lang/texlive-lang_2009.orig.tar.gz;
    sha256 = "10shnsc71n95zy9ys938pljdid9ampmc50k4lji9wv53hm14laic";
  };

  setupHook = ./setup-hook.sh;

  doMainBuild = fullDepEntry (''
    ensureDir $out
    ensureDir $out/nix-support 
    cp ${setupHook} $out/nix-support/setup-hook.sh
    ensureDir $out/share
    tar xf ${texmfSrc} -C $out --strip-components=1
    tar xf ${langTexmfSrc} -C $out --strip-components=1

    sed -e s@/usr/bin/@@g -i $(grep /usr/bin/ -rl . )

    sed -e 's@\<env ruby@${ruby}/bin/ruby@' -i $(grep 'env ruby' -rl . )
    sed -e 's@\<env perl@${perl}/bin/perl@' -i $(grep 'env perl' -rl . )
    sed -e 's@\<env python@${python}/bin/python@' -i $(grep 'env python' -rl . )

    sed -e '/ubidi_open/i#include <unicode/urename.h>' -i $(find . -name configure)
    sed -e s@ncurses/curses.h@curses.h@g -i $(grep ncurses/curses.h -rl . ) 
    sed -e '1i\#include <string.h>\n\#include <stdlib.h>' -i $( find libs/teckit -name '*.cpp' -o -name '*.c' )

    NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE -I${freetype}/include/freetype2"
    NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE -I${icu}/include/layout";

    ./Build --prefix="$out" --datadir="$out/share" --mandir "$out/share/man" --infodir "$out/share/info" \
      ${args.lib.concatStringsSep " " configureFlags}
    cd Work
  '') ["minInit" "doUnpack" "addInputs" "defEnsureDir"];

  doPostInstall = fullDepEntry(''
    mv $out/bin $out/libexec
    ensureDir $out/bin
    for i in "$out/libexec/"*"/"*; do
        echo -ne "#! /bin/sh\\n$i \"\$@\"" >$out/bin/$(basename $i)
        chmod a+x $out/bin/$(basename $i)
    done
    [ -d $out/texmf-config ] || ln -s $out/texmf $out/texmf-config
    ln -s "$out/"*texmf* "$out/share/"
    
    sed -e 's/.*pyhyph.*/=&/' -i $out/texmf-config/tex/generic/config/language.dat

    PATH=$PATH:$out/bin mktexlsr $out/texmf*

    HOME=. PATH=$PATH:$out/bin updmap-sys --syncwithtrees

    # Prebuild the format files, as it used to be done with TeXLive 2007.
    echo "building format files..."
    ensureDir "$out/texmf-var/web2c"
    PATH="$PATH:$out/bin" fmtutil-sys --all

    PATH=$PATH:$out/bin mktexlsr $out/texmf*
 '') ["minInit" "defEnsureDir" "doUnpack" "doMakeInstall"];

  buildInputs = [
    zlib bzip2 ncurses libpng flex bison libX11 libICE
    xproto freetype t1lib gd libXaw icu ghostscript ed 
    libXt libXpm libXmu libXext xextproto perl libSM 
    ruby expat curl libjpeg python fontconfig
  ];

  configureFlags = [ "--with-x11" 
    "--enable-ipc" "--with-mktexfmt"
  ];

  phaseNames = ["addInputs" (doDump "0") "doMainBuild" 
    (doDump "1")
    "doMakeInstall" "doPostInstall"];

  name = "texlive-core-2009";
  meta = {
    description = "A TeX distribution";
    maintainers = [ args.lib.maintainers.raskin ];
    platforms = args.lib.platforms.linux ++ args.lib.platforms.freebsd ;
  };
}