1{ lib
2, buildPythonPackage
3, fetchPypi
4, pythonAtLeast
5, python
6, spake2
7, pynacl
8, six
9, attrs
10, twisted
11, autobahn
12, automat
13, hkdf
14, tqdm
15, click
16, humanize
17, ipaddress
18, txtorcon
19, nettools
20, glibc
21, glibcLocales
22, mock
23, magic-wormhole-transit-relay
24}:
25
26buildPythonPackage rec {
27 pname = "magic-wormhole";
28 version = "0.10.5";
29
30 src = fetchPypi {
31 inherit pname version;
32 sha256 = "9558ea1f3551e535deec3462cd5c8391cb32ebb12ecd8b40b36861dbee4917ee";
33 };
34
35 checkInputs = [ mock magic-wormhole-transit-relay ];
36 buildInputs = [ nettools glibcLocales ];
37 propagatedBuildInputs = [ spake2 pynacl six attrs twisted autobahn automat hkdf tqdm click humanize ipaddress txtorcon ];
38
39 postPatch = ''
40 sed -i -e "s|'ifconfig'|'${nettools}/bin/ifconfig'|" src/wormhole/ipaddrs.py
41 sed -i -e "s|if (os.path.dirname(os.path.abspath(wormhole))|if not os.path.abspath(wormhole).startswith('/nix/store') and (os.path.dirname(os.path.abspath(wormhole))|" src/wormhole/test/test_cli.py
42
43 # magic-wormhole will attempt to find all available locales by running
44 # 'locale -a'. If we're building on Linux, then this may result in us
45 # running the system's locale binary instead of the one from Nix, so let's
46 # ensure we patch this.
47 sed -i -e 's|getProcessOutputAndValue("locale"|getProcessOutputAndValue("${glibc}/bin/locale"|' src/wormhole/test/test_cli.py
48 '' + lib.optionalString (pythonAtLeast "3.3") ''
49 sed -i -e 's|"ipaddress",||' setup.py
50 '';
51
52 checkPhase = ''
53 export PATH="$PATH:$out/bin"
54 export LANG="en_US.UTF-8"
55 export LC_ALL="en_US.UTF-8"
56 ${python.interpreter} -m wormhole.test.run_trial wormhole
57 '';
58
59 meta = with lib; {
60 description = "Securely transfer data between computers";
61 homepage = https://github.com/warner/magic-wormhole;
62 license = licenses.mit;
63 maintainers = with maintainers; [ asymmetric ];
64 };
65}