From d92712673ba8d169606a1db83224969952f8ac07 Mon Sep 17 00:00:00 2001 From: Jade Lovelace Date: Thu, 27 Jun 2024 22:43:02 -0700 Subject: store: guess the URL of failing fixed-output derivations This is a shameless layering violation in favour of UX. It falls back trivially to "unknown", so it's purely a UX feature. Diagnostic sample: ``` error: hash mismatch in fixed-output derivation '/nix/store/sjfw324j4533lwnpmr5z4icpb85r63ai-x1.drv': likely URL: https://meow.puppy.forge/puppy.tar.gz specified: sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA= got: sha256-a1Qvp3FOOkWpL9kFHgugU1ok5UtRPSu+NwCZKbbaEro= ``` Change-Id: I873eedcf7984ab23f57a6754be00232b5cb5b02c --- src/libstore/build/local-derivation-goal.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/libstore/build') diff --git a/src/libstore/build/local-derivation-goal.cc b/src/libstore/build/local-derivation-goal.cc index 968f669ec..1dd2ad8aa 100644 --- a/src/libstore/build/local-derivation-goal.cc +++ b/src/libstore/build/local-derivation-goal.cc @@ -2546,9 +2546,12 @@ SingleDrvOutputs LocalDerivationGoal::registerOutputs() /* Throw an error after registering the path as valid. */ worker.hashMismatch = true; + // XXX: shameless layering violation hack that makes the hash mismatch error at least not utterly worthless + auto guessedUrl = getOr(drv->env, "urls", getOr(drv->env, "url", "(unknown)")); delayedException = std::make_exception_ptr( - BuildError("hash mismatch in fixed-output derivation '%s':\n specified: %s\n got: %s", + BuildError("hash mismatch in fixed-output derivation '%s':\n likely URL: %s\n specified: %s\n got: %s", worker.store.printStorePath(drvPath), + guessedUrl, wanted.to_string(SRI, true), got.to_string(SRI, true))); } -- cgit v1.2.3