1{
2 lib,
3 stdenv,
4 buildPythonPackage,
5 fetchFromGitHub,
6
7 # build-system
8 setuptools,
9
10 # dependencies
11 spake2,
12 pynacl,
13 six,
14 attrs,
15 twisted,
16 autobahn,
17 automat,
18 tqdm,
19 click,
20 humanize,
21 iterable-io,
22 txtorcon,
23 zipstream-ng,
24
25 # optional-dependencies
26 noiseprotocol,
27
28 # tests
29 nettools,
30 unixtools,
31 magic-wormhole-transit-relay,
32 magic-wormhole-mailbox-server,
33 pytestCheckHook,
34}:
35
36buildPythonPackage rec {
37 pname = "magic-wormhole";
38 version = "0.17.0";
39 pyproject = true;
40
41 src = fetchFromGitHub {
42 owner = "magic-wormhole";
43 repo = "magic-wormhole";
44 rev = "refs/tags/${version}";
45 hash = "sha256-BxPF4iQ91wLBagdvQ/Y89VIZBkMxFiEHnK+BU55Bwr4=";
46 };
47
48 postPatch =
49 # enable tests by fixing the location of the wormhole binary
50 ''
51 substituteInPlace src/wormhole/test/test_cli.py --replace-fail \
52 'locations = procutils.which("wormhole")' \
53 'return "${placeholder "out"}/bin/wormhole"'
54 ''
55 # fix the location of the ifconfig binary
56 + lib.optionalString stdenv.hostPlatform.isLinux ''
57 sed -i -e "s|'ifconfig'|'${nettools}/bin/ifconfig'|" src/wormhole/ipaddrs.py
58 '';
59
60 build-system = [ setuptools ];
61
62 dependencies =
63 [
64 attrs
65 autobahn
66 automat
67 click
68 humanize
69 iterable-io
70 pynacl
71 six
72 spake2
73 tqdm
74 twisted
75 txtorcon
76 zipstream-ng
77 ]
78 ++ autobahn.optional-dependencies.twisted
79 ++ twisted.optional-dependencies.tls;
80
81 optional-dependencies = {
82 dilation = [ noiseprotocol ];
83 };
84
85 nativeCheckInputs =
86 [
87 magic-wormhole-mailbox-server
88 magic-wormhole-transit-relay
89 pytestCheckHook
90 ]
91 ++ optional-dependencies.dilation
92 ++ lib.optionals stdenv.hostPlatform.isDarwin [ unixtools.locale ];
93
94 __darwinAllowLocalNetworking = true;
95
96 postInstall = ''
97 install -Dm644 docs/wormhole.1 $out/share/man/man1/wormhole.1
98 '';
99
100 meta = {
101 changelog = "https://github.com/magic-wormhole/magic-wormhole/blob/${version}/NEWS.md";
102 description = "Securely transfer data between computers";
103 homepage = "https://github.com/magic-wormhole/magic-wormhole";
104 license = lib.licenses.mit;
105 maintainers = [ lib.maintainers.mjoerg ];
106 mainProgram = "wormhole";
107 };
108}