about summary refs log tree commit diff
path: root/nixpkgs/pkgs/tools/typesetting/tex/advi/default.nix
blob: 3b6b2eb3048a04f2720a52f74da48501ae18a87a (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
{ fetchurl
, lib
, makeWrapper
, writeShellScriptBin
, ghostscriptX
, ocamlPackages
, texliveMedium
, which
}:

let
  # simplified fake-opam edited from tweag's opam-nix
  fake-opam = writeShellScriptBin "opam" ''
    case "$1 $2" in
      "config var")
        case "$3" in
          man) echo "$out/share/man";;
          etc) echo "$out/etc";;
          doc) echo "$out/share/doc";;
          share) echo "$out/share";;
          prefix) echo "$out";;
          *) echo "fake-opam does not understand arguments: $@" ; exit 1 ;;
        esac;;
      *) echo "fake-opam does not understand arguments: $@" ; exit 1 ;;
    esac
  '';

  # texlive currently does not symlink kpsexpand
  kpsexpand = writeShellScriptBin "kpsexpand" ''
    exec kpsetool -v
  '';
in
ocamlPackages.buildDunePackage rec {
  pname = "advi";
  version = "2.0.0";

  minimalOCamlVersion = "4.11";

  src = fetchurl {
    url = "http://advi.inria.fr/advi-${version}.tar.gz";
    hash = "sha256-c0DQHlvdekJyXCxmR4+Ut/njtoCzmqX6hNazNv8PpBQ=";
  };

  postPatch = ''
    substituteInPlace ./Makefile \
      --replace "\$(DUNE) install \$(DUNEROOT) --display=short" \
      "\$(DUNE) install \$(DUNEROOT) --prefix $out --docdir $out/share/doc --mandir $out/share/man"
    substituteInPlace ./src/discover.sh \
      --replace 'gs_path=$(which gs)' 'gs_path=${ghostscriptX}/bin/gs'
  '';

  duneVersion = "3";

  nativeBuildInputs = [ fake-opam kpsexpand makeWrapper texliveMedium which ];
  buildInputs = with ocamlPackages; [ camlimages ghostscriptX graphics ];

  # install additional files (such as man pages)
  preInstall = ''
    make install
  '';

  # TODO: redirect /share/advi/tex/latex to tex output compatible with texlive.combine
  # (requires patching check() in advi-latex-files)

  meta = with lib; {
    homepage = "http://advi.inria.fr/";
    description = "Active-DVI is a Unix-platform DVI previewer and a programmable presenter for slides written in LaTeX.";
    license = licenses.lgpl21Only;
    maintainers = [ maintainers.xworld21 ];
  };
}