1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-28 01:11:15 +02:00

Make the hashes mirrors used by builtins.fetchurl configurable

In particular, this allows it to be disabled in our tests.
This commit is contained in:
Eelco Dolstra 2017-07-17 13:07:08 +02:00
parent 4ec6eb1fdf
commit 49304bae81
No known key found for this signature in database
GPG key ID: 8170B4726D7198DE
4 changed files with 42 additions and 8 deletions

View file

@ -38,12 +38,15 @@ void builtinFetchurl(const BasicDerivation & drv, const std::string & netrcData)
std::shared_ptr<std::string> data;
try {
if (getAttr("outputHashMode") == "flat")
data = fetch("http://tarballs.nixos.org/" + getAttr("outputHashAlgo") + "/" + getAttr("outputHash"));
} catch (Error & e) {
debug(e.what());
}
if (getAttr("outputHashMode") == "flat")
for (auto hashedMirror : settings.hashedMirrors.get())
try {
if (!hasSuffix(hashedMirror, "/")) hashedMirror += '/';
data = fetch(hashedMirror + getAttr("outputHashAlgo") + "/" + getAttr("outputHash"));
break;
} catch (Error & e) {
debug(e.what());
}
if (!data) data = fetch(getAttr("url"));

View file

@ -327,6 +327,9 @@ public:
"Whether builders can acquire new privileges by calling programs with "
"setuid/setgid bits or with file capabilities."};
#endif
Setting<Strings> hashedMirrors{this, {"http://tarballs.nixos.org/"}, "hashed-mirrors",
"A list of servers used by builtins.fetchurl to fetch files by hash."};
};