Skip to content

Commit 2a1e98f

Browse files
committed
fetchdarcs: add mirror support
1 parent 5f53a02 commit 2a1e98f

File tree

2 files changed

+21
-5
lines changed

2 files changed

+21
-5
lines changed

pkgs/build-support/fetchdarcs/builder.sh

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,19 @@ elif test -n "$context"; then
1414
tagflags="--context=$context"
1515
fi
1616

17-
echo "Cloning $url ${tagtext} into $out"
17+
# Repository list may contain ?. No glob expansion for that.
18+
set -o noglob
1819

19-
darcs clone --lazy $tagflags "$url" "$out"
20-
# remove metadata, because it can change
21-
rm -rf "$out/_darcs"
20+
for repository in $repositories; do
21+
echo "Trying to clone $repository $tagtext into $out"
22+
if darcs clone --lazy $tagflags "$repository" "$out"; then
23+
# remove metadata, because it can change
24+
rm -rf "$out/_darcs"
25+
exit 0
26+
fi
27+
done
28+
29+
set +o noglob
30+
31+
echo "Error: couldn’t clone repository from any mirror" 1>&2
32+
exit 1

pkgs/build-support/fetchdarcs/default.nix

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@
88
lib.makeOverridable (
99
lib.fetchers.withNormalizedHash { } (
1010
{
11+
# Repository to fetch
1112
url,
13+
# Additional list of repositories specifying alternative download
14+
# location to be tried in order, if the prior repository failed to fetch.
15+
mirrors ? [ ],
1216
rev ? null,
1317
context ? null,
1418
outputHash ? lib.fakeHash,
@@ -27,11 +31,12 @@ lib.makeOverridable (
2731
outputHashMode = "recursive";
2832

2933
inherit
30-
url
3134
rev
3235
context
3336
name
3437
;
38+
39+
repositories = [ url ] ++ mirrors;
3540
}
3641
)
3742
)

0 commit comments

Comments
 (0)