haskell.nix
haskell.nix copied to clipboard
Provide instructions about how to push all the build dependencies to cachix
I built by project locally and pushed all build dependencies to cachix. When using an explicit pkgs.nix
file this worked as expected and CI downloaded the dependencies and used them.
I changed to use the callCabalProjectToNix
function and now whatever I try, CI will rebuild the entire project. It seems that the hash is somehow dependent on what's in the directory.
The configuration is completely standard - https://github.com/mpickering/eventlog2html/blob/documentation/build.nix
Thanks for the report.
Thankfully CI does reuse the dependencies that it built itself on subsequent runs.
Perhaps the problem was the hpack
dependency. Maybe there wouldn't have been a problem if I also pushed the dependencies of the plan-and-src
command. There were a lot of packages being built which I didn't recognise from my own build plan.
callCabalProjectToNix
does not clean src
, so when you pass in src = ./.;
it will introduce a dependency on everything (even build artefacts). You can use pkgs.lib.cleanSourceWIth
to filter out files that should not be included and pass the result in place of ./.
. Here is an example.
@hamishmack I tried changing a file locally and it didn't cause a mass rebuild so I don't think that's the problem. I suspect I wasn't careful about pushing all dependencies to CI (as described in https://github.com/input-output-hk/haskell.nix/issues/186#issuecomment-504317829)
Oh that makes sense. The cleanSourceWith stuff would not help on CI where the source should be clean anyway. It is only useful if you are running build.nix
locally where you might have stuff to clean.
I think this ticket is now about documentation. It would be good to provide instructions about invocations you need to push all the build dependencies to cachix.
Something like
nix-store -qR --include-outputs /nix/store/mxamx6s0va931nl3nf4r1b9g6qkl6xc4-plan-and-src.drv | cachix push mpickering
nix-store -qR --include-outputs /nix/store/32jax7y9ascbzngvxjxm3bf53q45j8ns-eventlog2html-0.9-exe-eventlog2html.drv | cachix push mpickering
Perhaps the fact it's documented here in this comment is now documentation enough.
Is there a way to ask Nix to give you all the evaluation time dependencies of an expression?
I think nix-instantiate
would have to, but I'm not sure it lists it. I believe that using cachix with the --watch-store
option is the best solution:
cachix push $cache --watch-store&
nix-build ...
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.