How to make a version compatable config for `nix.binaryCaches` or `nix.settings.substituters`?

The config about binary cache is called nix.binaryCaches before, and now it becomes nix.settings.substituters, so how can I write my configuration.nix to fit both old version and new version of Nixpkgs?

The easiest solution is to only set nix.binaryCaches because for now that option still exists and in newer versions will be translated to nix.settings.substituters with a warning.

For a more future proof and warning-less solution you could set each option based on config.system.stateVersion.