Rust package doesn't wan't to build, protoc binary not found

Hello, I’m trying to build a rust package and have been having an issue with it so thought of asking for help.

The package in question I’m trying to build is comet.

My current comet.nix looks like this:

{ pkgs, ... }:
with pkgs;
rustPlatform.buildRustPackage rec {
  pname = "comet-gog";
  version = "e313c8a";
  src = fetchFromGitHub {
    owner = "imLinguin";
    repo = "comet";
    rev = "e313c8ae052dfd9a6b06c8246f83f5f34672bcaa";
    hash = "sha256-ctU9yhnlS8x4xY2iUaG7NvPJB4+vJTXzZF2llof4NyM=";
    fetchSubmodules = true;
  };
  cargoLock.lockFile = src + /Cargo.lock;
}

The package build until it hits the custom build command where it error’s out, here are the revelant logs:

Caused by: 
  process didn't exit successfully: `/build/source/target/release/build/comet-85bbf36aabd27783/build-script-build` (exit status: 1) 
  --- stderr 
  codegen failed: parse and typecheck
 
  Caused by:
      0: using protoc parser
      1: failed to spawn command `"/build/cargo-vendor-dir/protoc-bin-vendored-linux-x86_64-3.0.0/bin/protoc" "-Iproto" "--descriptor_set_out=/build/protobuf-parseenQcHn/descriptor.pbbin" "--include_import
      s" "proto/gog.protocols.pb.proto" "proto/galaxy.protocols.webbroker_service.proto" "proto/galaxy.protocols.overlay_for_peer.proto" "proto/galaxy.protocols.communication_service.proto" "proto/galaxy.c
      ommon.protocols.peer_to_server.proto" "proto/galaxy.common.protocols.peer_to_peer.proto" "proto/galaxy.common.protocols.peer_common.proto" "proto/galaxy.common.protocols.connection.proto"`
      2: No such file or directory (os error 2)
1 Like

I tried to add protoc as build input and it still doesn’t work, here is the current nix file:

{ pkgs, ... }:
with pkgs;
rustPlatform.buildRustPackage rec {
  pname = "comet-gog";
  version = "e313c8a";
  src = fetchFromGitHub {
    owner = "imLinguin";
    repo = "comet";
    rev = "e313c8ae052dfd9a6b06c8246f83f5f34672bcaa";
    hash = "sha256-ctU9yhnlS8x4xY2iUaG7NvPJB4+vJTXzZF2llof4NyM=";
    fetchSubmodules = true;
  };
  cargoLock.lockFile = src + /Cargo.lock;
  buildInputs = [ protobuf ];
  PROTOC = "${protobuf}/bin/protoc";
}

maybe adding the following helps:

PROTOC_INCLUDE = "${pkgs.protobuf}/include";

FYI I have alread opened a PR adding this package (comet-gog: init at 0-unstable-2024-03-28 by TomaSajt · Pull Request #278800 · NixOS/nixpkgs · GitHub)
and I solved this issue by patching out build.rs to use the nix based package.