1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-12-15 13:31:05 +01:00

Move substitution into Input::fetch()

Closes #3520.
This commit is contained in:
Eelco Dolstra 2020-05-30 01:16:53 +02:00
parent 0e7f77a59a
commit 89e0b3e2d6
3 changed files with 20 additions and 55 deletions

View file

@ -103,6 +103,26 @@ std::pair<Tree, Input> Input::fetch(ref<Store> store) const
if (!scheme)
throw Error("cannot fetch unsupported input '%s'", attrsToJson(toAttrs()));
/* The tree may already be in the Nix store, or it could be
substituted (which is often faster than fetching from the
original source). So check that. */
if (hasAllInfo()) {
try {
auto storePath = computeStorePath(*store);
store->ensurePath(storePath);
debug("using substituted/cached input '%s' in '%s'",
to_string(), store->printStorePath(storePath));
auto actualPath = store->toRealPath(storePath);
return {fetchers::Tree { .actualPath = actualPath, .storePath = std::move(storePath) }, *this};
} catch (Error & e) {
debug("substitution of input '%s' failed: %s", to_string(), e.what());
}
}
auto [tree, input] = scheme->fetch(store, *this);
if (tree.actualPath == "")