I cannot change GHC's compilation times, but I can control the environment in which things are compiled. What can I do with git and stack to minimize downtime due to (re-)building?
Haskell stack caches compiled dependencies in the .stack-work
directory, and it great for working on one thing at a time. However, I find myself switching back and forth between branches. I've done git checkout
in place, and perhaps some of the .stack-work
cache is usable. But I greatly prefer git worktree
to get a copy of a branch in a different directory altogether. Worktree is especially hard on build times as each worktree directory will have its own .stack-work
, and therefore must download/configure/compile/install its own dependencies instead of using existing ones.
I've been doing some reading about Nix and Haskell, but since stack creates its own cache, it ignores whatever Nix has compiled and installed. From what I've read, I really want Nix to handle dependencies and stack to handle my personal code. I get great benefit from stackage and stack solver
, so I do not want to give them up. But when I see a screenful of "unregistering" messages when running stack build --only-dependencies && stack ghci
, I know that I've got at least 10-15 minutes before I get a prompt.
Many thanks!
stack
keeps is GHC installs in~/.stack
and binary installs (likealex
andhappy
) in~/.local/bin
. Do you use Cabal for projects with dozens of dependencies, and if so, do you draw from Stackage releases or something else? – Earlearlacabal install
defaults to), which works fine most of the time and generally avoids compiling any package over again if it has ever been installed before on the system. When there's a conflict (the kind that Stack was written to avoid), I'll generally clone the offending package straight from Github, tweak the dependencies as needed, and move on. – Postboy