summary refs log tree commit diff
path: root/pkgs/tools/typesetting/xmlto/default.nix
blob: 1b0602063e9eb40fff99929113a3b4fe24bffa8e (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
{ fetchurl, stdenv, flex, libxml2, libxslt
, docbook_xml_dtd_42, docbook_xsl, w3m
, bash, getopt, makeWrapper }:

stdenv.mkDerivation rec {
  name = "xmlto-0.0.25";
  src = fetchurl {
    url = "http://fedorahosted.org/releases/x/m/xmlto/${name}.tar.bz2";
    sha256 = "0dp5nxq491gymq806za0dk4hngfmq65ysrqbn0ypajqbbl6vf71n";
  };

  patchPhase = ''
    substituteInPlace "xmlto.in" \
      --replace "/bin/bash" "${bash}/bin/bash"
    substituteInPlace "xmlto.in" \
      --replace "/usr/bin/locale" "$(type -P locale)"
    substituteInPlace "xmlto.in" \
      --replace "mktemp" "$(type -P mktemp)"
  '';

  # `libxml2' provides `xmllint', needed at build-time and run-time.
  # `libxslt' provides `xsltproc', used by `xmlto' at run-time.
  buildInputs = [ libxml2 libxslt docbook_xml_dtd_42 docbook_xsl getopt makeWrapper ];

  postInstall = ''
    wrapProgram "$out/bin/xmlto" \
       --prefix PATH : "${libxslt}/bin:${libxml2}/bin:${getopt}/bin"

    # `w3m' is needed for HTML to text conversions.
    substituteInPlace "$out/share/xmlto/format/docbook/txt" \
      --replace "/usr/bin/w3m" "${w3m}/bin/w3m"
  '';

  meta = {
    description = "xmlto, a front-end to an XSL toolchain";

    longDescription = ''
      xmlto is a front-end to an XSL toolchain.  It chooses an
      appropriate stylesheet for the conversion you want and applies
      it using an external XSL-T processor.  It also performs any
      necessary post-processing.
    '';

    license = stdenv.lib.licenses.gpl2Plus;
    homepage = https://fedorahosted.org/xmlto/;
  };
}