summaryrefslogtreecommitdiffstats
path: root/pkgs/by-name/it/itstool/package.nix
blob: 1244e0cb1728320b619cdef3d8a691cd3d360993 (plain)
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
{
  stdenv,
  lib,
  fetchurl,
  fetchpatch,
  python3,
  autoreconfHook,
  versionCheckHook,
}:

stdenv.mkDerivation (finalAttrs: {
  pname = "itstool";
  version = "2.0.7";

  src = fetchurl {
    url = "https://files.itstool.org/itstool/itstool-${finalAttrs.version}.tar.bz2";
    hash = "sha256-a5p80poSu5VZj1dQ6HY87niDahogf4W3TYsydbJ+h8o=";
  };

  patches = [
    # https://github.com/itstool/itstool/pull/51
    (fetchpatch {
      name = "fix-insufficiently-quoted-regular-expressions-pr51";
      url = "https://github.com/itstool/itstool/commit/19f9580f27aa261ea383b395fdef7e153f3f9e6d.patch";
      hash = "sha256-5J4mRXQu24o2rqVtaXN/ETgj6A8R0Ym+YkZhqhZTzIc=";
    })
  ];

  strictDeps = true;

  postPatch = ''
    # Do not let autoconf find Python, but set it directly. This fixes cross-compilation.
    substituteInPlace configure.ac \
      --replace-fail 'AM_PATH_PYTHON([2.6])' "" \
      --replace-fail 'AC_MSG_ERROR(Python module $py_module is needed to run this package)' ""
    substituteInPlace itstool.in \
      --replace-fail "@PYTHON@" "${python3.interpreter}"
  '';

  nativeBuildInputs = [
    autoreconfHook
    python3.pkgs.wrapPython
  ];

  pythonPath = [
    python3.pkgs.libxml2
  ];

  postFixup = ''
    wrapPythonPrograms
  '';

  nativeInstallCheckInputs = [ versionCheckHook ];
  doInstallCheck = true;

  meta = {
    homepage = "https://itstool.org/";
    description = "XML to PO and back again";
    mainProgram = "itstool";
    license = lib.licenses.gpl3Plus;
    platforms = lib.platforms.all;
    maintainers = [ ];
  };
})