summary refs log tree commit diff
path: root/pkgs/applications/networking/instant-messengers/tkabber/default.nix
blob: 8b6b3893311eb3faadb2350b37fe6ee6dbd061ba (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
{ stdenv, fetchurl, tcl, tk, tcllib, tcltls, tclgpg
, bwidget, makeWrapper, x11
, withSitePlugins ? true
, theme ? null
}:

with stdenv.lib;

let
  version = "1.0";

  main = {
    name = "tkabber";
    sha256 = "49ee6e897dfe52ebac256531b54955e6b39223f606a9b8ad63a52475389db206";
  };

  plugins = {
    name = "tkabber-plugins";
    sha256 = "d61251dc664f0bfa8534e578096dede9a7bb7d4f2620489f8d2c43d36cd61ba9";
  };

  tclLibraries = [ bwidget tcllib tcltls tclgpg ];

  getTclLibPath = p: "${p}/lib/${p.libPrefix}";

  tclLibPaths = stdenv.lib.concatStringsSep " "
    (map getTclLibPath tclLibraries);

  mkTkabber = attrs: stdenv.mkDerivation (rec {
    name = "${attrs.name}-${version}";

    src = fetchurl {
      url = "http://files.jabber.ru/tkabber/${name}.tar.xz";
      inherit (attrs) sha256;
    };

    prePatch = ''
      sed -e "s@/usr/local@$out@" -i Makefile
    '';
  } // removeAttrs attrs [ "name" "sha256" ]);

in mkTkabber (main // {
  postPatch = ''
    substituteInPlace login.tcl --replace \
      "custom::defvar loginconf(sslcacertstore) \"\"" \
      "custom::defvar loginconf(sslcacertstore) \$env(OPENSSL_X509_CERT_FILE)"
  '' + optionalString (theme != null) ''
    themePath="$out/share/doc/tkabber/examples/xrdb/${theme}.xrdb"
    sed -i '/^if.*load_default_xrdb/,/^}$/ {
      s@option readfile \(\[fullpath [^]]*\]\)@option readfile "'"$themePath"'"@
    }' tkabber.tcl
  '';

  postInstall = ''
    for prog in $out/bin/*; do
      wrapProgram "$prog" \
        --prefix PATH : "${tk}/bin" \
        --set TCLLIBPATH '"${tclLibPaths}"' \
        ${optionalString withSitePlugins ''
        --set TKABBER_SITE_PLUGINS '${mkTkabber plugins}/share/tkabber-plugins'
        ''}
    done
  '';

  buildInputs = [ tcl tk x11 makeWrapper ] ++ tclLibraries;

  meta = {
    homepage = "http://tkabber.jabber.ru/";
    description = "A GUI XMPP (Jabber) client written in Tcl/Tk";
    license = stdenv.lib.licenses.gpl2;
  };
})