1 if [ -e "$NIX_ATTRS_SH_FILE" ]; then .
"$NIX_ATTRS_SH_FILE"; elif [ -f .attrs.sh
]; then . .attrs.sh
; fi
6 curlVersion
=$
(curl
-V |
head -1 | cut
-d' ' -f2)
8 # Curl flags to handle redirects, not use EPSV, handle cookies for
9 # servers to need them during redirects, and work on SSL without a
10 # certificate (this isn't a security problem because we check the
11 # cryptographic hash of the output anyway).
19 --user-agent "curl/$curlVersion Nixpkgs/$nixpkgsVersion"
22 if ! [ -f "$SSL_CERT_FILE" ]; then
26 eval "curl+=($curlOptsList)"
34 if [ -n "$downloadToTemp" ]; then downloadedFile
="$TMPDIR/file"; fi
45 # if we get error code 18, resume partial download
46 while [ $curlexit -eq 18 ]; do
47 # keep this inside an if statement, since on failure it doesn't abort the script
48 if "${curl[@]}" -C - --fail "$url" --output "$downloadedFile"; then
59 local skipPostFetch
="$1"
63 if [[ $executable == "1" ]]; then
64 chmod +x
$downloadedFile
67 if [ -z "$skipPostFetch" ]; then
76 if test -n "$NIX_HASHED_MIRRORS"; then
77 hashedMirrors
="$NIX_HASHED_MIRRORS"
80 for mirror
in $hashedMirrors; do
81 url
="$mirror/$outputHashAlgo/$outputHash"
82 if "${curl[@]}" --retry 0 --connect-timeout "${NIX_CONNECT_TIMEOUT:-15}" \
83 --fail --silent --show-error --head "$url" \
84 --write-out "%{http_code}" --output /dev
/null
> code
2> log
; then
87 # We skip postFetch here, because hashed-mirrors are
88 # already content addressed. So if $outputHash is in the
89 # hashed-mirror, changes from ‘postFetch’ would already be
90 # made. So, running postFetch will end up applying the
91 # change /again/, which we don’t want.
92 if test -n "$success"; then finish skipPostFetch
; fi
94 # Be quiet about 404 errors, which we interpret as the file
95 # not being present on this particular mirror.
96 if test "$(cat code)" != 404; then
97 echo "error checking the existence of $url:"
105 # URL list may contain ?. No glob expansion for that, please
110 if test "${url:0:9}" != "mirror://"; then
113 url2
="${url:9}"; echo "${url2/\// }" > split; read site fileName
< split
114 #varName="mirror_$site"
115 varName
="$site" # !!! danger of name clash, fix this
116 if test -z "${!varName}"; then
117 echo "warning: unknown mirror:// site \`$site'"
121 # Allow command-line override by setting NIX_MIRRORS_$site.
122 varName
="NIX_MIRRORS_$site"
123 if test -n "${!varName}"; then mirrors
="${!varName}"; fi
125 for url3
in $mirrors; do
126 urls2
="$urls2 $url3$fileName";
133 # Restore globbing settings
136 if test -n "$showURLs"; then
141 if test -n "$preferHashedMirrors"; then
145 # URL list may contain ?. No glob expansion for that, please
150 if [ -z "$postFetch" ]; then
152 https
://github.com
/*/archive
/*)
153 echo "warning: archives from GitHub revisions should use fetchFromGitHub"
155 https
://gitlab.com
/*/-/archive
/*)
156 echo "warning: archives from GitLab revisions should use fetchFromGitLab"
161 if test -n "$success"; then finish
; fi
164 # Restore globbing settings
167 if test -z "$preferHashedMirrors"; then
172 echo "error: cannot download $name from any mirror"