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:
$ curl https://math-comp.cachix.org/bgbmz6z0igxvkang42h8by66ndii8y9n.narinfo
(and it was indeed stored in a github action run)
So why would it rebuild it instead of downloading it?
I retried today, without changing anything, and it works perfectly… I’m quite puzzled…
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.
Actually I am really calling
nix-build (the reason for the
nix-shell is just to get a
shellHook that calls
nix-build and does extra stuff)
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).
Thanks! I did not know about the negative cache. Since rebooting my virtual machine did not help, I guess that is what happened.
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.
@CohenCyril I wonder, how many hours did you lose because of this?