diff options
author | Dmitry Ivankov <boltzmannrain@gmail.com> | 2023-11-13 20:34:06 +0100 |
---|---|---|
committer | Weijia Wang <9713184+wegank@users.noreply.github.com> | 2023-11-18 17:04:59 +0100 |
commit | 0dd2238ac7fb39e9123ecc0c7332a6930397f5d2 (patch) | |
tree | a4efbfe1e64bf717e8608cbda71606880f495381 | |
parent | bb0fe34d79f02db24d671553db71f87313dd8c39 (diff) |
mitmproxy: fix macos build
https://hydra.nixos.org/build/240114924/nixlog/1 ``` error: linking with `/nix/store/sa6hywsm1mqfyd1xakyzv4ljjsb3hawh-clang-wrapper-11.1.0/bin/cc` failed: exit status: 1 | ... = note: ld: library not found for -liconv clang-11: error: linker command failed with exit code 1 (use -v to see invocation) ``` after adding libiconv it starts to fail with ``` File "/nix/store/ncs3h7zqjl3cl2cwflka40rrirb6qg1m-python3.11-mitmproxy-rs-0.3.11/lib/python3.11/site-packages/mitmproxy_rs/__init__.py", line 1, in <module> from .mitmproxy_rs import * ModuleNotFoundError: No module named 'mitmproxy_macos' ``` so it needs extra module https://github.com/mitmproxy/mitmproxy_rs/tree/main/mitmproxy-macos So the fixes are - add `libiconv` dependency to mitmproxy-rs - add `mitmproxy-macos` python package and add it to dependencies of `mitmproxy-rs` and `mitmproxy` itself (otherwise import fails, looks like the import is sneaky because it is platform-conditional)
4 files changed, 44 insertions, 1 deletions
diff --git a/pkgs/development/python-modules/mitmproxy-macos/default.nix b/pkgs/development/python-modules/mitmproxy-macos/default.nix new file mode 100644 index 0000000000000..39798d90b15d8 --- /dev/null +++ b/pkgs/development/python-modules/mitmproxy-macos/default.nix @@ -0,0 +1,33 @@ +{ lib +, buildPythonPackage +, fetchFromGitHub +, hatchling +}: + +buildPythonPackage rec { + pname = "mitmproxy-macos"; + version = "0.3.11"; + pyproject = true; + + src = fetchFromGitHub { + owner = "mitmproxy"; + repo = "mitmproxy_rs"; + rev = version; + hash = "sha256-V6LUr1jJiTo0+53jipkTyzG5JSw6uHaS6ziyBaFbETw="; + }; + + sourceRoot = "${src.name}/mitmproxy-macos"; + pythonImportsCheck = [ "mitmproxy_macos" ]; + nativeBuildInputs = [ + hatchling + ]; + + meta = with lib; { + description = "The MacOS Rust bits in mitmproxy"; + homepage = "https://github.com/mitmproxy/mitmproxy_rs/tree/main/mitmproxy-macos"; + changelog = "https://github.com/mitmproxy/mitmproxy_rs/blob/${src.rev}/CHANGELOG.md"; + license = licenses.mit; + maintainers = with maintainers; [ boltzmannrain ]; + platforms = platforms.darwin; + }; +} diff --git a/pkgs/development/python-modules/mitmproxy-rs/default.nix b/pkgs/development/python-modules/mitmproxy-rs/default.nix index 15850ab7cd784..d90e1e0c2a96a 100644 --- a/pkgs/development/python-modules/mitmproxy-rs/default.nix +++ b/pkgs/development/python-modules/mitmproxy-rs/default.nix @@ -4,6 +4,8 @@ , fetchFromGitHub , rustPlatform , darwin +, libiconv +, mitmproxy-macos }: buildPythonPackage rec { @@ -34,13 +36,15 @@ buildPythonPackage rec { buildInputs = lib.optionals stdenv.isDarwin [ darwin.apple_sdk.frameworks.Security + libiconv + mitmproxy-macos ]; pythonImportsCheck = [ "mitmproxy_rs" ]; meta = with lib; { description = "The Rust bits in mitmproxy"; - homepage = " https://github.com/mitmproxy/mitmproxy_rs"; + homepage = "https://github.com/mitmproxy/mitmproxy_rs"; changelog = "https://github.com/mitmproxy/mitmproxy_rs/blob/${src.rev}/CHANGELOG.md"; license = licenses.mit; maintainers = with maintainers; [ fab ]; diff --git a/pkgs/development/python-modules/mitmproxy/default.nix b/pkgs/development/python-modules/mitmproxy/default.nix index 1c57361a64068..566c1e0b32987 100644 --- a/pkgs/development/python-modules/mitmproxy/default.nix +++ b/pkgs/development/python-modules/mitmproxy/default.nix @@ -2,6 +2,7 @@ , fetchFromGitHub , buildPythonPackage , pythonOlder +, stdenv # Mitmproxy requirements , aioquic , asgiref @@ -15,6 +16,7 @@ , hyperframe , kaitaistruct , ldap3 +, mitmproxy-macos , mitmproxy-rs , msgpack , passlib @@ -81,6 +83,8 @@ buildPythonPackage rec { urwid wsproto zstandard + ] ++ lib.optionals stdenv.isDarwin [ + mitmproxy-macos ]; nativeCheckInputs = [ diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index f0502b4eeb5e0..78f2c18e582c9 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -6877,6 +6877,8 @@ self: super: with self; { mitmproxy = callPackage ../development/python-modules/mitmproxy { }; + mitmproxy-macos = callPackage ../development/python-modules/mitmproxy-macos { }; + mitmproxy-rs = callPackage ../development/python-modules/mitmproxy-rs { }; mitmproxy-wireguard = callPackage ../development/python-modules/mitmproxy-wireguard { }; |