How to choose first priority substituter using flakes

In this thread, @luochen1990 figured out how to set the priority of a substituter with nix.settings.substituters = lib.mkBefore [ "https.mirrors.somesite.com/nix-channels/store" ].

How do I accomplish this with flakes? I have added a substituter to my flake.nix like this:

  nixConfig = {
    trusted-substituters = [
      "https://mirrors.tuna.tsinghua.edu.cn/nix-channels/store"
      "https://cache.nixos.org"
    ];

And it does add the Tsinghua substituter, but I cannot figure out how I can change the substituter order from within the flake.nix file so that it uses Tsinghua’s server before relying on cache.nixos.org.

You can add the query param priority=<num> to it:

https://mirrors.tuna.tsinghua.edu.cn/nix-channels/store?priority=10

Lower number means higher priority.

I was looking for docs on this, but the only thing I can find is the Nix release notes for 2.4: Release 2.4 (2021-11-01) - Nix Reference Manual