Download calculation with omitted FileSize is wrong #606

Open
opened 2024-12-26 13:43:09 +00:00 by flokli · 1 comment

Describe the bug

I'm using a binary cache that doesn't expose FileSize / FileHash fields.

While being totally a valid NARInfo file, Nix gets its download estimates wrong:

these 3 derivations will be built:
  /nix/store/m6dkr67hk87lpcz9wv8f2mp2zrgsyfp9-nix-2.24.11.drv
  /nix/store/zcfi6vs0z18309asw8fpa9v3665av44v-niv-0.2.22.drv
  /nix/store/g4kvzrs1kk9i13vaa8q1r0y4hgsqsnlp-dev-env.drv
these 112 paths will be fetched (0.00 MiB download, 2649.76 MiB unpacked):
  /nix/store/3qzlg8h5qc1slypy99aafdcgkzj6974h-OneTuple-0.4.2
  /nix/store/pp4540rig52fnj66kz1kiaj1000ja9v0-QuickCheck-2.14.3
  /nix/store/416aqss6p59w6v92127hkz04v0bclx21-StateVar-1.2.2
  /nix/store/b5f93spm2cl9g6x73dnx7ns5irs739fz-aeson-2.1.2.1
  /nix/store/nqnx6k6y103rargdz2gai2rmi389zn6n-aeson-pretty-0.8.10
  /nix/store/11wc4s6a6qi98lxikacw746slhmj5dl7-ansi-terminal-1.0.2
  /nix/store/yy7j66av9lwh3lvbxp1zv7572wb4l7dj-ansi-terminal-types-0.11.5
  /nix/store/cn6m459cbacdwkvjllgy5hkzf045yc1g-appar-0.1.8
  […]

As can be seen, it assumes 0.00 MiB download size and 2649.76 MiB unpacked size.

I assume other CLI frontends with other progress reports are also borked.

Expected Behaviour

If the FileSize field is omitted, it should probably just fall back to use the NARSize field for size calculation, or only report the unpacked size.

Steps To Reproduce

  1. Configure https://nixos.tvix.store as a binary cache
  2. Substitute something
  3. See error

nix --version output

nix (Lix, like Nix) 2.91.1

## Describe the bug I'm using a binary cache that doesn't expose FileSize / FileHash fields. While being totally a valid NARInfo file, Nix gets its download estimates wrong: ``` these 3 derivations will be built: /nix/store/m6dkr67hk87lpcz9wv8f2mp2zrgsyfp9-nix-2.24.11.drv /nix/store/zcfi6vs0z18309asw8fpa9v3665av44v-niv-0.2.22.drv /nix/store/g4kvzrs1kk9i13vaa8q1r0y4hgsqsnlp-dev-env.drv these 112 paths will be fetched (0.00 MiB download, 2649.76 MiB unpacked): /nix/store/3qzlg8h5qc1slypy99aafdcgkzj6974h-OneTuple-0.4.2 /nix/store/pp4540rig52fnj66kz1kiaj1000ja9v0-QuickCheck-2.14.3 /nix/store/416aqss6p59w6v92127hkz04v0bclx21-StateVar-1.2.2 /nix/store/b5f93spm2cl9g6x73dnx7ns5irs739fz-aeson-2.1.2.1 /nix/store/nqnx6k6y103rargdz2gai2rmi389zn6n-aeson-pretty-0.8.10 /nix/store/11wc4s6a6qi98lxikacw746slhmj5dl7-ansi-terminal-1.0.2 /nix/store/yy7j66av9lwh3lvbxp1zv7572wb4l7dj-ansi-terminal-types-0.11.5 /nix/store/cn6m459cbacdwkvjllgy5hkzf045yc1g-appar-0.1.8 […] ``` As can be seen, it assumes 0.00 MiB download size and 2649.76 MiB unpacked size. I assume other CLI frontends with other progress reports are also borked. ## Expected Behaviour If the `FileSize` field is omitted, it should probably just fall back to use the NARSize field for size calculation, or only report the unpacked size. ## Steps To Reproduce 1. Configure `https://nixos.tvix.store` as a binary cache 2. Substitute something 3. See error ## `nix --version` output nix (Lix, like Nix) 2.91.1
Author

For now I think this can be worked-around on the server side by setting FileSize to NarSize, but the field is optional, so it should probably still be supported.

For now I think this can be worked-around on the server side by setting FileSize to NarSize, but the field is optional, so it should probably still be supported.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: lix-project/lix#606
No description provided.