BUG: Gen fallback passes a ZIP to fetchTarball
Description
Den's Gen fallback fails when a consumer does not declare a top-level gen input. In nix/lib/schema.nix, it builds a GitHub URL ending in .zip and passes it to builtins.fetchTarball. On a machine that has to fetch Gen, evaluation fails because fetchTarball cannot unpack a ZIP file.
This happens in my public config: https://github.com/Keyruu/shinyflakes
The flake pins Den to 2f1ae4aa27e756684d1fb5ebc1d25267727bd305 and does not declare gen as a root input, so it takes the fallback at nix/lib/schema.nix:38. The error is:
cannot read the tarball: numeric field was not a number: 22e551eb when getting cksum for PK
It is hidden on machines where the source is already in the Nix store, and shows up on a fresh machine after syncing the config.
Expected: Den's fallback fetches Gen in a format fetchTarball can unpack.
Actual: it fetches the .zip archive and evaluation fails.
Thanks for the clear report. You're right that the fallback is wrong: when a config has no gen input, nix/lib/schema.nix hands GitHub's .zip archive URL to builtins.fetchTarball, which is documented for tarballs. The nix-effects fallback in nix/lib/fx.nix has the same shape.
I couldn't reproduce the failure with any Nix I have. I ran den's exact fetch, builtins.fetchTarball { url = ".../archive/<rev>.zip"; sha256 = <narHash>; } at the gen rev den pins, with each evaluator in a fresh, empty store and an empty fetcher cache, so nothing was already present:
| evaluator | .zip |
.tar.gz |
|---|---|---|
| Nix 2.34.9 | unpacks | unpacks |
| Nix 2.35.6 | unpacks | unpacks |
Determinate Nix 3.24.2 (2.35.3), lazy-trees on and off |
unpacks | unpacks |
| Lix 2.95.4 | unpacks | unpacks |
| Lix 2.97.0-pre | unpacks | unpacks |
Every row lands on the same store path, so the archive format doesn't change the content.
Reading shinyflakes explained the difference: modules/aspects/core/nixConfig.nix enables iets in classic mode, from your fork at c650e81. iets unpacks archives with the Rust tar crate, and has no zip reader. Your error is that crate's message (cannot read the tarball: numeric field was not a number … when getting cksum for PK), and it's word for word the one in numtide/iets#300, which reports this same den fallback at the same gen rev your den pin uses (6427d427). I didn't run iets itself, so to confirm: does the machine that fails evaluate through iets? If it doesn't, please post nix --version and the error with --show-trace from it.
Either way, moving from .zip to .tar.gz is harmless and the right thing to do: .tar.gz is the format fetchTarball is for, GitHub's two archives of one rev unpack to the same tree so the pinned hashes stay valid, and den stops relying on every evaluator also accepting zips. I've opened #771 for that. Until it lands, declaring the input skips the fallback entirely:
inputs.gen.url = "github:sini/gen";
Oh yeah, I should've checked iets as well my bad but thanks for fixing it anyways!