summary refs log tree commit diff
path: root/pkgs/applications/networking/instant-messengers/gajim/default.nix
blob: 42c510495574cdf179636394cc65c3e89cc319ab (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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
{ stdenv, fetchurl, autoreconfHook, python, intltool, pkgconfig, libX11
, ldns, pythonPackages

, enableJingle ? true, farstream ? null, gst-plugins-bad ? null
,                      libnice ? null
, enableE2E ? true
, enableRST ? true
, enableSpelling ? true, gtkspell2 ? null
, enableNotifications ? false
, enableOmemoPluginDependencies ? true
, extraPythonPackages ? pkgs: []
}:

assert enableJingle -> farstream != null && gst-plugins-bad != null
                    && libnice != null;
assert enableE2E -> pythonPackages.pycrypto != null;
assert enableRST -> pythonPackages.docutils != null;
assert enableSpelling -> gtkspell2 != null;
assert enableNotifications -> pythonPackages.notify != null;

with stdenv.lib;

stdenv.mkDerivation rec {
  name = "gajim-${version}";
  version = "0.16.9";

  src = fetchurl {
    name = "${name}.tar.bz2";
    url = "https://dev.gajim.org/gajim/gajim/repository/archive.tar.bz2?"
        + "ref=${name}";
    sha256 = "121dh906zya9n7npyk7b5xama0z3ycy9jl7l5jm39pc86h1winh3";
  };

  patches = let
    # An attribute set of revisions to apply from the upstream repository.
    cherries = {
      #example-fix = {
      #  rev = "<replace-with-git-revsion>";
      #  sha256 = "<replace-with-sha256>";
      #};
    };
  in (mapAttrsToList (name: { rev, sha256 }: fetchurl {
    name = "gajim-${name}.patch";
    url = "https://dev.gajim.org/gajim/gajim/commit/${rev}.diff";
    inherit sha256;
  }) cherries);

  postPatch = ''
    sed -i -e '0,/^[^#]/ {
      /^[^#]/i export \\\
        GST_PLUGIN_PATH="'"\$GST_PLUGIN_PATH''${GST_PLUGIN_PATH:+:}${""
        }$GST_PLUGIN_PATH"'"
    }' scripts/gajim.in

    # requires network access
    echo "" > test/integration/test_resolver.py

    # We want to run tests in installCheckPhase rather than checkPhase to test
    # whether the *installed* version of Gajim works rather than just whether it
    # works in the unpacked source tree.
    sed -i -e '/sys\.path\.insert.*gajim_root.*\/src/d' test/lib/__init__.py
  '' + optionalString enableSpelling ''
    sed -i -e 's|=.*find_lib.*|= "${gtkspell2}/lib/libgtkspell.so"|'   \
      src/gtkspell.py
  '';

  buildInputs = [
    python libX11
  ] ++ optionals enableJingle [ farstream gst-plugins-bad libnice ];

  nativeBuildInputs = [
    autoreconfHook pythonPackages.wrapPython intltool pkgconfig
  ];

  autoreconfPhase = ''
    sed -e 's/which/type -P/;s,\./configure,:,' autogen.sh | bash
  '';

  propagatedBuildInputs = with pythonPackages; [
    libasyncns
    pygobject2 pyGtkGlade
    pyasn1
    pyxdg
    nbxmpp
    pyopenssl dbus-python
  ] ++ optional enableE2E pythonPackages.pycrypto
    ++ optional enableRST pythonPackages.docutils
    ++ optional enableNotifications pythonPackages.notify
    ++ optionals enableOmemoPluginDependencies (with pythonPackages; [
      cryptography python-axolotl python-axolotl-curve25519 qrcode
    ]) ++ extraPythonPackages pythonPackages;

  postFixup = ''
    install -m 644 -t "$out/share/gajim/icons/hicolor" \
                      "icons/hicolor/index.theme"

    buildPythonPath "$out"

    for i in $out/bin/*; do
      name="$(basename "$i")"
      if [ "$name" = "gajim-history-manager" ]; then
        name="history_manager"
      fi

      patchPythonScript "$out/share/gajim/src/$name.py"
    done
  '';

  doInstallCheck = true;
  installCheckPhase = ''
    PYTHONPATH="test:$out/share/gajim/src:''${PYTHONPATH:+:}$PYTHONPATH" \
      make test_nogui
  '';

  enableParallelBuilding = true;

  meta = {
    homepage = http://gajim.org/;
    description = "Jabber client written in PyGTK";
    license = licenses.gpl3Plus;
    maintainers = [ maintainers.raskin maintainers.aszlig ];
    downloadPage = "http://gajim.org/downloads.php";
    updateWalker = true;
    platforms = stdenv.lib.platforms.linux;
  };
}