summary refs log tree commit diff
path: root/pkgs/test/texlive/default.nix
blob: 7a6affd6cbe00c1d656a779504a140347dde8458 (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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
{ runCommandNoCC, fetchurl, file, texlive, writeShellScript }:

{
  chktex = runCommandNoCC "texlive-test-chktex" {
    nativeBuildInputs = [
      (with texlive; combine { inherit scheme-infraonly chktex; })
    ];
    input = builtins.toFile "chktex-sample.tex" ''
      \documentclass{article}
      \begin{document}
        \LaTeX is great
      \end{document}
    '';
  } ''
    chktex -v -nall -w1 "$input" 2>&1 | tee "$out"
    grep "One warning printed" "$out"
  '';

  # https://github.com/NixOS/nixpkgs/issues/75605
  dvipng.basic = runCommandNoCC "texlive-test-dvipng-basic" {
    nativeBuildInputs = [ file texlive.combined.scheme-medium ];
    input = fetchurl {
      name = "test_dvipng.tex";
      url = "http://git.savannah.nongnu.org/cgit/dvipng.git/plain/test_dvipng.tex?id=b872753590a18605260078f56cbd6f28d39dc035";
      sha256 = "1pjpf1jvwj2pv5crzdgcrzvbmn7kfmgxa39pcvskl4pa0c9hl88n";
    };
  } ''
    cp "$input" ./document.tex

    latex document.tex
    dvipng -T tight -strict -picky document.dvi
    for f in document*.png; do
      file "$f" | tee output
      grep PNG output
    done

    mkdir "$out"
    mv document*.png "$out"/
  '';

  # test dvipng's limited capability to render postscript specials via GS
  dvipng.ghostscript = runCommandNoCC "texlive-test-ghostscript" {
    nativeBuildInputs = [ file (with texlive; combine { inherit scheme-small dvipng; }) ];
    input = builtins.toFile "postscript-sample.tex" ''
      \documentclass{minimal}
      \begin{document}
        Ni
        \special{ps:
          newpath
          0 0 moveto
          7 7 rlineto
          0 7 moveto
          7 -7 rlineto
          stroke
          showpage
        }
      \end{document}
    '';
    gs_trap = writeShellScript "gs_trap.sh" ''
      exit 1
    '';
  } ''
    cp "$gs_trap" ./gs
    export PATH=$PWD:$PATH
    # check that the trap works
    gs && exit 1

    cp "$input" ./document.tex

    latex document.tex
    dvipng -T 1in,1in -strict -picky document.dvi
    for f in document*.png; do
      file "$f" | tee output
      grep PNG output
    done

    mkdir "$out"
    mv document*.png "$out"/
  '';


  # https://github.com/NixOS/nixpkgs/issues/75070
  dvisvgm = runCommandNoCC "texlive-test-dvisvgm" {
    nativeBuildInputs = [ file texlive.combined.scheme-medium ];
    input = builtins.toFile "dvisvgm-sample.tex" ''
      \documentclass{article}
      \begin{document}
        mwe
      \end{document}
    '';
  } ''
    cp "$input" ./document.tex

    latex document.tex
    dvisvgm document.dvi -n -o document_dvi.svg
    cat document_dvi.svg
    file document_dvi.svg | grep SVG

    pdflatex document.tex
    dvisvgm -P document.pdf -n -o document_pdf.svg
    cat document_pdf.svg
    file document_pdf.svg | grep SVG

    mkdir "$out"
    mv document*.svg "$out"/
  '';
}