Building a go module with `replace … => …` inside `go.mod`

I’m trying to build a PR of gonic. Gonic is in nixpkgs, where it’s built from the main branch.

So I tried creating the following overlay:

(final: prev: {
  gonic = (prev.gonic.overrideAttrs (_: {
    version = "v0.16.4+albumcovers";

    src = prev.fetchFromGitHub {
      owner = "sentriz";
      repo = "gonic";
      rev = "615dee87a12b350f5bc01a25caceb4199a0c0a40";
      sha256 = "sha256-5+sgIOwefNoG/voVtXt6UksSiNTqS9zKe6kH3OKFuEs=";
    };

    # proxyVendor = true; changes the hash below, but leads to the same result
    vendorHash = "sha256-PNvHXK6YpWLSsvRAS/B5vriqSlJv3QR/ObbWBR3OfaY=";
  }));
})

Easy enough! But building this fails:

Build logs
building '/nix/store/j9iiqfi3wxpcvvw0rcxmckapj6q3fcih-gonic-v0.16.4+albumcovers.drv'...
Running phase: unpackPhase
unpacking source archive /nix/store/fs56026nvw36skz2fc7bar5sawdx6jxg-source
source root is source
Running phase: patchPhase
Running phase: updateAutotoolsGnuConfigScriptsPhase
Running phase: configurePhase
Running phase: buildPhase
Building subPackage .
Building subPackage ./cmd/gonic
# github.com/sentriz/audiotags
audiotags.c: In function 'audiotags_file_memory':
audiotags.c:46:3: error: unknown type name 'TagLib_IOStream'
   46 |   TagLib_IOStream *ioStream = taglib_memory_iostream_new(data, length);
      |   ^~~~~~~~~~~~~~~
audiotags.c:46:31: error: implicit declaration of function 'taglib_memory_iostream_new' [-Wimplicit-function-declaration]
   46 |   TagLib_IOStream *ioStream = taglib_memory_iostream_new(data, length);
      |                               ^~~~~~~~~~~~~~~~~~~~~~~~~~
audiotags.c:46:31: error: initialization of 'int *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
audiotags.c:50:21: error: implicit declaration of function 'taglib_file_new_iostream'; did you mean 'taglib_file_new_type'? [-Wimplicit-function-declaration]
   50 |   TagLib_File *fr = taglib_file_new_iostream(ioStream);
      |                     ^~~~~~~~~~~~~~~~~~~~~~~~
      |                     taglib_file_new_type
audiotags.c:50:21: error: initialization of 'TagLib_File *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
audiotags.c:56:5: error: implicit declaration of function 'taglib_iostream_free'; did you mean 'taglib_file_free'? [-Wimplicit-function-declaration]
   56 |     taglib_iostream_free(ioStream);
      |     ^~~~~~~~~~~~~~~~~~~~
      |     taglib_file_free
audiotags.c: In function 'audiotags_file_properties':
audiotags.c:66:17: error: implicit declaration of function 'taglib_property_keys' [-Wimplicit-function-declaration]
   66 |   char **keys = taglib_property_keys(fileRef);
      |                 ^~~~~~~~~~~~~~~~~~~~
audiotags.c:66:17: error: initialization of 'char **' from 'int' makes pointer from integer without a cast [-Wint-conversion]
audiotags.c:71:23: error: implicit declaration of function 'taglib_property_get' [-Wimplicit-function-declaration]
   71 |       char **values = taglib_property_get(fileRef, *keyPtr);
      |                       ^~~~~~~~~~~~~~~~~~~
audiotags.c:71:23: error: initialization of 'char **' from 'int' makes pointer from integer without a cast [-Wint-conversion]
audiotags.c:78:7: error: implicit declaration of function 'taglib_property_free'; did you mean 'taglib_file_free'? [-Wimplicit-function-declaration]
   78 |       taglib_property_free(values);
      |       ^~~~~~~~~~~~~~~~~~~~
      |       taglib_file_free
audiotags.c: In function 'audiotags_clear_properties':
audiotags.c:88:17: error: initialization of 'char **' from 'int' makes pointer from integer without a cast [-Wint-conversion]
   88 |   char **keys = taglib_property_keys(fileRef);
      |                 ^~~~~~~~~~~~~~~~~~~~
audiotags.c:93:7: error: implicit declaration of function 'taglib_property_set' [-Wimplicit-function-declaration]
   93 |       taglib_property_set(fileRef, *keyPtr, NULL);
      |       ^~~~~~~~~~~~~~~~~~~
audiotags.c: In function 'audiotags_read_picture':
audiotags.c:139:3: error: unknown type name 'TagLib_Complex_Property_Attribute'
  139 |   TagLib_Complex_Property_Attribute*** properties = taglib_complex_property_get(fileRef, "PICTURE");
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
audiotags.c:139:53: error: implicit declaration of function 'taglib_complex_property_get' [-Wimplicit-function-declaration]
  139 |   TagLib_Complex_Property_Attribute*** properties = taglib_complex_property_get(fileRef, "PICTURE");
      |                                                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~
audiotags.c:139:53: error: initialization of 'int ***' from 'int' makes pointer from integer without a cast [-Wint-conversion]
audiotags.c:144:3: error: unknown type name 'TagLib_Complex_Property_Picture_Data'
  144 |   TagLib_Complex_Property_Picture_Data picture;
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
audiotags.c:145:3: error: implicit declaration of function 'taglib_picture_from_complex_property' [-Wimplicit-function-declaration]
  145 |   taglib_picture_from_complex_property(properties, &picture);
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
audiotags.c:147:25: error: request for member 'data' in something not a structure or union
  147 |   goPutImage(id, picture.data, picture.size);
      |                         ^
audiotags.c:147:39: error: request for member 'size' in something not a structure or union
  147 |   goPutImage(id, picture.data, picture.size);
      |                                       ^
audiotags.c: In function 'audiotags_write_picture':
audiotags.c:154:3: error: implicit declaration of function 'TAGLIB_COMPLEX_PROPERTY_PICTURE' [-Wimplicit-function-declaration]
  154 |   TAGLIB_COMPLEX_PROPERTY_PICTURE(prop, data, length, "Written by go-taglib", mime, "Front Cover");
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
audiotags.c:154:35: error: 'prop' undeclared (first use in this function)
  154 |   TAGLIB_COMPLEX_PROPERTY_PICTURE(prop, data, length, "Written by go-taglib", mime, "Front Cover");
      |                                   ^~~~
audiotags.c:154:35: note: each undeclared identifier is reported only once for each function it appears in
audiotags.c:156:8: error: implicit declaration of function 'taglib_complex_property_set' [-Wimplicit-function-declaration]
  156 |   if (!taglib_complex_property_set(fileRef, "PICTURE", prop))
      |        ^~~~~~~~~~~~~~~~~~~~~~~~~~~
error: builder for '/nix/store/j9iiqfi3wxpcvvw0rcxmckapj6q3fcih-gonic-v0.16.4+albumcovers.drv' failed with exit code 1;
       last 25 log lines:
       >       |                                                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~
       > audiotags.c:139:53: error: initialization of 'int ***' from 'int' makes pointer from integer without a cast [-Wint-conversion]
       > audiotags.c:144:3: error: unknown type name 'TagLib_Complex_Property_Picture_Data'
       >   144 |   TagLib_Complex_Property_Picture_Data picture;
       >       |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       > audiotags.c:145:3: error: implicit declaration of function 'taglib_picture_from_complex_property' [-Wimplicit-function-declaration]
       >   145 |   taglib_picture_from_complex_property(properties, &picture);
       >       |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       > audiotags.c:147:25: error: request for member 'data' in something not a structure or union
       >   147 |   goPutImage(id, picture.data, picture.size);
       >       |                         ^
       > audiotags.c:147:39: error: request for member 'size' in something not a structure or union
       >   147 |   goPutImage(id, picture.data, picture.size);
       >       |                                       ^
       > audiotags.c: In function 'audiotags_write_picture':
       > audiotags.c:154:3: error: implicit declaration of function 'TAGLIB_COMPLEX_PROPERTY_PICTURE' [-Wimplicit-function-declaration]
       >   154 |   TAGLIB_COMPLEX_PROPERTY_PICTURE(prop, data, length, "Written by go-taglib", mime, "Front Cover");
       >       |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       > audiotags.c:154:35: error: 'prop' undeclared (first use in this function)
       >   154 |   TAGLIB_COMPLEX_PROPERTY_PICTURE(prop, data, length, "Written by go-taglib", mime, "Front Cover");
       >       |                                   ^~~~
       > audiotags.c:154:35: note: each undeclared identifier is reported only once for each function it appears in
       > audiotags.c:156:8: error: implicit declaration of function 'taglib_complex_property_set' [-Wimplicit-function-declaration]
       >   156 |   if (!taglib_complex_property_set(fileRef, "PICTURE", prop))
       >       |        ^~~~~~~~~~~~~~~~~~~~~~~~~~~
       For full logs, run 'nix log /nix/store/j9iiqfi3wxpcvvw0rcxmckapj6q3fcih-gonic-v0.16.4+albumcovers.drv'.

If I understand it correctly, this is because buildGoModule uses go install under the hood which does not seem to support replace statements in go.mod. There is a replace statement which replaces a go module with a fork of a module that has some extra features regarding cover images, and these are missing in the compile logs above.

Is there any way to still build the PR? Thanks!