When you specify a list of
substituters, what determines which substituter is tried first?
I am using a list of 3 substituters, one the official cache (
https://cache.nixos.org), one primary cache and one backup (which is slow).
For some reason it is always using my backup substituter first. I initially put things in the order Primary, Nix, Backup thinking that putting Backup last that it would prefer the ones at the beginning. However it used up the backup one first. I also tried reversing the order, and also putting the backup in the middle and all had the same effect.
I also verified that if I omit the backup substituter, it pulls from our primary cache just fine.
The nix docs say you can give a list of URLs for
substituters, but I cannot find information on which one is chosen.
A list of URLs of substituters, separated by whitespace. The default is
I believe they’re tried in order. EDIT: but I had the feeling relatively long time ago – since then there’s new http/2 support, etc.
We found a solution in old docs: the
Priority configuration of the cache.
Old docs are here.
Each binary cache has a priority (defaulting to 50). Binary caches are checked for binaries in order of ascending priority; thus a higher number denotes a lower priority. The binary cache
http://cache.nixos.org has priority 40.
This successfully worked for our use case.
It also helped to clear the local cache database as described here.
$ rm $HOME/.cache/nix/binary-cache-v5.sqlite*
In our case with the multiuser setup, we use
$ rm /root/.cache/nix/binary-cache-v5.sqlite* since the nix-daemon runs as root.
I stuck with the same problem. My list of
file:// entries but nix always use ssh one. If I keep only
file:// substituters then it starts to use file:// one. Is there any way to lower down ssh substitutor priority?