I am running nix on a ubuntu in a virtualbox to test the reproducibility of this webpage:
In my (nonvirtual) machine, running NixOS, the line nix-shell --run cachedMake # Wait about one minute takes about 1s.
Because in fact it runs nix-build (without arguments), which downloads a cached result and copies some files around.
However in my virtual machine, running the whole installation procedure, install cachix, adding caches anf finally the Work! section. The invocation of nix-build does not download but rebuilds, as if it did not find the derivation in cachix. However, reading the log, it does look at the right cachix cache, and it is still in the cache as I write these lines:
I might have an idea of what is going wrong but first I have a few questions. You talk about calling nix-build but the command you show is nix-shell which might be relevant since they don’t work exactly the same especially when it comes to caching. It is also not clear from either your log or your wiki entry how you populate the cache.
The difference between the two commands is that nix-shell deals with a development environment and build dependencies while the output derivation from nix-build only includes the runtime dependencies. So if you cache something with nix-build default.nix | cachix push mycache it will only cache the build result and runtime dependencies. The reason it works now might be because the cachix github action caches all things built during the run.
The cache is populated from a github action (using cachix with authToken) using a build that is supposed to cover the one in the shellHook (I made sure that it was indeed cached at some point during my attempts).
I managed to reproduce the problem by trying nix-build slightly to early… and then rm $HOME/.cache/nix/binary-cache-v*.sqlite* did indeed solve the problem.
Thank you!