@@ -2,20 +2,24 @@ source $stdenv/setup
22
33source $mirrorsFile
44
5+curlVersion=$(curl -V | head -1 | cut -d' ' -f2)
56
67# Curl flags to handle redirects, not use EPSV, handle cookies for
78# servers to need them during redirects, and work on SSL without a
89# certificate (this isn't a security problem because we check the
910# cryptographic hash of the output anyway).
10−curl="curl \
11− --location --max-redirs 20 \
12− --retry 3 \
13− --disable-epsv \
14− --cookie-jar cookies \
15− --insecure \
16− $curlOpts \
17− $NIX_CURL_FLAGS"
18−
11+curl=(
12+ curl
13+ --location
14+ --max-redirs 20
15+ --retry 3
16+ --disable-epsv
17+ --cookie-jar cookies
18+ --insecure
19+ --user-agent "curl/$curlVersion Nixpkgs/$nixpkgsVersion"
20+ $curlOpts
21+ $NIX_CURL_FLAGS
22+)
1923
2024downloadedFile="$out"
2125if [ -n "$downloadToTemp" ]; then downloadedFile="$TMPDIR/file"; fi
@@ -32,7 +36,7 @@ tryDownload() {
3236 # if we get error code 18, resume partial download
3337 while [ $curlexit -eq 18 ]; do
3438 # keep this inside an if statement, since on failure it doesn't abort the script
35− if $curl -C - --fail "$url" --output "$downloadedFile"; then
39+ if "${curl[@]}" -C - --fail "$url" --output "$downloadedFile"; then
3640 success=1
3741 break
3842 else
@@ -61,7 +65,7 @@ tryHashedMirrors() {
6165
6266 for mirror in $hashedMirrors; do
6367 url="$mirror/$outputHashAlgo/$outputHash"
64− if $curl --retry 0 --connect-timeout "${NIX_CONNECT_TIMEOUT:-15}" \
68+ if "${curl[@]}" --retry 0 --connect-timeout "${NIX_CONNECT_TIMEOUT:-15}" \
6569 --fail --silent --show-error --head "$url" \
6670 --write-out "%{http_code}" --output /dev/null > code 2> log; then
6771 tryDownload "$url"