Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mwotton/stackswitcher
https://github.com/mwotton/stackswitcher
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/mwotton/stackswitcher
- Owner: mwotton
- License: bsd-3-clause
- Created: 2018-05-25T17:04:33.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-02-05T19:30:00.000Z (almost 6 years ago)
- Last Synced: 2024-10-27T18:28:01.906Z (3 months ago)
- Language: Shell
- Size: 3.91 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: ChangeLog.md
- License: LICENSE
Awesome Lists containing this project
README
# stackswitcher - stop rebuilding the world
## why?
stack does a pretty good job in general of caching built packages. It isn't quite so successful at caching built local products, for a number of reasons:
- profiling builds are done by default in the same place
- switching git branches can change enough that almost everything needs to be rebuilt.## what doesn't work?
```
alias stack='mkdir -p .stack-work; export STACK_REF="ref-$(git rev-parse --abbrev-ref HEAD)"; (cd .stack-work; if [ -d ref-master ] && [ ! -d $STACK_REF ]; then cp -r ref-master $STACK_REF; fi); stack --work-dir .stack-work/$STACK_REF'
```https://twitter.com/tazjin/status/999056299596877825
This is pretty close - unfortunately, because there are absolute paths in the stack model, you can't move .stack-work directories around and expect them to work in the new location.
## what does work
- create a directory to hold a per-branch .stack-work
- initialise as .stack-work in the root
- add a git hook to move the current .stack-work into the holding directory on branch change.
- this is a _little_ more complicated than it seems: we also have a .stack-work for each package directory, for reasons to do with a Cabal Windows bug (https://github.com/commercialhaskell/stack/issues/1178#issuecomment-162255770) - we need to cache these too.
- should also move the equivalent .stack-work-profiling.
- add an alias (pstack) that uses .stack-work-profiling in order not to trash what's there when you want to profile.## Bugs/TODO
No bugs yet, because no code!
TODO: think about the approach to profiling a little more carefully. arguably we could get the same effect by just opening up a new branch.
meanwhile, the `post-checkout` shell command in the repo will work if you put it into the `.git/hooks` directory of your repo.