aboutsummaryrefslogtreecommitdiff
path: root/nixpkgs/pkgs/applications/networking/irc/weechat/scripts/weechat-otr/default.nix
blob: c7f2958cf55369a471794942a8add308683181b0 (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
65
66
67
68
69
70
{ stdenv, substituteAll, buildEnv, fetchgit, fetchFromGitHub, python3Packages, gmp }:

let
  # pure-python-otr (potr) requires an older version of pycrypto, which is
  # not compatible with pycryptodome. Therefore, the latest patched version
  # of pycrypto will be fetched from the Debian project.
  # https://security-tracker.debian.org/tracker/source-package/python-crypto

  pycrypto = python3Packages.buildPythonPackage rec {
    pname = "pycrypto";
    version = "2.6.1-13.1";

    src = fetchgit {
      url = "https://salsa.debian.org/sramacher/python-crypto.git";
      rev = "debian/${version}";
      sha256 = "1mahqmlgilgk0rn5hfkhza7kscfm7agdakkb6rqnif9g0qp3s52f";
    };

    postPatch = ''
      for p in debian/patches/*.patch; do
        patch -p1 < "$p"
      done
    '';

    buildInputs = [ gmp ];

    preConfigure = ''
      sed -i 's,/usr/include,/no-such-dir,' configure
      sed -i "s!,'/usr/include/'!!" setup.py
    '';
  };

  potr = python3Packages.potr.overridePythonAttrs (oldAttrs: {
    propagatedBuildInputs = [ pycrypto ];
  });
in stdenv.mkDerivation rec {
  pname = "weechat-otr";
  version = "1.9.2";

  src = fetchFromGitHub {
    repo = pname;
    owner = "mmb";
    rev = "v${version}";
    sha256 = "1lngv98y6883vk8z2628cl4d5y8jxy39w8245gjdvshl8g18k5s2";
  };

  patches = [
    (substituteAll {
      src = ./libpath.patch;
      env = "${buildEnv {
        name = "weechat-otr-env";
        paths = [ potr pycrypto ];
      }}/${python3Packages.python.sitePackages}";
    })
  ];

  passthru.scripts = [ "weechat_otr.py" ];

  installPhase = ''
    mkdir -p $out/share
    cp weechat_otr.py $out/share/weechat_otr.py
  '';

  meta = with stdenv.lib; {
    homepage = "https://github.com/mmb/weechat-otr";
    license = licenses.gpl3;
    maintainers = with maintainers; [ oxzi ];
    description = "WeeChat script for Off-the-Record messaging";
  };
}