Need some Go and Protobuf packaging pointer

Hi everyone, I’m trying to package the OliveTin project for my own needs, and eventual inclusion in nixpkgs. It’s built using Go and Protobuf.

However, I don’t have much experience with Go. I’ve made some progress, but I’m having problems.

Here is the packaging I currently have:

{ lib
, stdenv
, fetchFromGitHub
, buildGoModule
, grpc-gateway
, protobuf
, protoc-gen-go
, protoc-gen-go-grpc
}: let
  pname = "OliveTin";
  version = "2023.12.21";

  googleapis = fetchFromGitHub {
    owner = "googleapis";
    repo = "googleapis";
    rev = "ef8a5429145c241dcb256b0b84fa8e477facc9e1";
    hash = "sha256-K0y7bXf7ehY168WFEHztNzLbh0sf1ZkyVF6A+QgMrRg=";
  };

in buildGoModule {
  inherit pname version;

  src = fetchFromGitHub {
    owner = "OliveTin";
    repo = pname;
    rev = version;
    hash = "sha256-UqPSNRXTRdt7b4P0qG0ER/7mpsKnyaFsZvcMQe6lG24=";
  };

  nativeBuildInputs = [
    grpc-gateway
    protobuf
    protoc-gen-go
    protoc-gen-go-grpc
  ];

  preBuild = ''
    protoc --go_out=. --go-grpc_out=. --grpc-gateway_out=. -I${googleapis}:$src OliveTin.proto
  '';

  vendorHash = "sha256-jcr++E9UhsBMGc8i5xOvuO+hmXRcQbP1Zm8yM+wFYQo=";

  meta = {
    description = "A web interface for safe and simple access to predefined shell commands.";
    homepage = "https://github.com/OliveTin/OliveTin";
    license = lib.licenses.agpl3;
  };
}

However, if I try to build it, I get the following error:

internal/grpcapi/grpcApi.go:293:50: cannot use newServer(ex) (value of type *oliveTinAPI) as "github.com/OliveTin/OliveTin/gen/grpc".OliveTinApiServiceServer value in argument to pb.RegisterOliveTinApiServiceServer: *oliveTinAPI does not implement "github.com/OliveTin/OliveTin/gen/grpc".OliveTinApiServiceServer (missing method mustEmbedUnimplementedOliveTinApiServiceServer)

Is this something to do with a mismatch between the version of protobuf in nixpkgs-22.11, versus the version OliveTin expects?

I tried updating the version to master to see if there was a patch that I could backport, but then I get many issues relating to vendoring, which I’m not sure how to address.

Any other feedback is welcome.

It seems like it’s a protobuf feature to yield errors when the server doesn’t include the “unimplemented” server.

There’s an option to change that behaviour as described in this stackoverflow post:

protoc --go-grpc_out=require_unimplemented_servers=false:.

That fixed it! Thanks

Hey, have you gotten this package to build? I’d also be interested.