1{
2 lib,
3 stdenv,
4 buildPythonPackage,
5 fetchFromGitHub,
6 mitmproxy,
7 mitmproxy-linux,
8 mitmproxy-macos,
9 rustPlatform,
10}:
11
12buildPythonPackage rec {
13 pname = "mitmproxy-rs";
14 version = "0.12.7";
15 pyproject = true;
16
17 src = fetchFromGitHub {
18 owner = "mitmproxy";
19 repo = "mitmproxy_rs";
20 tag = "v${version}";
21 hash = "sha256-Wd/4XzSMQ3qgacFUlxReQFyonUbTqWKDCk3m+kWhXy0=";
22 };
23
24 buildAndTestSubdir = "mitmproxy-rs";
25
26 cargoDeps = rustPlatform.fetchCargoVendor {
27 inherit pname version src;
28 hash = "sha256-Q5EBI5uXJgbI9NMblkTT/GweopnTr/zUG35i+Aoe3QA=";
29 };
30
31 nativeBuildInputs = [
32 rustPlatform.cargoSetupHook
33 rustPlatform.maturinBuildHook
34 ];
35
36 dependencies =
37 lib.optionals stdenv.hostPlatform.isLinux [ mitmproxy-linux ]
38 ++ lib.optionals stdenv.hostPlatform.isDarwin [ mitmproxy-macos ];
39 # not packaged yet
40 # ++ lib.optionals stdenv.hostPlatform.isWindows [ mitmproxy-windows ]
41
42 # repo has no python tests
43 doCheck = false;
44
45 pythonImportsCheck = [ "mitmproxy_rs" ];
46
47 meta = with lib; {
48 description = "Rust bits in mitmproxy";
49 homepage = "https://github.com/mitmproxy/mitmproxy_rs";
50 changelog = "https://github.com/mitmproxy/mitmproxy_rs/blob/${src.rev}/CHANGELOG.md#${
51 lib.replaceStrings [ "." ] [ "" ] version
52 }";
53 license = licenses.mit;
54 inherit (mitmproxy.meta) maintainers;
55 };
56}