How can I write Nix expression to build content-addressable path?

Documentation that I read so far focuses on the fact that content-addressable derivations do not need to be signed, but I have different focus.

I have swagger definition(OpenAPI Specification - Version 3.0.3 | Swagger) and Nix expression that generates library code from it, which is dependency of pretty much everything else. With this approach every change to swagger definition, even minor one, like change of “description” field, results in major rebuild of everything.

Ideally, I would use content-addressable derivation to do rebuilds only when generated code changes, but I found no way to do it. One would expect “buildin.makeContentAddressable” function that accepts and returns derivation, but I didn’t found one and attempts to call to “nix store make-content-addressable” inside build script fails with permission denied.

Am I asking for impossible?

https://nixos.org/manual/nix/unstable/command-ref/new-cli/nix3-store-make-content-addressable.html

1 Like