summary refs log tree commit diff
path: root/pkgs/tools/text/unoconv/default.nix
blob: 879f903ade975bf16071c6b451b14b94c76fc7f7 (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
{ stdenv, fetchurl, python3, libreoffice-unwrapped, asciidoc, makeWrapper
# whether to install odt2pdf/odt2doc/... symlinks to unoconv
, installSymlinks ? true
}:

# IMPORTANT: unoconv must use the same python version as libreoffice (unless it
# will not be able to load the pyuno module from libreoffice).

stdenv.mkDerivation rec {
  name = "unoconv-0.6";

  src = fetchurl {
    url = "http://dag.wieers.com/home-made/unoconv/${name}.tar.gz";
    sha256 = "1m3kv942zf5rzyrbkil0nhmyq9mm3007y64bb3s7w88mhr5n23kr";
  };

  buildInputs = [ asciidoc makeWrapper ];

  # We need to use python3 because libreoffice 4.x uses it. This patch comes
  # from unoconv.git, so it will be a part of the next release.
  patches = [ ./unoconv-python3.patch ];

  preBuild = ''
    makeFlags=prefix="$out"
  '';

  postInstall = ''
    sed -i "s|/usr/bin/env python.*|${python3}/bin/${python3.executable}|" "$out/bin/unoconv"
    wrapProgram "$out/bin/unoconv" --set UNO_PATH "${libreoffice-unwrapped}/lib/libreoffice/program/"
  '' + (if installSymlinks then ''
    make install-links prefix="$out"
  '' else "");

  meta = with stdenv.lib; {
    description = "Convert between any document format supported by LibreOffice/OpenOffice";
    homepage = http://dag.wieers.com/home-made/unoconv/;
    license = licenses.gpl2;
    platforms = platforms.linux;
    maintainers = [ maintainers.bjornfor ];
  };
}