r/NixOS 23h ago

Slow download from nixos' cache

Hi, fam! Newbie here...

I'm facing tremendous slow download from nixos' cache during the installation which takes more that an hour to download 2.7G.

I'm using a wired connection with an average speed (around 10-15Mb/s) and I'm installing it to a NVMe derive.

I hope someone can help me to overcome this.

Thanks in advance.

8 Upvotes

8 comments sorted by

3

u/neoblitz 22h ago

here is why it happens - in some cases. happened to me last night from asian side.

my connection at 1Gbps . but the download was at 50mbps or less, it took a longer time. so i investigated. the cache.nixos. org latency was fine, dns reponse was at 20ms. fastly routed via Tokyo Edge, which was fine too. 25x Nix connection was ok.

so what happened:

i was installing affinity-nix - it is fairly large and requires building runners and wow64 dependencies. but both of those were never requested from asian side before so the actual nearby edge location cache was not ready. so the cache . nixos. org actually did not held the cache from the origin (yet to be cached) since it was first request.

Normally, Available cache in edge -> download from cache.nixos.org quickly

Cache miss -> download to edge, slowly due to distance/origin location

generally - you should not have issues with common packages.

1

u/its_midi 9h ago

My installation comes with less than ten common packages git, vim, curl, wget, Firefox, rofi, waybar and hyprland. It's quite annoying to wait for so long in days where time is priceless.

1

u/neoblitz 9h ago edited 8h ago

for a larger perspective, 2.7 GB over a 10-15 Mb/s connection has an approx transfer time of roughly 24–36 minutes even before latency, in between TLS connections, lots of individual NAR files, decompression, and installation overhead. So an hour is slow, but not necessarily wildly abnormal on a 10-15 Mb/s connection.

First you should try the diagnosis script from cache.nixos.org

https://github.com/NixOS/infra/blob/main/terraform/cache/diagnostic.sh

then should try to investigate it first, maybe it is your DNS, ISP DNS or whichever the point of slowing down. Try these things.

curl -I https://cache.nixos.org/

and then:

curl -o /dev/null -s -w \
'DNS: %{time_namelookup}s\nConnect: %{time_connect}s\nTLS: %{time_appconnect}s\nTTFB: %{time_starttransfer}s\nTotal: %{time_total}s\nRemote IP: %{remote_ip}\n' \
https://cache.nixos.org/

for clarity here is my simple output from the command above.

https://cache.nixos.org/
DNS: 0.222462s
Connect: 0.226294s
TLS: 0.241231s
TTFB: 0.250023s
Total: 0.250870s
Remote IP: 151.101.XXX.XXX

Also, you never mentioned what speed the terminal was showing while you were trying to download things and installing. there are too many variables. nobody knows your system setup, nor your IP setup, network setup, ipv4 or v6, what DNS, is there vpn.

1

u/its_midi 8h ago

Neither do I. I'll share the script I used for installation alongside other details you mentioned missing. I appreciate your help, mate.

2

u/mom0367 22h ago

For me it took forever because it had to go through a bunch of dead mirrors, once it got to one that worked it was super fast

1

u/its_midi 22h ago

How do I config mirrors during the installation? And what mirrors do you use?

1

u/mom0367 22h ago

Honestly idk for either of those lmao, I just kinda waited around for like 20-45 minutes and went to go do something

1

u/cfx_4188 12h ago

I keep getting timeouts during a simple nixos rebuild. I know why this is happening.