Can flakes take zip input without a subfolder

I have a flake that depends on a information in a zip file provided by a third party. This zip file includes all of its contents at the top level, instead of within sub-directories.

This causes a problem with fetchTarball and fetchZip, since they expect all files to be contained within a single subfolder of the root. Now, with fetchZip, I can pass the stripRoot = false option and everything is fine. That’s how I’m currently handling the issue.

However, multiple users of my flakes have asked that the file be made an explicit input of the flake. The third party moves the zip file from time to time, requiring me to update the flake file. If it was just one of the inputs, they could override it in their own flake and not wait on my slowness.

Unfortunately, zip flake inputs are automatically downloaded with fetchTarball and there doesn’t seem to be a way to override strip root. I’ve already tried

inputs.source.url = "";
inputs.source.flake = false;

But this immediately fails with the message

tarball contains an unexpected number of top-level files

Is there any way to prevent nix from trying to strip off the root directory? Alternately, can I tell it to treat the input as just a binary blob? That would at least allow my to manually extract the download myself.

1 Like

I am having the same issue. Have you found a fix?

Sadly, I haven’t found a solution and it appears that this is a known bug in flakes. Specifically, flakes uses fetchTarball to get the zip file and fetchTarball doesn’t allow for this sort of zip structure.

In the interim, I’m downloading the zip file internally within the flake. It’s not as neat and clean, but at least it works. If it would help, you can see my code and possibly modify it to your own uses.