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

builtins.fetchTarball with a single-file tarball produces an empty store path #10983

Closed
Silic0nS0ldier opened this issue Jun 28, 2024 · 3 comments · Fixed by #11195
Closed

builtins.fetchTarball with a single-file tarball produces an empty store path #10983

Silic0nS0ldier opened this issue Jun 28, 2024 · 3 comments · Fixed by #11195
Assignees
Labels
bug fetching Networking with the outside (non-Nix) world, input locking

Comments

@Silic0nS0ldier
Copy link

Describe the bug

Using a .tar.gz file which only contains a file with builtins.fetchTarball results in a derivation that is an empty directory.

This behaviour is inconsistent with nix-prefetch-url --unpack which is often cited as the recommended way to obtain sha256 for these fixed output derivations.

Steps To Reproduce

let
  dotslashPath = builtins.fetchTarball {
    url = "https://github.com/facebook/dotslash/releases/download/v0.4.1/dotslash-macos.v0.4.1.tar.gz";
  };
in
  dotslashPath
❯ nix-instantiate --eval ./testing.nix                  
"/nix/store/0ccnxa25whszw7mgbgyzdm4nqc0zwnm8-source"
❯ file /nix/store/0ccnxa25whszw7mgbgyzdm4nqc0zwnm8-source
/nix/store/0ccnxa25whszw7mgbgyzdm4nqc0zwnm8-source: directory
❯ ls -l /nix/store/0ccnxa25whszw7mgbgyzdm4nqc0zwnm8-source
total 0

Expected behavior

The documentation states that the top-level directory will be removed, but does not specify what happens when there is no top-level directory.

#4785 suggests that prior to a certain Nix release the file would have been extracted successfully. Looking back at a past release may help to inform what should happen.

My personal preference is that fetching of a single-file tarball would work, and that the filename be perserved (this does not happen with nix-prefetch-url --unpack, the file ends up being placed at the store path itself). If that is not possible, a clear error.

nix-env --version output

nix-env (Nix) 2.23.0

Additional context

Similar expected behaviour ambiguity to #4785

Priorities

Add 👍 to issues you find important.

@roberth roberth added the fetching Networking with the outside (non-Nix) world, input locking label Jul 1, 2024
@nixos-discourse
Copy link

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/2024-07-03-nix-team-meeting-minutes-158/49097/1

@roberth
Copy link
Member

roberth commented Jul 15, 2024

Triaged by the Nix team 2024-07-03 (apologies for the delay)
Relevant notes:

Somewhat related to the code tested here https://github.com/DeterminateSystems/nix-src/pull/1/files

Assigned to Eelco

@roberth
Copy link
Member

roberth commented Jul 15, 2024

Somewhat related to the code tested here https://github.com/DeterminateSystems/nix-src/pull/1/files

Something went wrong there.

The relevant test is https://github.com/NixOS/nix/pull/11077/files#diff-7b407c6754b02bc382cb4344e00c566919584fd7d75ab2624de5d4f6b32bab46

It shows the behavior of the file system object sink which should not describe tarball-specific behavior, but currently does.
This code is probably related to the problem, and I think we should change the GitFileSystemObjectSink to have more straightforward behavior, to make room for the tarball fetching code to handle the "complexity" of handling various layouts of tarball contents.

@edolstra edolstra changed the title builtins.fetchTarball with a single-file tarball produces an empty derivation builtins.fetchTarball with a single-file tarball produces an empty store path Jul 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug fetching Networking with the outside (non-Nix) world, input locking
Projects
None yet
4 participants