diff --git a/pkgs/fetchPipMetadata/aioquic-mitmproxy.nix b/pkgs/fetchPipMetadata/aioquic-mitmproxy.nix new file mode 100644 index 00000000..3a82b78a --- /dev/null +++ b/pkgs/fetchPipMetadata/aioquic-mitmproxy.nix @@ -0,0 +1,58 @@ +{ + lib, + buildPythonPackage, + certifi, + cryptography, + fetchFromGitHub, + pylsqpack, + pyopenssl, + pytestCheckHook, + pythonOlder, + service-identity, + setuptools, + wheel, +}: +buildPythonPackage rec { + pname = "aioquic-mitmproxy"; + version = "0.9.21.1"; + pyproject = true; + + disabled = pythonOlder "3.8"; + + src = fetchFromGitHub { + owner = "meitinger"; + repo = "aioquic_mitmproxy"; + rev = "refs/tags/${version}"; + hash = "sha256-eD3eICE9jS1jyqMgWwcv6w3gkR0EyGcKwgSXhasXNeA="; + }; + + nativeBuildInputs = [ + setuptools + wheel + ]; + + propagatedBuildInputs = [ + certifi + cryptography + pylsqpack + pyopenssl + service-identity + ]; + + nativeCheckInputs = [ + pytestCheckHook + ]; + + pythonImportsCheck = [ + "aioquic" + ]; + + doCheck = false; + + meta = with lib; { + description = "QUIC and HTTP/3 implementation in Python"; + homepage = "https://github.com/meitinger/aioquic_mitmproxy"; + license = licenses.bsd3; + maintainers = with maintainers; [fab]; + }; +} diff --git a/pkgs/fetchPipMetadata/mitmproxy.nix b/pkgs/fetchPipMetadata/mitmproxy.nix new file mode 100644 index 00000000..ed76da86 --- /dev/null +++ b/pkgs/fetchPipMetadata/mitmproxy.nix @@ -0,0 +1,153 @@ +{ + lib, + stdenv, + fetchFromGitHub, + buildPythonPackage, + pythonOlder, + # Mitmproxy requirements + aioquic-mitmproxy, + asgiref, + blinker, + brotli, + certifi, + cryptography, + flask, + h11, + h2, + hyperframe, + kaitaistruct, + ldap3, + mitmproxy-macos, + mitmproxy-rs, + msgpack, + passlib, + protobuf, + publicsuffix2, + pyopenssl, + pyparsing, + pyperclip, + ruamel-yaml, + setuptools, + sortedcontainers, + tornado, + urwid-mitmproxy, + wsproto, + zstandard, + # Additional check requirements + hypothesis, + parver, + pytest-asyncio, + pytest-timeout, + pytest-xdist, + pytestCheckHook, + requests, + pythonRelaxDepsHook, +}: +buildPythonPackage rec { + pname = "mitmproxy"; + version = "10.1.6"; + pyproject = true; + + disabled = pythonOlder "3.9"; + + src = fetchFromGitHub { + owner = "mitmproxy"; + repo = "mitmproxy"; + rev = "refs/tags/${version}"; + hash = "sha256-W+gxK5bNCit1jK9ojwE/HVjUz6OJcNw6Ac1lN5FxGgw="; + }; + + pythonRelaxDeps = [ + "pyopenssl" + "cryptography" + ]; + + nativeBuildInputs = [ + pythonRelaxDepsHook + ]; + + propagatedBuildInputs = + [ + aioquic-mitmproxy + asgiref + blinker + brotli + certifi + cryptography + flask + h11 + h2 + hyperframe + kaitaistruct + ldap3 + mitmproxy-rs + msgpack + passlib + protobuf + publicsuffix2 + pyopenssl + pyparsing + pyperclip + ruamel-yaml + setuptools + sortedcontainers + tornado + urwid-mitmproxy + wsproto + zstandard + ] + ++ lib.optionals stdenv.isDarwin [ + mitmproxy-macos + ]; + + nativeCheckInputs = [ + hypothesis + parver + pytest-asyncio + pytest-timeout + pytest-xdist + pytestCheckHook + requests + ]; + + __darwinAllowLocalNetworking = true; + + preCheck = '' + export HOME=$(mktemp -d) + ''; + + disabledTests = [ + # Tests require a git repository + "test_get_version" + # https://github.com/mitmproxy/mitmproxy/commit/36ebf11916704b3cdaf4be840eaafa66a115ac03 + # Tests require terminal + "test_integration" + "test_contentview_flowview" + "test_flowview" + # ValueError: Exceeds the limit (4300) for integer string conversion + "test_roundtrip_big_integer" + "test_wireguard" + "test_commands_exist" + "test_statusbar" + # AssertionError: Playbook mismatch! + "test_untrusted_cert" + "test_mitmproxy_ca_is_untrusted" + ]; + + disabledTestPaths = [ + # teardown of half the tests broken + "test/mitmproxy/addons/test_onboarding.py" + ]; + + dontUsePytestXdist = true; + + pythonImportsCheck = ["mitmproxy"]; + + meta = with lib; { + description = "Man-in-the-middle proxy"; + homepage = "https://mitmproxy.org/"; + changelog = "https://github.com/mitmproxy/mitmproxy/blob/${version}/CHANGELOG.md"; + license = licenses.mit; + maintainers = with maintainers; [kamilchm SuperSandro2000]; + }; +} diff --git a/pkgs/fetchPipMetadata/script.nix b/pkgs/fetchPipMetadata/script.nix index 8dc3594b..0a02fa24 100644 --- a/pkgs/fetchPipMetadata/script.nix +++ b/pkgs/fetchPipMetadata/script.nix @@ -64,18 +64,30 @@ [17:42:11.909][[::1]:56958] server connect pypi.org:443 (151.101.64.223:443) [17:42:11.958] Deferring layer decision, not enough data: [...] */ - mitmproxy = prev.mitmproxy.overridePythonAttrs (old: rec { - version = "10.1.6"; - src = fetchFromGitHub { - owner = "mitmproxy"; - repo = "mitmproxy"; - rev = "refs/tags/${version}"; - hash = "sha256-W+gxK5bNCit1jK9ojwE/HVjUz6OJcNw6Ac1lN5FxGgw="; - }; - doCheck = false; - pyproject = true; - # format = "pyproject"; - }); + + aioquic-mitmproxy = curr.callPackage ./aioquic-mitmproxy.nix {}; + urwid-mitmproxy = curr.callPackage ./urwid-mitmproxy.nix {}; + + mitmproxy = curr.callPackage ./mitmproxy.nix {}; + + # mitmproxy = prev.mitmproxy.overridePythonAttrs (old: rec { + # version = "10.1.6"; + # src = fetchFromGitHub { + # owner = "mitmproxy"; + # repo = "mitmproxy"; + # rev = "refs/tags/${version}"; + # hash = "sha256-W+gxK5bNCit1jK9ojwE/HVjUz6OJcNw6Ac1lN5FxGgw="; + # }; + # doCheck = false; + # pyproject = true; + # pythonRelaxDeps = [ + # "pyopenssl" + # "cryptography" + # ]; + # propagatedBuildInputs = [ + # curr.aioquic-mitmproxy + # ]; + # }); mitmproxy-rs = prev.mitmproxy-rs.overrideAttrs (old: rec { version = "0.4.1"; src = fetchFromGitHub { diff --git a/pkgs/fetchPipMetadata/urwid-mitmproxy.nix b/pkgs/fetchPipMetadata/urwid-mitmproxy.nix new file mode 100644 index 00000000..15ac449b --- /dev/null +++ b/pkgs/fetchPipMetadata/urwid-mitmproxy.nix @@ -0,0 +1,37 @@ +{ + lib, + buildPythonPackage, + fetchFromGitHub, + fetchpatch, + glibcLocales, + pythonOlder, + unittestCheckHook, +}: +buildPythonPackage rec { + pname = "urwid-mitmproxy"; + version = "2.1.2.1"; + format = "setuptools"; + + disabled = pythonOlder "3.7"; + + src = fetchFromGitHub { + owner = "mitmproxy"; + repo = "urwid-mitmproxy"; + rev = "refs/tags/${version}"; + hash = "sha256-93AauYWbrG/2smAhbNKGE0twGJZ2u9gBetlXGCpciH8="; + }; + + pythonImportsCheck = [ + "urwid" + ]; + + # Tests which assert on strings don't decode results correctly, see urwid + doCheck = false; + + meta = with lib; { + description = "Urwid fork used by mitmproxy"; + homepage = "https://github.com/mitmproxy/urwid-mitmproxy"; + license = licenses.lgpl21Plus; + maintainers = with maintainers; [fab]; + }; +}