Install package only when in cache?

Maybe related to Allow failing derivation but I think a bit different.

Is it possible to exclude packages or replace them with “dummy” derivations, when no version in the cache is available, instead of building them?

In the past I had sometimes the issue that large packages like firefox or libreoffice weren’t available on the cache, esp. when I tested a systemwide dependency update like bluez a few months ago with my normal system config. I rather have them not available.

I know I could pin them to a stable channel, but a more general solution would be nice.

1 Like

Also relevant: Steps to find a commit with cached version of package - #3 by SRGOM

I do not think that there is a way to do that automatically. The reason is that nix tries very hard to be deterministic and reproducible. Changing what is installed depending on a network (cache) state would require to work around nix in complex ways.

As for now, there are some ways to get the information

  1. nix has --dry-run to print in advance what will be built.
  2. nix has a --prebuilt-only flag to some commands, that will fetch binaries but not build local files.

Usually, I start the update, and stop when large packages are starting to build locally. When that happens, I temporarily comment out the package from my declarative input list, and restart the update. With a web browser, this is not really feasible.