fetchTree: handle tarballs with multiple top-level files#9053
fetchTree: handle tarballs with multiple top-level files#9053fgaz wants to merge 1 commit intoNixOS:masterfrom
Conversation
roberth
left a comment
There was a problem hiding this comment.
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
filetype, it imposes a dependency on nixpkgs and makes implementation of other fetchers based ondownloadTarballmore 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.