How to mark a derivation is content-addressable or override existing package as content-addressable?

I want to create a private repository with a cache. Unless I lock every user of this repository to a certain NixOS / nixpkgs release (or even hashes), the cache will be all misses. So the solution is to enable content-addressable on each derivation provided in the repository.

But, is there a way to do that? Hinting that a derivation should be build with content-addressable approach?


In this case, I have control over the CA approach of the users. But managing to lock on certain Nixpkgs version is impossible as each use case have different set of package that maybe come from latest or even unstable Nixpkgs.

There is `__contentAddressed` but that enforces CA.

Thanks! This lead to its documentation too.

But, what do you mean “that enforces CA”? Do my entire build will be CA? Or it can be a select packages?

That derivation then requires ca derivation and does not build without it. It is selective per package but there is no way to do opt in as in “use ca-derivations if they are enabled”

Thank you for the clarification.