Skip to content

Commit a3b7a15

Browse files
committed
fetchpijul: add mirror support
1 parent 33731f8 commit a3b7a15

File tree

1 file changed

+25
-7
lines changed

1 file changed

+25
-7
lines changed

pkgs/build-support/fetchpijul/default.nix

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@
77

88
lib.makeOverridable (
99
{
10+
# Remote to fetch
1011
url,
12+
# Additional list of remotes specifying alternative download location to be
13+
# tried in order, if the prior remote failed to fetch.
14+
mirrors ? [ ],
1115
hash ? "",
1216
change ? null,
1317
state ? null,
@@ -36,12 +40,25 @@ lib.makeOverridable (
3640
installPhase = ''
3741
runHook preInstall
3842
39-
pijul clone \
40-
''${change:+--change "$change"} \
41-
''${state:+--state "$state"} \
42-
--channel "$channel" \
43-
"$url" \
44-
"$out"
43+
success=
44+
for remote in $remotes; do
45+
if
46+
pijul clone \
47+
''${change:+--change "$change"} \
48+
''${state:+--state "$state"} \
49+
--channel "$channel" \
50+
"$remote" \
51+
"$out"
52+
then
53+
success=1
54+
break
55+
fi
56+
done
57+
58+
if [ -z "$success" ]; then
59+
echo "Error: couldn’t clone remote from any mirror" 1>&2
60+
exit 1
61+
fi
4562
4663
runHook postInstall
4764
'';
@@ -59,12 +76,13 @@ lib.makeOverridable (
5976
outputHash = if hash != "" then hash else lib.fakeHash;
6077

6178
inherit
62-
url
6379
change
6480
state
6581
channel
6682
;
6783

84+
remotes = [ url ] ++ mirrors;
85+
6886
impureEnvVars = lib.fetchers.proxyImpureEnvVars;
6987
}
7088
)

0 commit comments

Comments
 (0)