buildGoModule: be nicer when overrideAttrs clears passthru

Before an overlay in the form of:

package.overrideAttrs (old: {
  passthru = {};
})

would fail evaluation like:

       error: attribute 'overrideModAttrs' missing
       at /nix/store/afwc3m1sm49qq57xjv2hmd7iy4x0j33h-source/pkgs/build-support/go/module.nix:179:20:
          178|     outputHashAlgo = if finalAttrs.vendorHash == "" then "sha256" else null;
          179|   }).overrideAttrs finalAttrs.passthru.overrideModAttrs;
             |                    ^
          180|

Now instead we take the fallback default.
This commit is contained in:
Sandro Jäckel 2024-09-02 17:50:29 +02:00
parent 9d4badae3e
commit bc12ef1bf0
No known key found for this signature in database
GPG Key ID: 3AF5A43A3EECC2E5

View File

@ -176,7 +176,8 @@ in
# Handle empty vendorHash; avoid
# error: empty hash requires explicit hash algorithm
outputHashAlgo = if finalAttrs.vendorHash == "" then "sha256" else null;
}).overrideAttrs finalAttrs.passthru.overrideModAttrs;
# in case an overlay clears passthru by accident, don't fail evaluation
}).overrideAttrs (finalAttrs.passthru.overrideModAttrs or overrideModAttrs);
nativeBuildInputs = [ go ] ++ nativeBuildInputs;