1{
2 lib,
3 fetchurl,
4 intltool,
5 libtorrent-rasterbar,
6 python3Packages,
7 gtk3,
8 glib,
9 gobject-introspection,
10 librsvg,
11 wrapGAppsHook3,
12 nixosTests,
13}:
14
15let
16 inherit (lib) optionals;
17
18 pypkgs = python3Packages;
19
20 generic =
21 { pname, withGUI }:
22 pypkgs.buildPythonPackage rec {
23 inherit pname;
24 version = "2.2.0";
25 format = "setuptools";
26
27 src = fetchurl {
28 url = "http://download.deluge-torrent.org/source/${lib.versions.majorMinor version}/deluge-${version}.tar.xz";
29 hash = "sha256-ubonK1ukKq8caU5sKWKKuBbMGnAKN7rAiqy1JXFgas0=";
30 };
31
32 propagatedBuildInputs =
33 with pypkgs;
34 [
35 twisted
36 mako
37 chardet
38 pyxdg
39 pyopenssl
40 service-identity
41 libtorrent-rasterbar.dev
42 libtorrent-rasterbar.python
43 setuptools
44 setproctitle
45 pillow
46 rencode
47 six
48 zope-interface
49 dbus-python
50 pycairo
51 librsvg
52 ]
53 ++ optionals withGUI [
54 gtk3
55 gobject-introspection
56 pygobject3
57 ];
58
59 nativeBuildInputs = [
60 intltool
61 glib
62 ]
63 ++ optionals withGUI [
64 gobject-introspection
65 wrapGAppsHook3
66 ];
67
68 nativeCheckInputs = with pypkgs; [
69 pytestCheckHook
70 pytest-twisted
71 pytest-cov-stub
72 mock
73 mccabe
74 pylint
75 ];
76
77 doCheck = false; # tests are not working at all
78
79 postInstall = ''
80 install -Dm444 -t $out/lib/systemd/system packaging/systemd/*.service
81 ''
82 + (
83 if withGUI then
84 ''
85 mkdir -p $out/share
86 cp -R deluge/ui/data/{icons,pixmaps} $out/share/
87 install -Dm444 -t $out/share/applications deluge/ui/data/share/applications/deluge.desktop
88 ''
89 else
90 ''
91 rm -r $out/bin/deluge-gtk
92 rm -r $out/${python3Packages.python.sitePackages}/deluge/ui/gtk3
93 rm -r $out/share/{icons,man/man1/deluge-gtk*,pixmaps}
94 ''
95 );
96
97 postFixup = ''
98 for f in $out/lib/systemd/system/*; do
99 substituteInPlace $f --replace /usr/bin $out/bin
100 done
101 '';
102
103 passthru.tests = { inherit (nixosTests) deluge; };
104
105 meta = with lib; {
106 description = "Torrent client";
107 homepage = "https://deluge-torrent.org";
108 license = licenses.gpl3Plus;
109 maintainers = with maintainers; [
110 ebzzry
111 ];
112 platforms = platforms.all;
113 };
114 };
115
116in
117rec {
118 deluge-gtk = generic {
119 pname = "deluge-gtk";
120 withGUI = true;
121 };
122 deluged = generic {
123 pname = "deluged";
124 withGUI = false;
125 };
126 deluge = deluge-gtk;
127}