Allow overriding the tarball fetcher #62
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This change allows the caller to replace the
fetchTarball
used for fetching the inputs of the flake withpkgs.fetchzip
, which works as a drop-in replacement. The difference is thatbuiltins.fetchTarball
does the fetching at Nix evaluation time, whilepkgs.fetchzip
does the fetching at build time. The distinction becomes crucial when one attempts to build a flake output inside arecursive-nix
derivation. A vanillanix build ${someFlake}
or anix-build default.nix
using the currentflake-compat
will fail inside a recursive Nix whenfetchTarball
attempts to download the tarball, but the following derivation (using theflake-compat
from this PR) will successfully build (on a system withrecursive-nix
):In the above Nix expression, if you remove the
fetchTarball
argument from line 11, then the build will fail with:Building a flake recursively like this allows us to hide its evaluation inside a derivation, which can be a world of difference in some cases (see this discussion thread I've opened a few months ago where I've explained in detail how bad this can get).
This approach essentially allows us to get a kind of nix flake output evaluation caching as part of a larger Nix evaluation.