"inconsistent vendoring" in buildGoModule when overriding source

I did a bit more digging on this, and managed to figure it out in the end, with some confirmation from @Mic92 on IRC. What set me on the right path was after having run a GC and trying to rebuild this overlay, I spotted the following line:

copying path '/nix/store/cyqfygx7d4k6mzv0hwdph4gd2q1kci53-aerc-0.4.0-go-modules' from 'https://cache.nixos.org'...

So my overriden derivation was using the exact same vendored libraries as the upstream nixpkgs one, leading to the version mismatches I was seeing in the above. It turns out that overrideAttrs and buildGoModule aren’t aware of each other, so the -go-modules derivation there isn’t recomputed when I change the source. I got it working by defining a whole new derivation with buildGoModules as follows:

(self: super: {
  aerc = super.buildGoModule {
    inherit (super.aerc.drvAttrs)
      pname runVend doCheck nativeBuildInputs pythonPath buildInputs
      buildPhase installPhase postFixup;
    inherit (super.aerc) meta;
    version = "0.4.0+master";
    src = super.fetchurl {
      url =
        "https://git.sr.ht/~sircmpwn/aerc/archive/c48f228fa5ac57984af78e19713929224874aa8b.tar.gz";
      sha256 = "0lw39c4visy91g2qy380cdqm2h1pn36b7q5zylaskd5xkfanpdgg";
    };
    # had to remake the patch because the old one didn't apply cleanly
    patches = [ ./runtime-sharedir.patch ];
    vendorSha256 = "03f7kfri1qjqbnchcivf074w6wmg7q2nansx5lk41z6ckjkzbv2n";
  };
})

I’m not sure whether using inherit is quite the right approach (perhaps buildGoModule (super.aerc.drvAttrs // { ... }) would be better), but that now builds, installs, and the bug is fixed!

4 Likes