Hi !
I use some larger packages that require building locally (like a kernel with custom config, virtualbox with disabled hardening). I was wondering if there is a system-wide way of saying I would like to use ccache for compiling all of the packages that require local compilation ? Something akin to:
if there is a binary version of the package - just download that
if there is not - try to compile
for every local compilation process launched by 2) - use global ccache
I think there was an attempt made long ago with https://github.com/edolstra/nix-make to use the nix-store as a repository for per-build-artifact packages, however, it has long since been ditched.
AFAIK, the only level of abstraction for nix is a derivation, so you will need to try and decompose your problem into smaller derivations if you want to get more mileage out of them. For a kernel? I’m not sure how far you’ll get, probably not very.
While developing a derivation, I’ve had luck just setting the CCACHE variables directly and turning sandboxing off. This allowed me to temporarily speed up iterations of builds, then turn it off before submission to Nixpkgs.