fetchurl: Introduce curlOptsList as an improvement over curlOpts
It's impossible to pass arguments with spaces with curlOpts. curlOptsList supports that. Passing a list to curlOpts has been deprecated. This commit is fully backwards compatible.
This commit is contained in:
parent
ba558c6ce0
commit
86c902d673
@ -22,6 +22,8 @@ if ! [ -f "$SSL_CERT_FILE" ]; then
|
|||||||
curl+=(--insecure)
|
curl+=(--insecure)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
eval "curl+=($curlOptsList)"
|
||||||
|
|
||||||
curl+=(
|
curl+=(
|
||||||
$curlOpts
|
$curlOpts
|
||||||
$NIX_CURL_FLAGS
|
$NIX_CURL_FLAGS
|
||||||
|
@ -45,8 +45,13 @@ in
|
|||||||
urls ? []
|
urls ? []
|
||||||
|
|
||||||
, # Additional curl options needed for the download to succeed.
|
, # Additional curl options needed for the download to succeed.
|
||||||
|
# Warning: Each space (no matter the escaping) will start a new argument.
|
||||||
|
# If you wish to pass arguments with spaces, use `curlOptsList`
|
||||||
curlOpts ? ""
|
curlOpts ? ""
|
||||||
|
|
||||||
|
, # Additional curl options needed for the download to succeed.
|
||||||
|
curlOptsList ? []
|
||||||
|
|
||||||
, # Name of the file. If empty, use the basename of `url' (or of the
|
, # Name of the file. If empty, use the basename of `url' (or of the
|
||||||
# first element of `urls').
|
# first element of `urls').
|
||||||
name ? ""
|
name ? ""
|
||||||
@ -148,7 +153,14 @@ stdenvNoCC.mkDerivation {
|
|||||||
|
|
||||||
outputHashMode = if (recursiveHash || executable) then "recursive" else "flat";
|
outputHashMode = if (recursiveHash || executable) then "recursive" else "flat";
|
||||||
|
|
||||||
inherit curlOpts showURLs mirrorsFile postFetch downloadToTemp executable;
|
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;
|
||||||
|
curlOptsList = lib.escapeShellArgs curlOptsList;
|
||||||
|
inherit showURLs mirrorsFile postFetch downloadToTemp executable;
|
||||||
|
|
||||||
impureEnvVars = impureEnvVars ++ netrcImpureEnvVars;
|
impureEnvVars = impureEnvVars ++ netrcImpureEnvVars;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user