lib.fetchers: remove throwIf usage

throwIf sends our error message through a function call, even if the
error condition doesn't trigger. This requires a lot of thunk allocation
that can be easily avoided.
This commit is contained in:
Eman Resu 2026-05-26 13:31:39 -04:00
commit c81b12b698

View file

@ -22,7 +22,6 @@ let
concatMapStringsSep
head
length
throwIf
;
inherit (lib.attrsets)
attrsToList
@ -130,7 +129,7 @@ rec {
hashesAsNVPairs = attrsToList (intersectAttrs hashSet args);
in
if hashesAsNVPairs == [ ] then
throwIf required "fetcher called without `hash`" null
if required then throw "fetcher called without `hash`" else null
else if length hashesAsNVPairs != 1 then
throw "fetcher called with mutually-incompatible arguments: ${
concatMapStringsSep ", " (a: a.name) hashesAsNVPairs