diff options
author | John Ericson <John.Ericson@Obsidian.Systems> | 2020-08-19 03:17:41 +0000 |
---|---|---|
committer | John Ericson <John.Ericson@Obsidian.Systems> | 2020-08-19 03:17:41 +0000 |
commit | be0d429b954be61a533dabf62a928e2f44c39ac2 (patch) | |
tree | 21db19064e33e7d5c2ec8fe6b9c5caf3f99216fe /src/libstore/builtins/fetchurl.cc | |
parent | 8f92bb5ad9856daaa8488a5dad206b980a2aacb5 (diff) | |
parent | 1c8b550e34414d0f4cb0fa20322a2dfe06ce2de0 (diff) |
Merge branch 'master' of github.com:NixOS/nix into templated-daemon-protocol
Diffstat (limited to 'src/libstore/builtins/fetchurl.cc')
-rw-r--r-- | src/libstore/builtins/fetchurl.cc | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/libstore/builtins/fetchurl.cc b/src/libstore/builtins/fetchurl.cc index 6585a480d..4fb5d8a06 100644 --- a/src/libstore/builtins/fetchurl.cc +++ b/src/libstore/builtins/fetchurl.cc @@ -58,6 +58,20 @@ void builtinFetchurl(const BasicDerivation & drv, const std::string & netrcData) } }; + /* Try the hashed mirrors first. */ + if (getAttr("outputHashMode") == "flat") + for (auto hashedMirror : settings.hashedMirrors.get()) + try { + if (!hasSuffix(hashedMirror, "/")) hashedMirror += '/'; + std::optional<HashType> ht = parseHashTypeOpt(getAttr("outputHashAlgo")); + Hash h = newHashAllowEmpty(getAttr("outputHash"), ht); + fetch(hashedMirror + printHashType(h.type) + "/" + h.to_string(Base16, false)); + return; + } catch (Error & e) { + debug(e.what()); + } + + /* Otherwise try the specified URL. */ fetch(mainUrl); } |