NixOS / nix

Nix, the purely functional package manager
https://nixos.org/
GNU Lesser General Public License v2.1
11.54k stars 1.45k forks source link

fetchTarball does not support hard links #10395

Closed holaguz closed 1 day ago

holaguz commented 3 months ago

Describe the bug

A custom derivation using fetchTarball suddenly stopped building.

Full error log ``` evaluating file '' evaluating file '/nix/store/sa8wlkyv4zvzkrx2a034ikfsn7iaj2k3-nixos-23.11-23.11/nixos-23.11/default.nix' evaluating file '/nix/store/sa8wlkyv4zvzkrx2a034ikfsn7iaj2k3-nixos-23.11-23.11/nixos-23.11/lib/minver.nix' evaluating file '/nix/store/sa8wlkyv4zvzkrx2a034ikfsn7iaj2k3-nixos-23.11-23.11/nixos-23.11/pkgs/top-level/impure.nix' evaluating file '/nix/store/sa8wlkyv4zvzkrx2a034ikfsn7iaj2k3-nixos-23.11-23.11/nixos-23.11/pkgs/top-level/default.nix' evaluating file '/nix/store/sa8wlkyv4zvzkrx2a034ikfsn7iaj2k3-nixos-23.11-23.11/nixos-23.11/lib/default.nix' evaluating file '/nix/store/sa8wlkyv4zvzkrx2a034ikfsn7iaj2k3-nixos-23.11-23.11/nixos-23.11/lib/fixed-points.nix' evaluating file '/nix/store/sa8wlkyv4zvzkrx2a034ikfsn7iaj2k3-nixos-23.11-23.11/nixos-23.11/lib/trivial.nix' evaluating file '/nix/store/sa8wlkyv4zvzkrx2a034ikfsn7iaj2k3-nixos-23.11-23.11/nixos-23.11/lib/lists.nix' evaluating file '/nix/store/sa8wlkyv4zvzkrx2a034ikfsn7iaj2k3-nixos-23.11-23.11/nixos-23.11/pkgs/stdenv/booter.nix' evaluating file '/nix/store/sa8wlkyv4zvzkrx2a034ikfsn7iaj2k3-nixos-23.11-23.11/nixos-23.11/pkgs/stdenv/default.nix' evaluating file '/nix/store/sa8wlkyv4zvzkrx2a034ikfsn7iaj2k3-nixos-23.11-23.11/nixos-23.11/lib/systems/default.nix' evaluating file '/nix/store/sa8wlkyv4zvzkrx2a034ikfsn7iaj2k3-nixos-23.11-23.11/nixos-23.11/lib/attrsets.nix' evaluating file '/nix/store/sa8wlkyv4zvzkrx2a034ikfsn7iaj2k3-nixos-23.11-23.11/nixos-23.11/lib/systems/inspect.nix' evaluating file '/nix/store/sa8wlkyv4zvzkrx2a034ikfsn7iaj2k3-nixos-23.11-23.11/nixos-23.11/lib/systems/architectures.nix' evaluating file '/nix/store/sa8wlkyv4zvzkrx2a034ikfsn7iaj2k3-nixos-23.11-23.11/nixos-23.11/lib/systems/parse.nix' evaluating file '/nix/store/sa8wlkyv4zvzkrx2a034ikfsn7iaj2k3-nixos-23.11-23.11/nixos-23.11/lib/strings.nix' evaluating file '/nix/store/sa8wlkyv4zvzkrx2a034ikfsn7iaj2k3-nixos-23.11-23.11/nixos-23.11/lib/types.nix' evaluating file '/nix/store/sa8wlkyv4zvzkrx2a034ikfsn7iaj2k3-nixos-23.11-23.11/nixos-23.11/lib/systems/platforms.nix' evaluating file '/nix/store/sa8wlkyv4zvzkrx2a034ikfsn7iaj2k3-nixos-23.11-23.11/nixos-23.11/lib/modules.nix' evaluating file '/nix/store/sa8wlkyv4zvzkrx2a034ikfsn7iaj2k3-nixos-23.11-23.11/nixos-23.11/pkgs/top-level/config.nix' evaluating file '/nix/store/sa8wlkyv4zvzkrx2a034ikfsn7iaj2k3-nixos-23.11-23.11/nixos-23.11/lib/options.nix' evaluating file '/nix/store/sa8wlkyv4zvzkrx2a034ikfsn7iaj2k3-nixos-23.11-23.11/nixos-23.11/pkgs/stdenv/linux/default.nix' evaluating file '/nix/store/sa8wlkyv4zvzkrx2a034ikfsn7iaj2k3-nixos-23.11-23.11/nixos-23.11/pkgs/stdenv/linux/bootstrap-tools/default.nix' evaluating file '/nix/store/sa8wlkyv4zvzkrx2a034ikfsn7iaj2k3-nixos-23.11-23.11/nixos-23.11/pkgs/top-level/stage.nix' evaluating file '/nix/store/sa8wlkyv4zvzkrx2a034ikfsn7iaj2k3-nixos-23.11-23.11/nixos-23.11/pkgs/stdenv/adapters.nix' evaluating file '/nix/store/sa8wlkyv4zvzkrx2a034ikfsn7iaj2k3-nixos-23.11-23.11/nixos-23.11/pkgs/build-support/trivial-builders/default.nix' evaluating file '/nix/store/sa8wlkyv4zvzkrx2a034ikfsn7iaj2k3-nixos-23.11-23.11/nixos-23.11/pkgs/top-level/splice.nix' evaluating file '/nix/store/sa8wlkyv4zvzkrx2a034ikfsn7iaj2k3-nixos-23.11-23.11/nixos-23.11/pkgs/top-level/by-name-overlay.nix' evaluating file '/nix/store/sa8wlkyv4zvzkrx2a034ikfsn7iaj2k3-nixos-23.11-23.11/nixos-23.11/pkgs/top-level/all-packages.nix' evaluating file '/nix/store/sa8wlkyv4zvzkrx2a034ikfsn7iaj2k3-nixos-23.11-23.11/nixos-23.11/pkgs/top-level/aliases.nix' evaluating file '/nix/store/sa8wlkyv4zvzkrx2a034ikfsn7iaj2k3-nixos-23.11-23.11/nixos-23.11/pkgs/stdenv/generic/default.nix' evaluating file '/nix/store/sa8wlkyv4zvzkrx2a034ikfsn7iaj2k3-nixos-23.11-23.11/nixos-23.11/lib/customisation.nix' evaluating file '/nix/store/sa8wlkyv4zvzkrx2a034ikfsn7iaj2k3-nixos-23.11-23.11/nixos-23.11/pkgs/build-support/bintools-wrapper/default.nix' evaluating file '/nix/store/sa8wlkyv4zvzkrx2a034ikfsn7iaj2k3-nixos-23.11-23.11/nixos-23.11/pkgs/stdenv/generic/make-derivation.nix' evaluating file '/nix/store/sa8wlkyv4zvzkrx2a034ikfsn7iaj2k3-nixos-23.11-23.11/nixos-23.11/lib/asserts.nix' evaluating file '/nix/store/sa8wlkyv4zvzkrx2a034ikfsn7iaj2k3-nixos-23.11-23.11/nixos-23.11/pkgs/development/tools/misc/binutils/default.nix' evaluating file '/nix/store/sa8wlkyv4zvzkrx2a034ikfsn7iaj2k3-nixos-23.11-23.11/nixos-23.11/pkgs/servers/x11/xorg/default.nix' evaluating file '/nix/store/sa8wlkyv4zvzkrx2a034ikfsn7iaj2k3-nixos-23.11-23.11/nixos-23.11/pkgs/servers/x11/xorg/overrides.nix' evaluating file '/nix/store/sa8wlkyv4zvzkrx2a034ikfsn7iaj2k3-nixos-23.11-23.11/nixos-23.11/pkgs/build-support/cc-wrapper/default.nix' evaluating file '/nix/store/sa8wlkyv4zvzkrx2a034ikfsn7iaj2k3-nixos-23.11-23.11/nixos-23.11/pkgs/stdenv/generic/check-meta.nix' evaluating file '/nix/store/sa8wlkyv4zvzkrx2a034ikfsn7iaj2k3-nixos-23.11-23.11/nixos-23.11/lib/meta.nix' evaluating file '/nix/store/sa8wlkyv4zvzkrx2a034ikfsn7iaj2k3-nixos-23.11-23.11/nixos-23.11/pkgs/stdenv/linux/bootstrap-files/x86_64-unknown-linux-gnu.nix' evaluating file '/nix/store/sa8wlkyv4zvzkrx2a034ikfsn7iaj2k3-nixos-23.11-23.11/nixos-23.11/pkgs/stdenv/linux/bootstrap-files/i686-unknown-linux-gnu.nix' evaluating file '' evaluating file '/nix/store/sa8wlkyv4zvzkrx2a034ikfsn7iaj2k3-nixos-23.11-23.11/nixos-23.11/pkgs/development/tools/misc/patchelf/default.nix' evaluating file '/nix/store/sa8wlkyv4zvzkrx2a034ikfsn7iaj2k3-nixos-23.11-23.11/nixos-23.11/pkgs/development/compilers/gcc/all.nix' evaluating file '/nix/store/sa8wlkyv4zvzkrx2a034ikfsn7iaj2k3-nixos-23.11-23.11/nixos-23.11/pkgs/development/compilers/gcc/versions.nix' evaluating file '/nix/store/sa8wlkyv4zvzkrx2a034ikfsn7iaj2k3-nixos-23.11-23.11/nixos-23.11/pkgs/development/compilers/gcc/default.nix' evaluating file '/nix/store/sa8wlkyv4zvzkrx2a034ikfsn7iaj2k3-nixos-23.11-23.11/nixos-23.11/lib/versions.nix' evaluating file '/nix/store/sa8wlkyv4zvzkrx2a034ikfsn7iaj2k3-nixos-23.11-23.11/nixos-23.11/pkgs/development/compilers/gcc/common/libgcc.nix' evaluating file '/nix/store/sa8wlkyv4zvzkrx2a034ikfsn7iaj2k3-nixos-23.11-23.11/nixos-23.11/pkgs/development/compilers/gcc/common/builder.nix' evaluating file '/nix/store/sa8wlkyv4zvzkrx2a034ikfsn7iaj2k3-nixos-23.11-23.11/nixos-23.11/pkgs/development/compilers/gcc/common/checksum.nix' evaluating file '/nix/store/sa8wlkyv4zvzkrx2a034ikfsn7iaj2k3-nixos-23.11-23.11/nixos-23.11/pkgs/development/libraries/glibc/default.nix' evaluating file '/nix/store/sa8wlkyv4zvzkrx2a034ikfsn7iaj2k3-nixos-23.11-23.11/nixos-23.11/pkgs/development/libraries/glibc/common.nix' evaluating file '/nix/store/sa8wlkyv4zvzkrx2a034ikfsn7iaj2k3-nixos-23.11-23.11/nixos-23.11/pkgs/os-specific/linux/kernel-headers/default.nix' evaluating file '/nix/store/sa8wlkyv4zvzkrx2a034ikfsn7iaj2k3-nixos-23.11-23.11/nixos-23.11/pkgs/development/libraries/gmp/6.x.nix' evaluating file '/nix/store/sa8wlkyv4zvzkrx2a034ikfsn7iaj2k3-nixos-23.11-23.11/nixos-23.11/pkgs/development/libraries/isl/0.20.0.nix' evaluating file '/nix/store/sa8wlkyv4zvzkrx2a034ikfsn7iaj2k3-nixos-23.11-23.11/nixos-23.11/pkgs/development/libraries/isl/generic.nix' evaluating file '/nix/store/sa8wlkyv4zvzkrx2a034ikfsn7iaj2k3-nixos-23.11-23.11/nixos-23.11/pkgs/development/libraries/libmpc/default.nix' evaluating file '/nix/store/sa8wlkyv4zvzkrx2a034ikfsn7iaj2k3-nixos-23.11-23.11/nixos-23.11/pkgs/development/libraries/mpfr/default.nix' evaluating file '/nix/store/sa8wlkyv4zvzkrx2a034ikfsn7iaj2k3-nixos-23.11-23.11/nixos-23.11/lib/licenses.nix' evaluating file '/nix/store/sa8wlkyv4zvzkrx2a034ikfsn7iaj2k3-nixos-23.11-23.11/nixos-23.11/lib/systems/doubles.nix' evaluating file '/nix/store/sa8wlkyv4zvzkrx2a034ikfsn7iaj2k3-nixos-23.11-23.11/nixos-23.11/pkgs/development/compilers/gcc/common/meta.nix' evaluating file '/nix/store/sa8wlkyv4zvzkrx2a034ikfsn7iaj2k3-nixos-23.11-23.11/nixos-23.11/maintainers/team-list.nix' evaluating file '/nix/store/sa8wlkyv4zvzkrx2a034ikfsn7iaj2k3-nixos-23.11-23.11/nixos-23.11/pkgs/development/libraries/zlib/default.nix' evaluating file '/nix/store/sa8wlkyv4zvzkrx2a034ikfsn7iaj2k3-nixos-23.11-23.11/nixos-23.11/pkgs/build-support/fetchurl/boot.nix' evaluating file '/nix/store/sa8wlkyv4zvzkrx2a034ikfsn7iaj2k3-nixos-23.11-23.11/nixos-23.11/pkgs/development/libraries/gnu-config/default.nix' evaluating file '/nix/store/sa8wlkyv4zvzkrx2a034ikfsn7iaj2k3-nixos-23.11-23.11/nixos-23.11/pkgs/development/libraries/gettext/default.nix' evaluating file '/nix/store/sa8wlkyv4zvzkrx2a034ikfsn7iaj2k3-nixos-23.11-23.11/nixos-23.11/pkgs/shells/bash/5.nix' evaluating file '/nix/store/sa8wlkyv4zvzkrx2a034ikfsn7iaj2k3-nixos-23.11-23.11/nixos-23.11/pkgs/shells/bash/bash-5.2-patches.nix' evaluating file '/nix/store/sa8wlkyv4zvzkrx2a034ikfsn7iaj2k3-nixos-23.11-23.11/nixos-23.11/pkgs/development/tools/parsing/bison/default.nix' evaluating file '/nix/store/sa8wlkyv4zvzkrx2a034ikfsn7iaj2k3-nixos-23.11-23.11/nixos-23.11/pkgs/development/tools/misc/gnum4/default.nix' evaluating file '/nix/store/sa8wlkyv4zvzkrx2a034ikfsn7iaj2k3-nixos-23.11-23.11/nixos-23.11/pkgs/build-support/fetchurl/mirrors.nix' evaluating file '/nix/store/sa8wlkyv4zvzkrx2a034ikfsn7iaj2k3-nixos-23.11-23.11/nixos-23.11/pkgs/development/interpreters/perl/default.nix' evaluating file '/nix/store/sa8wlkyv4zvzkrx2a034ikfsn7iaj2k3-nixos-23.11-23.11/nixos-23.11/pkgs/development/interpreters/perl/intepreter.nix' evaluating file '/nix/store/sa8wlkyv4zvzkrx2a034ikfsn7iaj2k3-nixos-23.11-23.11/nixos-23.11/pkgs/development/libraries/libxcrypt/default.nix' evaluating file '/nix/store/sa8wlkyv4zvzkrx2a034ikfsn7iaj2k3-nixos-23.11-23.11/nixos-23.11/pkgs/tools/compression/xz/default.nix' evaluating file '/nix/store/sa8wlkyv4zvzkrx2a034ikfsn7iaj2k3-nixos-23.11-23.11/nixos-23.11/pkgs/build-support/expand-response-params/default.nix' evaluating file '/nix/store/sa8wlkyv4zvzkrx2a034ikfsn7iaj2k3-nixos-23.11-23.11/nixos-23.11/pkgs/development/compilers/gcc/common/extra-target-flags.nix' evaluating file '/nix/store/sa8wlkyv4zvzkrx2a034ikfsn7iaj2k3-nixos-23.11-23.11/nixos-23.11/pkgs/development/compilers/gcc/common/dependencies.nix' evaluating file '/nix/store/sa8wlkyv4zvzkrx2a034ikfsn7iaj2k3-nixos-23.11-23.11/nixos-23.11/pkgs/development/compilers/gcc/common/configure-flags.nix' evaluating file '/nix/store/sa8wlkyv4zvzkrx2a034ikfsn7iaj2k3-nixos-23.11-23.11/nixos-23.11/pkgs/development/compilers/gcc/common/platform-flags.nix' evaluating file '/nix/store/sa8wlkyv4zvzkrx2a034ikfsn7iaj2k3-nixos-23.11-23.11/nixos-23.11/pkgs/development/tools/misc/texinfo/7.0.nix' evaluating file '/nix/store/sa8wlkyv4zvzkrx2a034ikfsn7iaj2k3-nixos-23.11-23.11/nixos-23.11/pkgs/development/tools/misc/texinfo/common.nix' evaluating file '/nix/store/sa8wlkyv4zvzkrx2a034ikfsn7iaj2k3-nixos-23.11-23.11/nixos-23.11/pkgs/tools/system/which/default.nix' evaluating file '/nix/store/sa8wlkyv4zvzkrx2a034ikfsn7iaj2k3-nixos-23.11-23.11/nixos-23.11/pkgs/development/compilers/gcc/patches/default.nix' evaluating file '/nix/store/sa8wlkyv4zvzkrx2a034ikfsn7iaj2k3-nixos-23.11-23.11/nixos-23.11/pkgs/build-support/nuke-references/default.nix' evaluating file '/nix/store/sa8wlkyv4zvzkrx2a034ikfsn7iaj2k3-nixos-23.11-23.11/nixos-23.11/pkgs/development/compilers/gcc/common/pre-configure.nix' evaluating file '/nix/store/sa8wlkyv4zvzkrx2a034ikfsn7iaj2k3-nixos-23.11-23.11/nixos-23.11/pkgs/development/compilers/gcc/common/strip-attributes.nix' evaluating file '/nix/store/sa8wlkyv4zvzkrx2a034ikfsn7iaj2k3-nixos-23.11-23.11/nixos-23.11/pkgs/development/interpreters/python/default.nix' evaluating file '/nix/store/sa8wlkyv4zvzkrx2a034ikfsn7iaj2k3-nixos-23.11-23.11/nixos-23.11/pkgs/development/interpreters/python/cpython/default.nix' evaluating file '/nix/store/sa8wlkyv4zvzkrx2a034ikfsn7iaj2k3-nixos-23.11-23.11/nixos-23.11/pkgs/development/interpreters/python/passthrufun.nix' evaluating file '/nix/store/sa8wlkyv4zvzkrx2a034ikfsn7iaj2k3-nixos-23.11-23.11/nixos-23.11/pkgs/tools/compression/bzip2/default.nix' evaluating file '/nix/store/sa8wlkyv4zvzkrx2a034ikfsn7iaj2k3-nixos-23.11-23.11/nixos-23.11/pkgs/development/libraries/expat/default.nix' evaluating file '/nix/store/sa8wlkyv4zvzkrx2a034ikfsn7iaj2k3-nixos-23.11-23.11/nixos-23.11/pkgs/development/libraries/libffi/default.nix' evaluating file '/nix/store/sa8wlkyv4zvzkrx2a034ikfsn7iaj2k3-nixos-23.11-23.11/nixos-23.11/pkgs/development/tools/misc/autoconf/default.nix' evaluating file '/nix/store/sa8wlkyv4zvzkrx2a034ikfsn7iaj2k3-nixos-23.11-23.11/nixos-23.11/pkgs/development/tools/misc/automake/automake-1.16.x.nix' evaluating file '/nix/store/sa8wlkyv4zvzkrx2a034ikfsn7iaj2k3-nixos-23.11-23.11/nixos-23.11/pkgs/development/tools/misc/libtool/libtool2.nix' evaluating file '/nix/store/sa8wlkyv4zvzkrx2a034ikfsn7iaj2k3-nixos-23.11-23.11/nixos-23.11/pkgs/tools/misc/file/default.nix' evaluating file '/nix/store/sa8wlkyv4zvzkrx2a034ikfsn7iaj2k3-nixos-23.11-23.11/nixos-23.11/pkgs/build-support/pkg-config-wrapper/default.nix' evaluating file '/nix/store/sa8wlkyv4zvzkrx2a034ikfsn7iaj2k3-nixos-23.11-23.11/nixos-23.11/pkgs/development/tools/misc/pkg-config/default.nix' evaluating file '/nix/store/sa8wlkyv4zvzkrx2a034ikfsn7iaj2k3-nixos-23.11-23.11/nixos-23.11/pkgs/development/tools/misc/autoconf-archive/default.nix' evaluating file '/nix/store/sa8wlkyv4zvzkrx2a034ikfsn7iaj2k3-nixos-23.11-23.11/nixos-23.11/pkgs/development/interpreters/python/setup-hook.nix' evaluating file '/nix/store/sa8wlkyv4zvzkrx2a034ikfsn7iaj2k3-nixos-23.11-23.11/nixos-23.11/pkgs/development/libraries/libidn2/default.nix' evaluating file '/nix/store/sa8wlkyv4zvzkrx2a034ikfsn7iaj2k3-nixos-23.11-23.11/nixos-23.11/pkgs/development/libraries/libunistring/default.nix' evaluating file '/nix/store/sa8wlkyv4zvzkrx2a034ikfsn7iaj2k3-nixos-23.11-23.11/nixos-23.11/pkgs/tools/misc/coreutils/default.nix' evaluating file '/nix/store/sa8wlkyv4zvzkrx2a034ikfsn7iaj2k3-nixos-23.11-23.11/nixos-23.11/pkgs/development/libraries/acl/default.nix' evaluating file '/nix/store/sa8wlkyv4zvzkrx2a034ikfsn7iaj2k3-nixos-23.11-23.11/nixos-23.11/pkgs/tools/text/gnugrep/default.nix' evaluating file '/nix/store/sa8wlkyv4zvzkrx2a034ikfsn7iaj2k3-nixos-23.11-23.11/nixos-23.11/pkgs/tools/text/gawk/default.nix' downloading 'https://www.gaisler.com/anonftp/bcc2/bin/bcc-2.2.1-gcc-linux64.tar.xz'... error: … while calling the 'derivationStrict' builtin at :9:12: 8| 9| strict = derivationStrict drvAttrs; | ^ 10| … while evaluating derivation 'gaisler-bcc-2.2.1' whose name attribute is located at /nix/store/sa8wlkyv4zvzkrx2a034ikfsn7iaj2k3-nixos-23.11-23.11/nixos-23.11/pkgs/stdenv/generic/make-derivation.nix:348:7 … while evaluating attribute 'src' of derivation 'gaisler-bcc-2.2.1' at /tmp/nix-bug/toolchain.nix:11:7: 10| name = "gaisler-bcc-${version}"; 11| src = builtins.fetchTarball { | ^ 12| url = tarballUrl; (stack trace truncated; use '--show-trace' to show the full trace) error: file 'bcc-2.2.1-gcc/bin/sparc-gaisler-elf-gcc' in tarball has unsupported file type ```

When importing the nix file using the repl, the error seems to appear after downloading a few MBs:

nix-repl> import ./toolchain.nix { pkgs = import <nixos-23.11> {}; }
{
[15.1/355.2 MiB DL] downloading 'https://www.gaisler.com/anonftp/bcc2/bin/bcc-2.2.1-gcc-linux64.tar.xz'«error: file 'bcc-2.2.1-gcc/bin/sparc-gaisler-elf-gcc' in tarball has unsupported file type»;
}

I was able to reproduce the error on both 23.11 and unstable channels, in two separate pcs:

I couldn't reproduce it on the following computer:


You can find the MRE down below:

toolchain.nix ```nix { pkgs }: let version = "2.2.1"; hash = "097z15zshr4711rzfr8ccwl8vzpxp7da573p89qmngxzrwxr4kwl"; tarballUrl = "https://www.gaisler.com/anonftp/bcc2/bin/bcc-${version}-gcc-linux64.tar.xz"; bccToolchain = pkgs.stdenv.mkDerivation { name = "gaisler-bcc-${version}"; src = builtins.fetchTarball { url = tarballUrl; sha256 = hash; }; }; in { inherit bccToolchain; } ```

Feel free to ping me if I missed any details.

holaguz commented 3 months ago

Oops, wrong repo.

Opened a new issue on nixpkgs: https://github.com/NixOS/nixpkgs/issues/301376

holaguz commented 3 months ago

Reopening this after the following comment: https://github.com/NixOS/nixpkgs/issues/301376#issuecomment-2038332592

pho commented 3 months ago

I'm also I'm triggering the same error on Arch & nix 2.21.1:

$ nix repl --expr 'builtins.fetchTarball { url = "http://more.musl.cc/11.2.1/x86_64-linux-musl/x86_64-linux-musl-cross.tgz"; }'
Nix 2.21.1
Type :? for help.
error:
       … while calling the 'fetchTarball' builtin
         at «string»:1:1:
            1| builtins.fetchTarball { url = "http://more.musl.cc/11.2.1/x86_64-linux-musl/x86_64-linux-musl-cross.tgz"; }
             | ^

       error: file 'x86_64-linux-musl-cross/bin/x86_64-linux-musl-gcc' in tarball has unsupported file type

Looks like the files which fetchTarball complains about are hardlinks, which (TIL) tar knows how to preserve Repacking the tgz files with tar --hard-dereference solves this, so my workaround has been to repack it, serve it locally and fetch it.

EDIT: I just updated to nix 2.21.2, and its still happening

pho commented 3 months ago

In case it's any help, I have git-bisected this and looks like https://github.com/NixOS/nix/commit/cabee9815239af426cece729cb765810b8a716ce might be the culprit

holaguz commented 3 months ago

The error is an exception being thrown on this file: https://github.com/NixOS/nix/blob/3fd8dfec4d0747e8f1129dc7f43c1f89fe3ba432/src/libutil/tarfile.cc#L223

Meaning the file is neither AE_IFDIR, AE_IFREG, or AE_IFLNK. For reference, these are the filetypes defined for libarchive:

man 3 archive_entry_stat:

   General accessor functions
       The functions archive_entry_filetype() and archive_entry_set_filetype() get respectively  set  the
       filetype.  The file type is one of the following constants:
             AE_IFREG   Regular file
             AE_IFLNK   Symbolic link
             AE_IFSOCK  Socket
             AE_IFCHR   Character device
             AE_IFBLK   Block device
             AE_IFDIR   Directory
             AE_IFIFO   Named pipe (fifo)

That's as far as I could dig since I'm not familiar with the source code nor libarchive.


Looks like the files which fetchTarball complains about are hardlinks, which (TIL) tar knows how to preserve

In my case bin/sparc-gaisler-elf-gcc is indeed a hardlink to bin/sparc-gaisler-elf-gcc-10.2.0

thufschmitt commented 3 months ago

Per https://github.com/libarchive/libarchive/blob/341800da257fb8c31b8b4281604fb7e3436b61f3/libarchive/archive_read_support_format_tar.c#L1219 , it seems like libarchive doesn't really use these accessor functions when unpacking tarfiles, but reads the tartype instead (both seem to be in sync, except for hardlinks which aren't handled by the AE_IF* family and for which archive_entry_filetype returns 0).

Maybe unpackTarfileToSink should follow that behavior.


For a more self-contained reproducer:

$ mkdir archive                        
$ touch archive/foo         
$ ln archive/foo archive/bar
$ tar cf archive.tar archive
$ nix-instantiate --eval --expr 'builtins.fetchTarball "file://'$PWD'/archive.tar"'
error:
       … while calling the 'fetchTarball' builtin
         at «string»:1:1:
            1| builtins.fetchTarball "file:///home/thufschmitt/Repos/nixos/nix/work/archive.tar"
             | ^

       error: file 'archive/bar' in tarball has unsupported file type
thufschmitt commented 3 months ago

Maybe unpackTarfileToSink should follow that behavior.

Contributions for that welcome ;)

infinisil commented 1 month ago

Since recently, Nixpkgs tarballs include hardlinks, which now causes issues because of this bug: https://github.com/NixOS/infra/issues/438

nixos-discourse commented 4 weeks ago

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

https://discourse.nixos.org/t/2024-06-10-nix-team-meeting-minutes-151/46956/1