Skip to content

fetchTarball accepts ISO images (and likely many unexpected archive formats) #10917

@andir

Description

@andir

Describe the bug

The documentation states that fetchTarball requires the file to be tar file. Apparently that isn't entirely true and Nix happily consumes other files.

image

Steps To Reproduce

  1. Open a nix repl and paste nix-repl> builtins.readDir (builtins.fetchTarball "https://releases.nixos.org/nixos/24.05-small/nixos-24.05beta551.6d452319127a/nixos-minimal-24.05beta551.6d452319127a-x86_64-linux.iso")
  2. See that Nix happily downloaded the entire ISO and unpacked it into your store.

Expected behavior

It should fail to unpack the archive..
From the libarchive.org page it seems like the following formats are supported: tar, pax, cpio, zip, xar, lha, ar, cab, mtree, rar, and ISO images. I chose the iso test by random and that succeeded.

nix-env --version output

Additional context

I was trying to figure out what has to be supported to be feature compatible with fetchTarball while working on npins. My objective was to get rid of calling nix-prefetch-url as a subprocess in order to ship the program as a single statically linked binary..

Priorities

Add 👍 to issues you find important.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions