From 28e6e36fa01c0037066e81385c280989bf95d455 Mon Sep 17 00:00:00 2001 From: Eman Resu <78693624+quatquatt@users.noreply.github.com> Date: Thu, 28 May 2026 00:15:41 -0400 Subject: [PATCH] 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. --- pkgs/build-support/fetchurl/default.nix | 38 ++++++++++++++----------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/pkgs/build-support/fetchurl/default.nix b/pkgs/build-support/fetchurl/default.nix index 2f75079ead55..0d626d5783f9 100644 --- a/pkgs/build-support/fetchurl/default.nix +++ b/pkgs/build-support/fetchurl/default.nix @@ -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