Thanks a lot for your help again. I finally figured this out
:
This happens (probably only to me) due to installManPage in postBuild. The go-modules derivation inherits the postBuild that one would expect to be used by the main builder, not the builder of the go-modules derivation[1]:
Hence since go-modules runs my postBuild, the $out directory is already created due to installManPage (and the man page is installed there as well, without use of course). This makes the following command act differently:
It copies the vendor directory into the $out directory, resulting in $out/vendor which becomes vendor/vendor in the main derivation.
[1]: This hooks inheritance behavior is something to be discussed and changed, IMO. Will open an issue or PR soon.