Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{
2 lib,
3 aioquic,
4 argon2-cffi,
5 asgiref,
6 bcrypt,
7 brotli,
8 buildPythonPackage,
9 certifi,
10 cryptography,
11 fetchFromGitHub,
12 flask,
13 h11,
14 h2,
15 hyperframe,
16 hypothesis,
17 kaitaistruct,
18 ldap3,
19 mitmproxy-rs,
20 msgpack,
21 nixosTests,
22 publicsuffix2,
23 pyopenssl,
24 pyparsing,
25 pyperclip,
26 pytest-asyncio,
27 pytest-timeout,
28 pytest-xdist,
29 pytestCheckHook,
30 requests,
31 ruamel-yaml,
32 setuptools,
33 sortedcontainers,
34 tornado,
35 urwid,
36 wsproto,
37 zstandard,
38}:
39
40buildPythonPackage rec {
41 pname = "mitmproxy";
42 version = "12.2.1";
43 pyproject = true;
44
45 src = fetchFromGitHub {
46 owner = "mitmproxy";
47 repo = "mitmproxy";
48 tag = "v${version}";
49 hash = "sha256-z3JJOql4JacXSeo6dRbKOaL+kLlSnpKQkeXzZdzLQJo=";
50 };
51
52 pythonRelaxDeps = [
53 "zstandard"
54
55 # requested by maintainer
56 "brotli"
57 # just keep those
58 "typing-extensions"
59 ];
60
61 build-system = [ setuptools ];
62
63 dependencies = [
64 aioquic
65 argon2-cffi
66 asgiref
67 brotli
68 bcrypt
69 certifi
70 cryptography
71 flask
72 h11
73 h2
74 hyperframe
75 kaitaistruct
76 ldap3
77 mitmproxy-rs
78 msgpack
79 publicsuffix2
80 pyopenssl
81 pyparsing
82 pyperclip
83 ruamel-yaml
84 sortedcontainers
85 tornado
86 urwid
87 wsproto
88 zstandard
89 ];
90
91 nativeCheckInputs = [
92 hypothesis
93 pytest-asyncio
94 pytest-timeout
95 pytest-xdist
96 pytestCheckHook
97 requests
98 ];
99
100 __darwinAllowLocalNetworking = true;
101
102 preCheck = ''
103 export HOME=$(mktemp -d)
104 '';
105
106 disabledTests = [
107 # Tests require a git repository
108 "test_get_version"
109 # https://github.com/mitmproxy/mitmproxy/commit/36ebf11916704b3cdaf4be840eaafa66a115ac03
110 # Tests require terminal
111 "test_commands_exist"
112 "test_contentview_flowview"
113 "test_flowview"
114 "test_get_hex_editor"
115 "test_integration"
116 "test_spawn_editor"
117 "test_statusbar"
118 # FileNotFoundError: [Errno 2] No such file or directory
119 # likely wireguard is also not working in the sandbox
120 "test_tun_mode"
121 "test_wireguard"
122 # test require a DNS server
123 # RuntimeError: failed to get dns servers: io error: entity not found
124 "test_errorcheck"
125 "test_errorcheck"
126 "test_dns"
127 "test_order"
128 # fails in pytest asyncio internals
129 "test_decorator"
130 "test_exception_handler"
131 ];
132
133 disabledTestPaths = [
134 # test require a DNS server
135 # RuntimeError: failed to get dns servers: io error: entity not found
136 "test/mitmproxy/addons/test_dns_resolver.py"
137 "test/mitmproxy/tools/test_dump.py"
138 "test/mitmproxy/tools/test_main.py"
139 "test/mitmproxy/tools/web/test_app.py"
140 "test/mitmproxy/tools/web/test_app.py" # 2 out of 31 tests work
141 "test/mitmproxy/tools/web/test_master.py"
142 ];
143
144 dontUsePytestXdist = true;
145
146 pythonImportsCheck = [ "mitmproxy" ];
147
148 passthru.tests = {
149 inherit (nixosTests) mitmproxy;
150 };
151
152 meta = {
153 description = "Man-in-the-middle proxy";
154 homepage = "https://mitmproxy.org/";
155 changelog = "https://github.com/mitmproxy/mitmproxy/blob/${src.tag}/CHANGELOG.md";
156 license = lib.licenses.mit;
157 maintainers = with lib.maintainers; [ SuperSandro2000 ];
158 mainProgram = "mitmproxy";
159 };
160}