haskell.nix icon indicating copy to clipboard operation
haskell.nix copied to clipboard

Provide instructions about how to push all the build dependencies to cachix

Open mpickering opened this issue 5 years ago • 10 comments

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

mpickering avatar Jun 20 '19 22:06 mpickering

Thanks for the report.

rvl avatar Jun 20 '19 22:06 rvl

Thankfully CI does reuse the dependencies that it built itself on subsequent runs.

mpickering avatar Jun 21 '19 07:06 mpickering

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.

mpickering avatar Jun 21 '19 07:06 mpickering

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 avatar Jun 21 '19 07:06 hamishmack

@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)

mpickering avatar Jun 21 '19 07:06 mpickering

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.

hamishmack avatar Jun 21 '19 07:06 hamishmack

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.

mpickering avatar Jun 21 '19 07:06 mpickering

Is there a way to ask Nix to give you all the evaluation time dependencies of an expression?

michaelpj avatar Jun 21 '19 08:06 michaelpj

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 ...

angerman avatar Jul 16 '19 03:07 angerman

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.

stale[bot] avatar Sep 29 '22 01:09 stale[bot]