Best way to ensure binary cache is hit when rebuilding after deleting flake.lock

I’m using flakes for system config and I’m tracking nixpkgs/nixos-unstable. When I want to update the system to a more recent version of nixpkgs, I rm flake.lock and then nixos-rebuild switch as usual.

However, I frequently see that many packages get built locally, which makes sense as I just told it to pick the latest nixos-unstable, so many new packages are not built.

My question is - what’s the easiest way (if there is any in the first place) to ensure binary caches are hit (as in - pick not the latest version, but the latest version for which all packages are in binary cache)? I guess it would be great if we had nixos-unstable-all-built-by-hydra branch :slight_smile:

When the commit on nixos-unstable gets advanced, then all relevant packages and more should have been built on hydra already and be available in the cache.

You are probably doing something else that causes the rebuilds.

Also, to properly update a flake you use nix flake update

What can I do to try to figure out what I’m doing that’s causing rebuilds?

Thanks, will use that going forward.

Hard to say, without knowing your configuration, though some overlay is usually related.

Another culprit are some misued follows in flakes, or a misunderstanding how to select the corrrect branches.