From a1cf578b40d84989c2eb8482c0e8eb55a89d9924 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sandro=20J=C3=A4ckel?= Date: Mon, 2 Sep 2024 17:50:29 +0200 Subject: [PATCH] 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. --- pkgs/build-support/go/module.nix | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkgs/build-support/go/module.nix b/pkgs/build-support/go/module.nix index 214b2603ff7f349..7a701060ebc91d9 100644 --- a/pkgs/build-support/go/module.nix +++ b/pkgs/build-support/go/module.nix @@ -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;