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

Add builtins.fetchGitArchive (WIP) #8149

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

bergkvist
Copy link
Member

Motivation

When working with private repos, it is desirable to interface with the users local git config to avoid checking secrets into the nix store. builtins.fetchGit currently allows for this, but can be slow for large repositories.

Thanks to git-archive - specific versions of these large private repositories can be checked out much more quickly (20s instead of 1h in my case)

There are some quirks though:

Context

See #8134

Checklist for maintainers

Maintainers: tick if completed or explain if not relevant

  • agreed on idea
  • agreed on implementation strategy
  • tests, as appropriate
    • functional tests - tests/**.sh
    • unit tests - src/*/tests
    • integration tests - tests/nixos/*
  • documentation in the manual
  • code and comments are self-explanatory
  • commit message explains why the change was made
  • new feature or incompatible change: updated release notes

Priorities

Add 👍 to pull requests you find important.

@bergkvist bergkvist requested a review from edolstra as a code owner April 2, 2023 03:45
@bjornfor
Copy link
Contributor

bjornfor commented Apr 2, 2023

The 1h runtime, was that with shallow/depth=1?

@bergkvist
Copy link
Member Author

The 1h runtime, was that with shallow/depth=1?

I just tested with shallow = true; now, and it took ~30 minutes (28.02s user 10.33s system 2% cpu 30:39.64 total).

time nix-instantiate -E --eval 'fetchGit { url="git@gitlab.example.com:private/repo"; ref = "refs/tags/v1.2.3"; shallow = true; }'

@edolstra
Copy link
Member

edolstra commented Apr 3, 2023

This should probably be a libfetcher input type, or maybe just an attribute for the git fetcher (e.g. archive = true). That way these archives can be used as flake inputs.

@roberth
Copy link
Member

roberth commented Apr 3, 2023

How does this relate to the archive for example the archive endpoint semantics on github? Specifically, it distinguishes between commits and trees.

  • commit hash: apply export-ignore
  • tree hash: serialize a tree without much processing

By understanding the semantics, we can have a better cache utilization (fewer unique keys), and we could switch between the three methods transparently. (regular git protocol, archive over git protocol, archive over forge api)

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.

4 participants