1{ 2 lib, 3 stdenv, 4 fetchFromGitHub, 5 buildPythonPackage, 6 pythonOlder, 7 pythonRelaxDepsHook, 8 # Mitmproxy requirements 9 aioquic, 10 asgiref, 11 blinker, 12 brotli, 13 certifi, 14 cryptography, 15 flask, 16 h11, 17 h2, 18 hyperframe, 19 kaitaistruct, 20 ldap3, 21 mitmproxy-macos, 22 mitmproxy-rs, 23 msgpack, 24 passlib, 25 protobuf, 26 publicsuffix2, 27 pyopenssl, 28 pyparsing, 29 pyperclip, 30 ruamel-yaml, 31 setuptools, 32 sortedcontainers, 33 tornado, 34 urwid-mitmproxy, 35 wsproto, 36 zstandard, 37 # Additional check requirements 38 hypothesis, 39 parver, 40 pytest-asyncio, 41 pytest-timeout, 42 pytest-xdist, 43 pytestCheckHook, 44 requests, 45}: 46 47buildPythonPackage rec { 48 pname = "mitmproxy"; 49 version = "10.3.0"; 50 pyproject = true; 51 52 disabled = pythonOlder "3.9"; 53 54 src = fetchFromGitHub { 55 owner = "mitmproxy"; 56 repo = "mitmproxy"; 57 rev = "refs/tags/${version}"; 58 hash = "sha256-YjvGsnpQQ8GWLyKmnd3lOxesnr+F2xCNXyahZh0JQnc="; 59 }; 60 61 nativeBuildInputs = [ pythonRelaxDepsHook ]; 62 63 pythonRelaxDeps = [ 64 "aioquic" 65 "cryptography" 66 ]; 67 68 propagatedBuildInputs = [ 69 aioquic 70 asgiref 71 blinker 72 brotli 73 certifi 74 cryptography 75 flask 76 h11 77 h2 78 hyperframe 79 kaitaistruct 80 ldap3 81 mitmproxy-rs 82 msgpack 83 passlib 84 protobuf 85 publicsuffix2 86 pyopenssl 87 pyparsing 88 pyperclip 89 ruamel-yaml 90 setuptools 91 sortedcontainers 92 tornado 93 urwid-mitmproxy 94 wsproto 95 zstandard 96 ] ++ lib.optionals stdenv.isDarwin [ mitmproxy-macos ]; 97 98 nativeCheckInputs = [ 99 hypothesis 100 parver 101 pytest-asyncio 102 pytest-timeout 103 pytest-xdist 104 pytestCheckHook 105 requests 106 ]; 107 108 __darwinAllowLocalNetworking = true; 109 110 preCheck = '' 111 export HOME=$(mktemp -d) 112 ''; 113 114 disabledTests = [ 115 # Tests require a git repository 116 "test_get_version" 117 # https://github.com/mitmproxy/mitmproxy/commit/36ebf11916704b3cdaf4be840eaafa66a115ac03 118 # Tests require terminal 119 "test_commands_exist" 120 "test_contentview_flowview" 121 "test_flowview" 122 "test_get_hex_editor" 123 "test_integration" 124 "test_spawn_editor" 125 "test_statusbar" 126 # FileNotFoundError: [Errno 2] No such file or directory 127 # likely wireguard is also not working in the sandbox 128 "test_wireguard" 129 ]; 130 131 dontUsePytestXdist = true; 132 133 pythonImportsCheck = [ "mitmproxy" ]; 134 135 meta = with lib; { 136 description = "Man-in-the-middle proxy"; 137 homepage = "https://mitmproxy.org/"; 138 changelog = "https://github.com/mitmproxy/mitmproxy/blob/${version}/CHANGELOG.md"; 139 license = licenses.mit; 140 maintainers = with maintainers; [ SuperSandro2000 ]; 141 }; 142}