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:
parent
4ec6eb1fdf
commit
49304bae81
4 changed files with 42 additions and 8 deletions
|
@ -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"));
|
||||
|
||||
|
|
|
@ -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."};
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue