With buildGoModule, a module is missing

I am attempting to package cwtch-ui, and, as a prerequisite, I’m building the C bindings for the cwtch library, which is written in Go. Here’s my current derivation; it uses buildGoModule but overrides installPhase to use the upstream Makefile instead of just running go build.

When I attempt to build this derivation, I get this error (full log):

lib.go:31:2: cannot find module providing package github.com/mutecomm/go-sqlcipher/v4: import lookup disabled by -mod=vendor

The upstream seems to be set up correctly; this library is listed in go.mod and go.sum. I’ve examined the build tree, and this module is indeed missing from the vendor directory created by buildGoModule.

The only thing I’ve noticed that seems suspicious is that this package isn’t directly used, it’s renamed to _, which I understand to mean that it’s being imported for its side effects.

Unfortunately, I’m not sufficiently familiar with Go to know immediately if this is definitely a nixpkgs problem or not, but I would have expected a Go problem to have been noticed and fixed upstream already.

I’m not sure what to look at or try next; any pointers would be appreciated.

I solved it. The issue was that the missing module (sqlcipher) is only used by the generate code, but go mod vendor “helpfully” only includes the modules referenced by the current code, so I had to add

  overrideModAttrs = (old: {
    preBuild = ''
      make lib.go

to generate the code before go mod vendor runs. Now it works fine.

1 Like