diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/libstore/builtins.cc | 15 | ||||
-rw-r--r-- | src/libstore/globals.hh | 3 |
2 files changed, 12 insertions, 6 deletions
diff --git a/src/libstore/builtins.cc b/src/libstore/builtins.cc index 8a5cf3327d44..b51b6f85cb0c 100644 --- a/src/libstore/builtins.cc +++ b/src/libstore/builtins.cc @@ -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")); diff --git a/src/libstore/globals.hh b/src/libstore/globals.hh index c8d67b07110b..9ebbf7b477bb 100644 --- a/src/libstore/globals.hh +++ b/src/libstore/globals.hh @@ -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."}; }; |