Navigation Menu

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Try to substitute builtins.fetch* #3721

Closed
wants to merge 1 commit into from

Conversation

matthewbauer
Copy link
Member

builtins.fetch* aren’t technically derivations, so they never got
substituted. To work around this, we can try to substitute this store
path during evaluation. This can happen any time a hash is provided.

builtins.fetch* aren’t technically derivations, so they never got
substituted. To work around this, we can try to substitute this store
path during evaluation. This can happen any time a hash is provided.
@edolstra
Copy link
Member

Please check the flakes branch, it already does this:

td::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(std::move(actualPath), std::move(storePath)), *this};
        } catch (Error & e) {
            debug("substitution of input '%s' failed: %s", to_string(), e.what());
        }
    }

@matthewbauer
Copy link
Member Author

Actually this just applies to fetchTree right? I think it would still be useful for builtins.fetchurl & builtins.fetchTarball. I can make it match what fetchTree does though.

@Ericson2314
Copy link
Member

I get the other builtins.fetch* in https://github.com/NixOS/nix/pull/3754/files, but this might be still useful as an intermediate step.

@matthewbauer
Copy link
Member Author

Since fetchTree can do substitution on tarballs, I think we are mostly covered just doing fetchTree everywhere.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants