nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 stdenv,
4 buildPythonPackage,
5 fetchFromGitHub,
6 cmake,
7 abseil-cpp_202508,
8 protobuf,
9 pybind11,
10 zlib,
11}:
12
13buildPythonPackage {
14 pname = "pybind11-protobuf";
15 version = "0-unstable-2025-10-29";
16 pyproject = false;
17
18 src = fetchFromGitHub {
19 owner = "pybind";
20 repo = "pybind11_protobuf";
21 rev = "4825dca68c8de73f5655fc50ce79c49c4d814652";
22 hash = "sha256-SeIUyWLeThfBX3SljLdG7CbENdbuJG+X0+h/gn/ATWE=";
23 };
24
25 patches = [
26 # Rebase of the OpenSUSE patch: https://build.opensuse.org/projects/openSUSE:Factory/packages/pybind11_protobuf/files/0006-Add-install-target-for-CMake-builds.patch?expand=1
27 # on top of: https://github.com/pybind/pybind11_protobuf/pull/188/commits/5f0ac3d8c10cbb8b3b81063467c71085cd39624f
28 ./add-install-target-for-cmake-builds.patch
29 ];
30
31 postPatch = ''
32 substituteInPlace cmake/dependencies/CMakeLists.txt \
33 --replace-fail 'find_package(protobuf 5.29.2 REQUIRED)' 'find_package(protobuf REQUIRED)'
34 '';
35
36 nativeBuildInputs = [ cmake ];
37
38 buildInputs = [
39 abseil-cpp_202508
40 protobuf
41 pybind11
42 zlib
43 ];
44
45 cmakeFlags = [
46 (lib.cmakeBool "USE_SYSTEM_ABSEIL" true)
47 (lib.cmakeBool "USE_SYSTEM_PROTOBUF" true)
48 (lib.cmakeBool "USE_SYSTEM_PYBIND" true)
49
50 # The find_package calls are local to the dependencies subdirectory
51 (lib.cmakeBool "CMAKE_FIND_PACKAGE_TARGETS_GLOBAL" true)
52 ]
53 ++ lib.optionals stdenv.hostPlatform.isDarwin [
54 # Without it, Cmake prefers using Find-module which is mysteriously broken
55 # But the generated Config works
56 (lib.cmakeBool "CMAKE_FIND_PACKAGE_PREFER_CONFIG" true)
57 ];
58
59 meta = {
60 description = "Pybind11 bindings for Google's Protocol Buffers";
61 homepage = "https://github.com/pybind/pybind11_protobuf";
62 license = lib.licenses.bsd3;
63 maintainers = with lib.maintainers; [ wegank ];
64 };
65}