1{ 2 lib, 3 buildPythonPackage, 4 bpf-linker, 5 rustPlatform, 6 mitmproxy-rs, 7}: 8 9buildPythonPackage { 10 pname = "mitmproxy-linux"; 11 inherit (mitmproxy-rs) version src cargoDeps; 12 pyproject = true; 13 14 postPatch = '' 15 substituteInPlace mitmproxy-linux/build.rs \ 16 --replace-fail '"-Z",' "" \ 17 --replace-fail '"build-std=core",' "" 18 19 substituteInPlace mitmproxy-linux-ebpf/.cargo/config.toml \ 20 --replace-fail 'build-std = ["core"]' "" 21 22 cp ${./fix-mitmproxy-linux-redirector-path.diff} tmp.diff 23 substituteInPlace tmp.diff \ 24 --replace-fail @mitmproxy-linux-redirector@ $out/bin/mitmproxy-linux-redirector 25 patch -p1 < tmp.diff 26 ''; 27 28 RUSTFLAGS = "-C target-feature="; 29 RUSTC_BOOTSTRAP = 1; 30 31 buildAndTestSubdir = "mitmproxy-linux"; 32 33 nativeBuildInputs = [ 34 bpf-linker 35 rustPlatform.cargoSetupHook 36 rustPlatform.maturinBuildHook 37 ]; 38 39 # repo has no python tests 40 doCheck = false; 41 42 pythonImportsCheck = [ "mitmproxy_linux" ]; 43 44 meta = 45 { 46 inherit (mitmproxy-rs.meta) changelog license maintainers; 47 } 48 // { 49 description = "Linux Rust bits in mitmproxy"; 50 homepage = "https://github.com/mitmproxy/mitmproxy_rs/tree/main/mitmproxy-linux"; 51 platforms = lib.platforms.linux; 52 }; 53}