fetchurl: cleanup a bit by moving the warning into assert

This commit is contained in:
Jan Malakhovski 2023-08-08 13:38:11 +00:00
parent 9dcecbdb31
commit 9437e4da35

View File

@ -132,6 +132,13 @@ let
else throw "fetchurl requires a hash for fixed-output derivation: ${lib.concatStringsSep ", " urls_}";
in
assert (lib.isList curlOpts) -> lib.warn ''
fetchurl for ${toString (builtins.head urls_)}: curlOpts is a list (${lib.generators.toPretty { multiline = false; } curlOpts}), 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 = ${lib.strings.escapeNixString (toString curlOpts)};
- If you wish for each list element to be passed as a separate curl argument, allowing arguments to contain spaces, use curlOptsList instead:
curlOptsList = [ ${lib.concatMapStringsSep " " lib.strings.escapeNixString curlOpts} ];'' true;
stdenvNoCC.mkDerivation ((
if (pname != "" && version != "") then
{ inherit pname version; }
@ -161,12 +168,7 @@ stdenvNoCC.mkDerivation ((
outputHashMode = if (recursiveHash || executable) then "recursive" else "flat";
curlOpts = lib.warnIf (lib.isList curlOpts) ''
fetchurl for ${toString (builtins.head urls_)}: curlOpts is a list (${lib.generators.toPretty { multiline = false; } curlOpts}), 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 = ${lib.strings.escapeNixString (toString curlOpts)};
- If you wish for each list element to be passed as a separate curl argument, allowing arguments to contain spaces, use curlOptsList instead:
curlOptsList = [ ${lib.concatMapStringsSep " " lib.strings.escapeNixString curlOpts} ];'' curlOpts;
inherit curlOpts;
curlOptsList = lib.escapeShellArgs curlOptsList;
inherit showURLs mirrorsFile postFetch downloadToTemp executable;