-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
fetchTree: handle tarballs with multiple top-level files #9053
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs a test in tests/tarball.sh
001c3fb
to
3957e71
Compare
Issue NixOS#7083 suggests two solutions to this problem: 1. If there are multiple top-level files, use the archive root 2. A stripRoot attribute, like in nixpkgs' fetchzip This patch implements (1). It is forward-compatible with (2) if a missing stripRoot is interpreted as "automatic". Fixes NixOS#7083
3957e71
to
bfd1ba8
Compare
I'd prefer not to do this. The lazy-trees branch completely changes how tarballs are handled (they're imported into a local git cache and accessed from there), and it's not clear how to handle tarballs with more than one root object. |
@edolstra Why isn't it clear? Is it because we don't know whether to strip the root until all entries are processed? If so, what about a |
@fgaz That seems to be a good solution (defaulting it to |
libgit should make this quite easy. Assuming you want to have a streaming implementation, you stream all the contents into blobs, and keep all directory entries, in the original tarball layout at first (probably in memory, because maintaining such a data structure on disk would be inefficient - could be done though, don't care). At the end, you check whether the raw root contains a single directory. If it does, you return its contents instead of the root.
I'm not so sure about that. Less "configuration" is generally better. |
Triaged in Nix team meeting:
|
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/2023-11-24-nix-team-meeting-minutes-106/35955/1 |
+1 |
I just noticed #9485 contains the lazy trees part that was mentioned by @fricklerhandwerk. @edolstra do you accept PRs targeting your branch? Should I wait until #9485 lands? |
Are there any workarounds on how to handle zip flake inputs with mutiple files in the meantime? |
Hm, true, but has the downside of having to provide and update the hash myself instead of it being managed in |
You can still have it as a flake input using the file input type |
Motivation
See #7083. While the issue can be worked around by using the
file
type, it imposes a dependency on nixpkgs and makes implementation of other fetchers based ondownloadTarball
more difficult.Context
Issue #7083 suggests two solutions to this problem:
This patch implements (1). It is forward-compatible with (2) if a missing stripRoot is interpreted as "automatic".
Fixes #7083
Priorities
Add 👍 to pull requests you find important.