about summary refs log tree commit diff
path: root/src/libstore/builtins.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/libstore/builtins.cc')
-rw-r--r--src/libstore/builtins.cc15
1 files changed, 9 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"));