CCache system wide?

I’d love to have a system wide build cache as compile times are lengthy even with a Ryzen 9 5950X.

Currently the NIX documentation for CCache specifies that relevant packages should be declared but I’m clueless how to properly do this globally as I’m still new to NIX.

This depends on what it is you’re building. If you’re building an entire NixOS closure because you’re modifying stdenv (or something close to it) anyways, you would use the ccacheStdenv by default via Nixpkgs’ config.replaceStdenv argument. See nixpkgs/all-packages.nix at e24c4f8cbbf4b03999c0b1d4d48b148e75ace1b5 · NixOS/nixpkgs · GitHub

This will, of course, result in a world rebuild.

If you only build a few leaf packages as part of a NixOS closure, use the ccache module and declare their attribute names in programs.ccache.packageNames.