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

Improve `shellFor` support for `lorri`

Open hamishmack opened this issue 5 years ago • 3 comments

hamishmack avatar Mar 17 '20 22:03 hamishmack

I think you accidentally lost the first cleanGit commit!

michaelpj avatar Mar 19 '20 11:03 michaelpj

I think you accidentally lost the first cleanGit commit!

I did some digging and it turns out that the .git directory is a problem with the way lorri watch handles calls to builtins.readDir. Although these calls only read the directory listing (and do not recurse into sub directories), lorri watch monitors the whole directory tree. So when we look to see if .git is a file or directory (to tell if it is a we are in a git worktree) that causes all of src to be watched (including .git). Also we have the same problem when we look for cabal.project in the cabalProject function.

I tried to find a work around we could put in haskell.nix itself, but the trick of using cleanSourceWith to copy the files to the store before using readDir breaks when using --option restrict-eval true.

Luckily there is already a fix for the lorri https://github.com/target/lorri/pull/232 and I have merged it into the latest master so it can be installed with:

nix-env -if https://github.com/hamishmack/lorri/archive/master.tar.gz

It seems to work (at least on macOS).

Changes to cabal.project files in the shellFor of a cabalProject worked nicely, but .cabal files were watched at all (because the inputs to the callCabalProjectToNix are not read using nix). I have added code to shellFor that calls readFile on the .cabal files causing lori watch to watch them.

hamishmack avatar Mar 19 '20 11:03 hamishmack

It turns out that https://github.com/target/lorri/pull/232 breaks some things that do need to be watched recursively. I have tried to make a new patch here https://github.com/target/lorri/pull/356 that does not have the same problem. If you want to try it out you can install that fix and https://github.com/target/lorri/pull/355 with.

nix-env -if https://github.com/hamishmack/lorri/archive/master.tar.gz

hamishmack avatar Mar 21 '20 10:03 hamishmack