{"id":17820591,"url":"https://github.com/mwotton/stackswitcher","last_synced_at":"2025-04-02T09:43:32.617Z","repository":{"id":66821654,"uuid":"134883844","full_name":"mwotton/stackswitcher","owner":"mwotton","description":null,"archived":false,"fork":false,"pushed_at":"2019-02-05T19:30:00.000Z","size":4,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-08T00:44:04.477Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mwotton.png","metadata":{"files":{"readme":"README.md","changelog":"ChangeLog.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-05-25T17:04:33.000Z","updated_at":"2020-08-05T17:20:42.000Z","dependencies_parsed_at":"2023-05-30T05:15:24.604Z","dependency_job_id":null,"html_url":"https://github.com/mwotton/stackswitcher","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mwotton%2Fstackswitcher","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mwotton%2Fstackswitcher/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mwotton%2Fstackswitcher/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mwotton%2Fstackswitcher/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mwotton","download_url":"https://codeload.github.com/mwotton/stackswitcher/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246793855,"owners_count":20834931,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-27T17:06:46.443Z","updated_at":"2025-04-02T09:43:32.599Z","avatar_url":"https://github.com/mwotton.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# stackswitcher - stop rebuilding the world\n\n## why?\n\nstack 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:\n\n- profiling builds are done by default in the same place\n- switching git branches can change enough that almost everything needs to be rebuilt.\n\n## what doesn't work?\n\n```\nalias stack='mkdir -p .stack-work; export STACK_REF=\"ref-$(git rev-parse --abbrev-ref HEAD)\"; (cd .stack-work; if [ -d ref-master ] \u0026\u0026 [ ! -d $STACK_REF ]; then cp -r ref-master $STACK_REF; fi); stack --work-dir .stack-work/$STACK_REF'\n```\n\nhttps://twitter.com/tazjin/status/999056299596877825\n\nThis 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.\n\n## what does work\n\n- create a directory to hold a per-branch .stack-work\n- initialise as .stack-work in the root\n- add a git hook to move the current .stack-work into the holding directory on branch change.\n  - 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.\n  - should also move the equivalent .stack-work-profiling.\n- add an alias (pstack) that uses .stack-work-profiling in order not to trash what's there when you want to profile.\n\n\n## Bugs/TODO\n\nNo bugs yet, because no code!\n\nTODO: think about the approach to profiling a little more carefully. arguably we could get the same effect by just opening up a new branch.\n\n\nmeanwhile, the `post-checkout` shell command in the repo will work if you put it into the `.git/hooks` directory of your repo.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmwotton%2Fstackswitcher","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmwotton%2Fstackswitcher","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmwotton%2Fstackswitcher/lists"}