Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at flake-libs 113 lines 3.4 kB view raw
1{ 2 lib, 3 stdenv, 4 buildPythonPackage, 5 fetchFromGitHub, 6 rustPlatform, 7 pytest, 8 runCommand, 9 boringssl, 10 libiconv, 11 gcc-unwrapped, 12 python, 13 fetchpatch, 14}: 15 16let 17 boringsslPatched = boringssl.overrideAttrs (oa: { 18 # boringssl source obtained from https://github.com/0x676e67/boring2/tree/1a0f1cd24e728aac100df68027c820f858199224/boring-sys/deps 19 src = fetchFromGitHub { 20 owner = "google"; 21 repo = "boringssl"; 22 rev = "44b3df6f03d85c901767250329c571db405122d5"; 23 hash = "sha256-REELo7X9aFy2OHjubYLO1UQXLTgekD4QFd2vyFthIrg="; 24 }; 25 modRoot = "./src"; 26 patches = [ 27 # A patch required to build boringssl compatible with `boring-sys2`. 28 # See https://github.com/0x676e67/boring2/blob/1a0f1cd24e728aac100df68027c820f858199224/boring-sys/build/main.rs#L486-L489 29 (fetchpatch { 30 name = "boringssl-44b3df6f03d85c901767250329c571db405122d5.patch"; 31 url = "https://raw.githubusercontent.com/0x676e67/boring2/4edbff8cade24d5d83cc372c4502b59c5192b5a1/boring-sys/patches/boringssl-44b3df6f03d85c901767250329c571db405122d5.patch"; 32 hash = "sha256-lM+2lLvfDHnxLl+OgZ6R8Y4Z6JfA9AiDqboT1mbxmao="; 33 }) 34 ]; 35 36 # Remove bazel specific build file to make way for build directory 37 # This is a problem on Darwin because of case-insensitive filesystem 38 preBuild = 39 (lib.optionalString stdenv.hostPlatform.isDarwin '' 40 rm ../BUILD 41 '') 42 + oa.preBuild; 43 44 env.NIX_CFLAGS_COMPILE = 45 oa.env.NIX_CFLAGS_COMPILE 46 + " " 47 + toString ( 48 lib.optionals stdenv.cc.isGNU [ 49 "-Wno-error=ignored-attributes" 50 ] 51 ); 52 53 vendorHash = "sha256-06MkjXl0DKFzIH/H+uT9kXsQdPq7qdZh2dlLW/YhJuk="; 54 }); 55 # boring-sys expects the static libraries in build/ instead of lib/ 56 boringssl-wrapper = runCommand "boringssl-wrapper" { } '' 57 mkdir $out 58 ln -s ${boringsslPatched.out}/lib $out/build 59 ln -s ${boringsslPatched.dev}/include $out/include 60 ''; 61in 62buildPythonPackage rec { 63 pname = "primp"; 64 version = "0.14.0"; 65 pyproject = true; 66 67 src = fetchFromGitHub { 68 owner = "deedy5"; 69 repo = "primp"; 70 tag = "v${version}"; 71 hash = "sha256-LrSygeioJlccOH1oyagw02ankkZK+H6Mzrgy8tB83mo="; 72 }; 73 74 cargoDeps = rustPlatform.fetchCargoVendor { 75 inherit pname version src; 76 hash = "sha256-iPf25DMGNHrWYByNTylB6bPpLfzs0ADwgkjfhVxiiXA="; 77 }; 78 79 nativeBuildInputs = [ 80 rustPlatform.bindgenHook 81 rustPlatform.cargoSetupHook 82 rustPlatform.maturinBuildHook 83 ]; 84 85 # TODO: Can we improve this? 86 postInstall = lib.optionalString stdenv.hostPlatform.isLinux '' 87 patchelf --add-rpath ${lib.getLib gcc-unwrapped.lib} --add-needed libstdc++.so.6 $out/${python.sitePackages}/primp/primp.abi3.so 88 ''; 89 90 buildInputs = lib.optionals stdenv.hostPlatform.isDarwin [ 91 libiconv 92 ]; 93 94 env.BORING_BSSL_PATH = boringssl-wrapper; 95 env.BORING_BSSL_ASSUME_PATCHED = true; 96 97 optional-dependencies = { 98 dev = [ pytest ]; 99 }; 100 101 # Test use network 102 doCheck = false; 103 104 pythonImportsCheck = [ "primp" ]; 105 106 meta = { 107 changelog = "https://github.com/deedy5/primp/releases/tag/${version}"; 108 description = "Python Requests IMPersonate, the fastest Python HTTP client that can impersonate web browsers"; 109 homepage = "https://github.com/deedy5/primp"; 110 license = lib.licenses.mit; 111 maintainers = with lib.maintainers; [ drupol ]; 112 }; 113}