How to correctly cache build-time dependencies using Nix - haskellforall.com

3 Likes

A possible adverse edge-case here would be that if you were hacking on i.e. stdenv before and had its build deps in the store, those would get uploaded to the store too eventhough they were never used in the build of the project on your machine.

It’d probably be better and overall more robust to cache all transitive build inputs that are not present on cache.nixos.org instead.

Any easy way to do that?

I’m not aware of an easier one than iterating through the list of dependencies and querying https://cache.nixos.org/<long hash>.narinfo.

2 Likes

This should make things even easier:
https://github.com/NixOS/nix/pull/7526

There is a doc snippet with a nice example showing how to capture both uncached build and runtime deps trivially.

3 Likes