···132132 else throw "fetchurl requires a hash for fixed-output derivation: ${lib.concatStringsSep ", " urls_}";
133133in
134134135135+assert (lib.isList curlOpts) -> lib.warn ''
136136+ fetchurl for ${toString (builtins.head urls_)}: curlOpts is a list (${lib.generators.toPretty { multiline = false; } curlOpts}), which is not supported anymore.
137137+ - 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:
138138+ curlOpts = ${lib.strings.escapeNixString (toString curlOpts)};
139139+ - If you wish for each list element to be passed as a separate curl argument, allowing arguments to contain spaces, use curlOptsList instead:
140140+ curlOptsList = [ ${lib.concatMapStringsSep " " lib.strings.escapeNixString curlOpts} ];'' true;
141141+135142stdenvNoCC.mkDerivation ((
136143 if (pname != "" && version != "") then
137144 { inherit pname version; }
···161168162169 outputHashMode = if (recursiveHash || executable) then "recursive" else "flat";
163170164164- curlOpts = lib.warnIf (lib.isList curlOpts) ''
165165- fetchurl for ${toString (builtins.head urls_)}: curlOpts is a list (${lib.generators.toPretty { multiline = false; } curlOpts}), which is not supported anymore.
166166- - 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:
167167- curlOpts = ${lib.strings.escapeNixString (toString curlOpts)};
168168- - If you wish for each list element to be passed as a separate curl argument, allowing arguments to contain spaces, use curlOptsList instead:
169169- curlOptsList = [ ${lib.concatMapStringsSep " " lib.strings.escapeNixString curlOpts} ];'' curlOpts;
171171+ inherit curlOpts;
170172 curlOptsList = lib.escapeShellArgs curlOptsList;
171173 inherit showURLs mirrorsFile postFetch downloadToTemp executable;
172174
+21-34
pkgs/build-support/fetchzip/default.nix
···7788{ lib, fetchurl, unzip, glibcLocalesUtf8 }:
991010-{ # Optionally move the contents of the unpacked tree up one level.
1111- stripRoot ? true
1010+{ name ? "source"
1211, url ? ""
1312, urls ? []
1414-, extraPostFetch ? ""
1313+, nativeBuildInputs ? []
1514, postFetch ? ""
1616-, name ? "source"
1717-, pname ? ""
1818-, version ? ""
1919-, nativeBuildInputs ? [ ]
2020-, # Allows to set the extension for the intermediate downloaded
2121- # file. This can be used as a hint for the unpackCmdHooks to select
2222- # an appropriate unpacking tool.
2323- extension ? null
2424-, ... } @ args:
1515+, extraPostFetch ? ""
25161717+# Optionally move the contents of the unpacked tree up one level.
1818+, stripRoot ? true
1919+# Allows to set the extension for the intermediate downloaded
2020+# file. This can be used as a hint for the unpackCmdHooks to select
2121+# an appropriate unpacking tool.
2222+, extension ? null
26232727-lib.warnIf (extraPostFetch != "") "use 'postFetch' instead of 'extraPostFetch' with 'fetchzip' and 'fetchFromGitHub'."
2424+# the rest are given to fetchurl as is
2525+, ... } @ args:
2626+2727+assert (extraPostFetch != "") -> lib.warn "use 'postFetch' instead of 'extraPostFetch' with 'fetchzip' and 'fetchFromGitHub'." true;
28282929-(let
2929+let
3030 tmpFilename =
3131 if extension != null
3232 then "download.${extension}"
3333 else baseNameOf (if url != "" then url else builtins.head urls);
3434in
35353636-fetchurl ((
3737- if (pname != "" && version != "") then
3838- {
3939- name = "${pname}-${version}";
4040- inherit pname version;
4141- }
4242- else
4343- { inherit name; }
4444-) // {
3636+fetchurl ({
3737+ inherit name;
4538 recursiveHash = true;
46394740 downloadToTemp = true;
···6154 mv "$downloadedFile" "$renamed"
6255 unpackFile "$renamed"
6356 chmod -R +w "$unpackDir"
6464- ''
6565- + (if stripRoot then ''
5757+ '' + (if stripRoot then ''
6658 if [ $(ls -A "$unpackDir" | wc -l) != 1 ]; then
6759 echo "error: zip file must contain a single file or directory."
6860 echo "hint: Pass stripRoot=false; to fetchzip to assume flat list of files."
···7567 mv "$unpackDir/$fn" "$out"
7668 '' else ''
7769 mv "$unpackDir" "$out"
7878- '')
7979- + ''
7070+ '') + ''
8071 ${postFetch}
8181- '' + ''
8272 ${extraPostFetch}
8383- ''
8484-8585- # Remove non-owner write permissions
8686- # Fixes https://github.com/NixOS/nixpkgs/issues/38649
8787- + ''
8873 chmod 755 "$out"
8974 '';
9090-} // removeAttrs args [ "stripRoot" "extraPostFetch" "postFetch" "extension" "nativeBuildInputs" ]))
7575+ # ^ Remove non-owner write permissions
7676+ # Fixes https://github.com/NixOS/nixpkgs/issues/38649
7777+} // removeAttrs args [ "stripRoot" "extraPostFetch" "postFetch" "extension" "nativeBuildInputs" ])