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