about summary refs log tree commit diff
path: root/pkgs/development/libraries/grpc
diff options
context:
space:
mode:
authorAlyssa Ross <hi@alyssa.is>2021-08-01 12:03:56 +0000
committerAlyssa Ross <hi@alyssa.is>2021-08-01 13:03:24 +0000
commitb2402c5cd3aa0ef5d46e6f894079f20005d6dee5 (patch)
treefa21fe08e00c6aec83f374cbe12afee7e7a21a9e /pkgs/development/libraries/grpc
parentadf2a047ae901beb39e2beae223e9d9ea71e8e79 (diff)
grpc: fix cross
I couldn't find any alternative to setting _gRPC_PROTOBUF_PROTOC_EXECUTABLE.
protobuf.cmake uses find_program when cross-compiling, which finds the
host platform's protoc instead of the build platform's.  I even tried
giving protobuf multiple outputs and not including the one with the
binary in buildInputs, but it didn't help.
Diffstat (limited to 'pkgs/development/libraries/grpc')
-rw-r--r--pkgs/development/libraries/grpc/default.nix8
1 files changed, 6 insertions, 2 deletions
diff --git a/pkgs/development/libraries/grpc/default.nix b/pkgs/development/libraries/grpc/default.nix
index 2bf843241a6aa..62f0c2e3d3148 100644
--- a/pkgs/development/libraries/grpc/default.nix
+++ b/pkgs/development/libraries/grpc/default.nix
@@ -1,4 +1,5 @@
-{ lib, stdenv, fetchFromGitHub, fetchpatch, cmake, zlib, c-ares, pkg-config, re2, openssl, protobuf
+{ lib, stdenv, fetchFromGitHub, fetchpatch, buildPackages
+, cmake, zlib, c-ares, pkg-config, re2, openssl, protobuf, grpc
 , abseil-cpp, libnsl
 }:
 
@@ -20,7 +21,8 @@ stdenv.mkDerivation rec {
     })
   ];
 
-  nativeBuildInputs = [ cmake pkg-config ];
+  nativeBuildInputs = [ cmake pkg-config ]
+    ++ lib.optional (stdenv.hostPlatform != stdenv.buildPlatform) grpc;
   propagatedBuildInputs = [ c-ares re2 zlib abseil-cpp ];
   buildInputs = [ c-ares.cmake-config openssl protobuf ]
     ++ lib.optionals stdenv.isLinux [ libnsl ];
@@ -35,6 +37,8 @@ stdenv.mkDerivation rec {
       "-DBUILD_SHARED_LIBS=ON"
       "-DCMAKE_SKIP_BUILD_RPATH=OFF"
       "-DCMAKE_CXX_STANDARD=17"
+    ] ++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
+      "-D_gRPC_PROTOBUF_PROTOC_EXECUTABLE=${buildPackages.protobuf}/bin/protoc"
     ];
 
   # CMake creates a build directory by default, this conflicts with the