How to specify the order of items in `nix.settings.substituters`?

Hi, I add some extra mirrors for binary cache, but nix show-config always shows substituters = https://cache.nixos.org/ .... which implies https://cache.nixos.org/ is always the first one.

I want to make “cache.nixos.org” the last one in nix.settings.substituters, how can I do that?

If you control the binary caches, you can configure their Priority.

You can use mkOrder, mkFirst and mkLast to control ordering in a merged list.

(I could misremember correct naming)

1 Like

As of nix 2.4:

  • The priority of substituters can now be overridden using the priority substituter setting (e.g. --substituters 'http://cache.nixos.org?priority=100 daemon?priority=10' ).

https://nixos.org/manual/nix/stable/release-notes/rl-2.4.html

2 Likes

Thanks to @NobbZ , My final solution is:

nix.settings.substituters = lib.mkBefore [ "https.mirrors.somesite.com/nix-channels/store" ]
1 Like