···46 urls ? []
4748, # Additional curl options needed for the download to succeed.
0049 curlOpts ? ""
0005051, # Name of the file. If empty, use the basename of `url' (or of the
52 # first element of `urls').
···147148 outputHashMode = if (recursiveHash || executable) then "recursive" else "flat";
149150- inherit curlOpts showURLs mirrorsFile postFetch downloadToTemp executable;
0000000151152 impureEnvVars = impureEnvVars ++ netrcImpureEnvVars;
153
···46 urls ? []
4748, # Additional curl options needed for the download to succeed.
49+ # Warning: Each space (no matter the escaping) will start a new argument.
50+ # If you wish to pass arguments with spaces, use `curlOptsList`
51 curlOpts ? ""
52+53+, # Additional curl options needed for the download to succeed.
54+ curlOptsList ? []
5556, # Name of the file. If empty, use the basename of `url' (or of the
57 # first element of `urls').
···152153 outputHashMode = if (recursiveHash || executable) then "recursive" else "flat";
154155+ curlOpts = lib.warnIf (lib.isList curlOpts) ''
156+ fetchurl for ${toString (builtins.head urls_)}: curlOpts is a list (${lib.generators.toPretty { multiline = false; } curlOpts}), which is not supported anymore.
157+ - 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:
158+ curlOpts = ${lib.strings.escapeNixString (toString curlOpts)};
159+ - If you wish for each list element to be passed as a separate curl argument, allowing arguments to contain spaces, use curlOptsList instead:
160+ curlOptsList = [ ${lib.concatMapStringsSep " " lib.strings.escapeNixString curlOpts} ];'' curlOpts;
161+ curlOptsList = lib.escapeShellArgs curlOptsList;
162+ inherit showURLs mirrorsFile postFetch downloadToTemp executable;
163164 impureEnvVars = impureEnvVars ++ netrcImpureEnvVars;
165
+13
pkgs/build-support/fetchurl/tests.nix
···0000000000000
···1+{ invalidateFetcherByDrvHash, fetchurl, jq, moreutils, ... }: {
2+ # Tests that we can send custom headers with spaces in them
3+ header =
4+ let headerValue = "Test '\" <- These are some quotes";
5+ in invalidateFetcherByDrvHash fetchurl {
6+ url = "https://httpbin.org/headers";
7+ sha256 = builtins.hashString "sha256" (headerValue + "\n");
8+ curlOptsList = [ "-H" "Hello: ${headerValue}" ];
9+ postFetch = ''
10+ ${jq}/bin/jq -r '.headers.Hello' $out | ${moreutils}/bin/sponge $out
11+ '';
12+ };
13+}