tarball '...' contains an unexpected number of top-level files #1177

Open
opened 2026-04-06 03:15:42 +00:00 by mrshmllow · 3 comments

Describe the bug

I've recently had this problem using tarballs from https://tangled.org/ as flake inputs:

$ nix flake metadata https://tangled.org/@althaea.zone/candy/archive/trunk.tar.gz
error:
       … while fetching the input 'https://tangled.org/@althaea.zone/candy/archive/trunk.tar.gz'

       error: tarball 'https://tangled.org/@althaea.zone/candy/archive/trunk.tar.gz' contains an unexpected number of top-level files

Which appears to be a regression from nix.

Steps To Reproduce

  1. Try and fetch a flake tarball from tangled.

Expected behavior

Nixcpp does not have any issue using the tarball:

$ nix run github:nixos/nixpkgs/nixos-unstable#nix -- --version
nix (Nix) 2.31.3

$ nix run github:nixos/nixpkgs/nixos-unstable#nix -- flake metadata https://tangled.org/@althaea.zone/candy/archive/trunk.tar.gz
warning: unknown experimental feature 'pipe-operator'
Resolved URL:  https://tangled.org/@althaea.zone/candy/archive/trunk.tar.gz
...

nix --version output

nix (Lix, like Nix) 2.94.0
System type: x86_64-linux
Additional system types: i686-linux, x86_64-v1-linux, x86_64-v2-linux, x86_64-v3-linux
Features: gc, signed-caches
System configuration file: /etc/nix/nix.conf
User configuration files: /home/marsh/.config/nix/nix.conf:/nix/store/jhxjf5qmvzqvskpyas884ild1gvz2dqx-stylix-kde-config/nix/nix.conf:/etc/xdg/nix/nix.conf:/home/marsh/.local/share/flatpak/exports/etc/xdg/nix/nix.conf:/var/lib/flatpak/exports/etc/xdg/nix/nix.conf:/home/marsh/.nix-profile/etc/xdg/nix/nix.conf:/nix/profile/etc/xdg/nix/nix.conf:/home/marsh/.local/state/nix/profile/etc/xdg/nix/nix.conf:/etc/profiles/per-user/marsh/etc/xdg/nix/nix.conf:/nix/var/nix/profiles/default/etc/xdg/nix/nix.conf:/run/current-system/sw/etc/xdg/nix/nix.conf:/nix/store/rr46kyd9vdfwvyif6xh8awdarg1scbkj-gnome-settings-daemon-49.1/etc/xdg/nix/nix.conf
Store directory: /nix/store
State directory: /nix/var/nix
Data directory: /nix/store/0zqbw17irvj0c71wn6cjbmcg2v04gzvd-lix-2.94.0/share
## Describe the bug I've recently had this problem using tarballs from https://tangled.org/ as flake inputs: ``` $ nix flake metadata https://tangled.org/@althaea.zone/candy/archive/trunk.tar.gz error: … while fetching the input 'https://tangled.org/@althaea.zone/candy/archive/trunk.tar.gz' error: tarball 'https://tangled.org/@althaea.zone/candy/archive/trunk.tar.gz' contains an unexpected number of top-level files ``` Which appears to be a regression from nix. ## Steps To Reproduce 1. Try and fetch a flake tarball from tangled. ## Expected behavior Nixcpp does not have any issue using the tarball: ``` $ nix run github:nixos/nixpkgs/nixos-unstable#nix -- --version nix (Nix) 2.31.3 $ nix run github:nixos/nixpkgs/nixos-unstable#nix -- flake metadata https://tangled.org/@althaea.zone/candy/archive/trunk.tar.gz warning: unknown experimental feature 'pipe-operator' Resolved URL: https://tangled.org/@althaea.zone/candy/archive/trunk.tar.gz ... ``` ## `nix --version` output ``` nix (Lix, like Nix) 2.94.0 System type: x86_64-linux Additional system types: i686-linux, x86_64-v1-linux, x86_64-v2-linux, x86_64-v3-linux Features: gc, signed-caches System configuration file: /etc/nix/nix.conf User configuration files: /home/marsh/.config/nix/nix.conf:/nix/store/jhxjf5qmvzqvskpyas884ild1gvz2dqx-stylix-kde-config/nix/nix.conf:/etc/xdg/nix/nix.conf:/home/marsh/.local/share/flatpak/exports/etc/xdg/nix/nix.conf:/var/lib/flatpak/exports/etc/xdg/nix/nix.conf:/home/marsh/.nix-profile/etc/xdg/nix/nix.conf:/nix/profile/etc/xdg/nix/nix.conf:/home/marsh/.local/state/nix/profile/etc/xdg/nix/nix.conf:/etc/profiles/per-user/marsh/etc/xdg/nix/nix.conf:/nix/var/nix/profiles/default/etc/xdg/nix/nix.conf:/run/current-system/sw/etc/xdg/nix/nix.conf:/nix/store/rr46kyd9vdfwvyif6xh8awdarg1scbkj-gnome-settings-daemon-49.1/etc/xdg/nix/nix.conf Store directory: /nix/store State directory: /nix/var/nix Data directory: /nix/store/0zqbw17irvj0c71wn6cjbmcg2v04gzvd-lix-2.94.0/share ```
Owner

This is behavior we inherited from CppNix 2.18 (the version of CppNix we largely forked from). I think there was a discussion about this some time ago but I cannot find or remember it… cc @pennae, @jade.

See also: #582.

This is behavior we inherited from CppNix 2.18 (the version of CppNix we largely forked from). I think there was a discussion about this some time ago but I cannot find or remember it… cc @pennae, @jade. See also: #582.
Owner

can't find or remember it either :/ technically there's no reason we couldn't do the same thing as cppnix and extract a tarball that doesn't contain a single toplevel directory as though it did and all the contents of the tarball were in that directory, but then we run into problems with eg tangled.org repos that contain a single toplevel directory in which everything happens. that directory would be unpacked same as it would now, but other tangled repos would not get this treatment. this would be very confusing and we are thus opposed to doing any such thing.

we're in a fucked up situation here. we either copy broken cppnix behavior, do something like https://gerrit.lix.systems/c/lix/+/1672 and thus change the lock format in incompatible ways, or we add a new tarball fetcher url schema that comes without the strip-root semantics (combining all the bad things of the previous solutions with none of the good things). considering that unpacking tarballs in the format tangled produces is generally fucked up we'd strongly suggest to file a bug with tangled instead

can't find or remember it either :/ technically there's no reason we couldn't do the same thing as cppnix and extract a tarball that doesn't contain a single toplevel directory as though it did and all the contents of the tarball were in that directory, but then we run into problems with eg tangled.org repos that contain a single toplevel directory in which everything happens. that directory would be unpacked same as it would now, but other tangled repos would not get this treatment. this would be very confusing and we are thus opposed to doing any such thing. we're in a fucked up situation here. we either copy broken cppnix behavior, do something like https://gerrit.lix.systems/c/lix/+/1672 and thus change the lock format in incompatible ways, or we add a new tarball fetcher url schema that comes without the strip-root semantics (combining all the bad things of the previous solutions with none of the good things). considering that unpacking tarballs in the format tangled produces is generally fucked up we'd strongly suggest to file a bug with tangled instead
Author

This is just tangled-specific information if anyone else is having this issue with tanlged:

I did some poking around in their source code, and the archive URL supports a prefix param, which wraps the contents in a single directory. It sounded like this would solve the problem, however, lix has another little quirk:

$ nix flake metadata "https://tangled.org/@althaea.zone/candy/archive/trunk?prefix=flake"
error: unsupported tarball input attribute 'prefix'. If you wanted to fetch a tarball with a query parameter, please use '{ type = "tarball"; url = "..."; }'

Not sure what that means. Anyway, this is largely avoidable if you just use git flakerefs in the form git+https://tangled.org/...

This is just tangled-specific information if anyone else is having this issue with tanlged: I did some poking around in their source code, and the archive URL supports a `prefix` param, which wraps the contents in a single directory. It sounded like this would solve the problem, however, lix has another little quirk: ``` $ nix flake metadata "https://tangled.org/@althaea.zone/candy/archive/trunk?prefix=flake" error: unsupported tarball input attribute 'prefix'. If you wanted to fetch a tarball with a query parameter, please use '{ type = "tarball"; url = "..."; }' ``` Not sure what that means. Anyway, this is largely avoidable if you just use git flakerefs in the form `git+https://tangled.org/...`
Sign in to join this conversation.
No milestone
No project
No assignees
3 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
lix-project/lix#1177
No description provided.