about summary refs log tree commit diff
path: root/nixpkgs/pkgs/applications/networking/p2p/deluge/default.nix
blob: dee7cde6fd3f134dbf054d8a9baab68b547ed81c (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
{ lib
, fetchurl
, intltool
, libtorrent-rasterbar
, python3Packages
, gtk3
, glib
, gobject-introspection
, librsvg
, wrapGAppsHook
}:

let
  inherit (lib) optionals;

  pypkgs = python3Packages;

  generic = { pname, withGUI }:
    pypkgs.buildPythonPackage rec {
      inherit pname;
      version = "2.1.1";

      src = fetchurl {
        url = "http://download.deluge-torrent.org/source/${lib.versions.majorMinor version}/deluge-${version}.tar.xz";
        hash = "sha256-do3TGYAuQkN6s3lOvnW0lxQuCO1bD7JQO61izvRC3/c=";
      };

      propagatedBuildInputs = with pypkgs; [
        twisted
        mako
        chardet
        pyxdg
        pyopenssl
        service-identity
        libtorrent-rasterbar.dev
        libtorrent-rasterbar.python
        setuptools
        setproctitle
        pillow
        rencode
        six
        zope_interface
        dbus-python
        pycairo
        librsvg
      ] ++ optionals withGUI [
        gtk3
        gobject-introspection
        pygobject3
      ];

      nativeBuildInputs = [
        intltool
        glib
      ] ++ optionals withGUI [
        gobject-introspection
        wrapGAppsHook
      ];

      nativeCheckInputs = with pypkgs; [
        pytestCheckHook
        pytest-twisted
        pytest-cov
        mock
        mccabe
        pylint
      ];

      doCheck = false; # tests are not working at all

      postInstall = ''
        install -Dm444 -t $out/lib/systemd/system packaging/systemd/*.service
      '' + (if withGUI
      then ''
        mkdir -p $out/share
        cp -R deluge/ui/data/{icons,pixmaps} $out/share/
        install -Dm444 -t $out/share/applications deluge/ui/data/share/applications/deluge.desktop
      '' else ''
        rm -r $out/bin/deluge-gtk
        rm -r $out/lib/${python3Packages.python.libPrefix}/site-packages/deluge/ui/gtk3
        rm -r $out/share/{icons,man/man1/deluge-gtk*,pixmaps}
      '');

      postFixup = ''
        for f in $out/lib/systemd/system/*; do
          substituteInPlace $f --replace /usr/bin $out/bin
        done
      '';

      meta = with lib; {
        description = "Torrent client";
        homepage = "https://deluge-torrent.org";
        license = licenses.gpl3Plus;
        maintainers = with maintainers; [ domenkozar ebzzry ];
        platforms = platforms.all;
      };
    };

in
rec {
  deluge-gtk = generic { pname = "deluge-gtk"; withGUI = true; };
  deluged = generic { pname = "deluged"; withGUI = false; };
  deluge = deluge-gtk;
}