build-support/fetchurl: remove warnIf usage

warnIf sends our warning message through a function call, even if the
warning 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-28 00:19:37 -04:00
parent 020ce4ae44
commit 28e6e36fa0
+21 -17
View File
@@ -327,23 +327,27 @@ lib.extendMkDerivation {
outputHashMode = if (recursiveHash || executable) then "recursive" else "flat";
curlOpts = lib.warnIf (lib.isList curlOpts) (
let
url = toString (builtins.head urls_);
curlOptsRepresentation = lib.generators.toPretty { multiline = false; } curlOpts;
curlOptsAsStringRepresentation = lib.strings.escapeNixString (toString curlOpts);
curlOptsListElementsRepresentation =
lib.concatMapStringsSep " " lib.strings.escapeNixString
curlOpts;
in
''
fetchurl for ${url}: curlOpts is a list (${curlOptsRepresentation}), which is not supported anymore.
- If you wish to get the same effect as before, for elements with spaces (even if escaped) to expand to multiple curl arguments, use a string argument instead:
curlOpts = ${curlOptsAsStringRepresentation};
- If you wish for each list element to be passed as a separate curl argument, allowing arguments to contain spaces, use curlOptsList instead:
curlOptsList = [ ${curlOptsListElementsRepresentation} ];
''
) curlOpts;
curlOpts =
if lib.isList curlOpts then
lib.warn (
let
url = toString (builtins.head urls_);
curlOptsRepresentation = lib.generators.toPretty { multiline = false; } curlOpts;
curlOptsAsStringRepresentation = lib.strings.escapeNixString (toString curlOpts);
curlOptsListElementsRepresentation =
lib.concatMapStringsSep " " lib.strings.escapeNixString
curlOpts;
in
''
fetchurl for ${url}: curlOpts is a list (${curlOptsRepresentation}), which is not supported anymore.
- If you wish to get the same effect as before, for elements with spaces (even if escaped) to expand to multiple curl arguments, use a string argument instead:
curlOpts = ${curlOptsAsStringRepresentation};
- If you wish for each list element to be passed as a separate curl argument, allowing arguments to contain spaces, use curlOptsList instead:
curlOptsList = [ ${curlOptsListElementsRepresentation} ];
''
) curlOpts
else
curlOpts;
inherit
curlOptsList