1{ lib
2, fetchFromGitHub
3, fetchpatch
4, buildPythonPackage
5, pythonOlder
6 # Mitmproxy requirements
7, asgiref
8, blinker
9, brotli
10, certifi
11, click
12, cryptography
13, flask
14, h11
15, h2
16, hyperframe
17, kaitaistruct
18, ldap3
19, msgpack
20, passlib
21, protobuf
22, publicsuffix2
23, pyopenssl
24, pyparsing
25, pyperclip
26, ruamel-yaml
27, setuptools
28, sortedcontainers
29, tornado
30, urwid
31, wsproto
32, zstandard
33 # Additional check requirements
34, hypothesis
35, parver
36, pytest-asyncio
37, pytest-timeout
38, pytest-xdist
39, pytestCheckHook
40, requests
41}:
42
43buildPythonPackage rec {
44 pname = "mitmproxy";
45 version = "8.1.1";
46 disabled = pythonOlder "3.8";
47
48 src = fetchFromGitHub {
49 owner = pname;
50 repo = pname;
51 rev = "refs/tags/v${version}";
52 sha256 = "sha256-nW/WfiY6uF67qNa95tvNvSv/alP2WmzTk34LEBma/04=";
53 };
54
55 patches = [
56 # Fix onboarding addon tests failing with Flask >= v2.2
57 (fetchpatch {
58 url = "https://github.com/mitmproxy/mitmproxy/commit/bc370276a19c1d1039e7a45ecdc23c362626c81a.patch";
59 hash = "sha256-Cp7RnYpZEuRhlWYOk8BOnAKBAUa7Vy296UmQi3/ufes=";
60 })
61 ];
62
63 propagatedBuildInputs = [
64 setuptools
65 # setup.py
66 asgiref
67 blinker
68 brotli
69 certifi
70 click
71 cryptography
72 flask
73 h11
74 h2
75 hyperframe
76 kaitaistruct
77 ldap3
78 msgpack
79 passlib
80 protobuf
81 publicsuffix2
82 pyopenssl
83 pyparsing
84 pyperclip
85 ruamel-yaml
86 sortedcontainers
87 tornado
88 urwid
89 wsproto
90 zstandard
91 ];
92
93 checkInputs = [
94 hypothesis
95 parver
96 pytest-asyncio
97 pytest-timeout
98 pytest-xdist
99 pytestCheckHook
100 requests
101 ];
102
103 postPatch = ''
104 # remove dependency constraints
105 sed 's/>=\([0-9]\.\?\)\+\( \?, \?<\([0-9]\.\?\)\+\)\?\( \?, \?!=\([0-9]\.\?\)\+\)\?//' -i setup.py
106 '';
107
108 preCheck = ''
109 export HOME=$(mktemp -d)
110 '';
111
112 disabledTests = [
113 # Tests require a git repository
114 "test_get_version"
115 # https://github.com/mitmproxy/mitmproxy/commit/36ebf11916704b3cdaf4be840eaafa66a115ac03
116 # Tests require terminal
117 "test_integration"
118 "test_contentview_flowview"
119 "test_flowview"
120 # ValueError: Exceeds the limit (4300) for integer string conversion
121 "test_roundtrip_big_integer"
122 ];
123 dontUsePytestXdist = true;
124
125 pythonImportsCheck = [ "mitmproxy" ];
126
127 meta = with lib; {
128 description = "Man-in-the-middle proxy";
129 homepage = "https://mitmproxy.org/";
130 license = licenses.mit;
131 maintainers = with maintainers; [ kamilchm SuperSandro2000 ];
132 };
133}