nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
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-rs-*-vendor/aya-build-*/src/lib.rs \
16 --replace-fail '"+nightly",' "" \
17 --replace-fail '"-Z",' "" \
18 --replace-fail '"build-std=core",' ""
19
20 substituteInPlace mitmproxy-linux-ebpf/.cargo/config.toml \
21 --replace-fail 'build-std = ["core"]' ""
22
23 cp ${./fix-mitmproxy-linux-redirector-path.diff} tmp.diff
24 substituteInPlace tmp.diff \
25 --replace-fail @mitmproxy-linux-redirector@ $out/bin/mitmproxy-linux-redirector
26 patch -p1 < tmp.diff
27 '';
28
29 env = {
30 RUSTFLAGS = "-C target-feature=";
31 RUSTC_BOOTSTRAP = 1;
32 };
33
34 buildAndTestSubdir = "mitmproxy-linux";
35
36 nativeBuildInputs = [
37 bpf-linker
38 rustPlatform.cargoSetupHook
39 rustPlatform.maturinBuildHook
40 ];
41
42 # repo has no python tests
43 doCheck = false;
44
45 pythonImportsCheck = [ "mitmproxy_linux" ];
46
47 meta = {
48 inherit (mitmproxy-rs.meta) changelog license maintainers;
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}