# Spin up a new worktree FAST, with cabal-buck2

**URL:** <https://discourse.haskell.org/t/spin-up-a-new-worktree-fast-with-cabal-buck2/14992>\
**Category:** Uncategorized\
**Created:** [November 6, 2026, 12:31pm UTC](https://discourse.haskell.org/t/spin-up-a-new-worktree-fast-with-cabal-buck2/14992 "2026-11-06T12:31:57Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![simonmar](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/simonmar/32/5058_2.png) [@simonmar](https://discourse.haskell.org/u/simonmar)\
**Post date:** [November 6, 2026, 12:31pm UTC](https://discourse.haskell.org/t/spin-up-a-new-worktree-fast-with-cabal-buck2/14992/1 "2026-11-06T12:31:57Z")

</div>

Something we often want to do is create a new worktree to work on a bug, PR, or small feature, especially if you’re forking off tasks for an AI to work on. Creating the worktree is easy, but to build and test the changes, you’re starting from a cold build.

I want to run through quickly how to set things up so that you can spin up a new worktree and use `cabal-buck2` to pull build artifacts from a cache, so the build in the fresh worktree is ready instantly.

Get a build cache running. I use [bazel-remote](https://github.com/buchgr/bazel-remote/releases), you can grab one of the releases or build from source. Start the cache, e.g.

```bash
./bazel-remote-2.6.4-linux-amd64 --dir ~/.cache/buck2 --max_size 20 --grpc_address 127.0.0.1:9092 --http_address 127.0.0.1:8080

```

Next get yourself set up with [cabal-buck2](https://hackage.haskell.org/package/cabal-buck2) - the README explains what you need.

Then set up your project with `cabal-buck2` and tell it to use the local cache:

```bash
cabal buck2 --enable-tests --cache=grpc://127.0.0.1:9092

```

build and run tests:

```bash
buck2 build //...
buck2 test //...

```

Now the build cache is warm, we can create a new worktree:

```bash
git worktree add /tmp/worktree -b tmp
cd buck2 && git worktree add /tmp/worktree/buck2 -b tmp

```

Run `cabal buck2` in the new worktree, again telling it to use the cache:

```bash
cd /tmp/worktree
cabal buck2 --enable-tests --cache=grpc://127.0.0.1:9092

```

And the build should now be almost instant:

```bash
buck2 build //...

```

When I tried this just now on the Cabal project itself, the clean build took 1.3s.

---

<div class="post-metadata">

**Author:** ![LaurentRDC](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/laurentrdc/32/4950_2.png) [@LaurentRDC](https://discourse.haskell.org/u/LaurentRDC)\
**Post date:** [November 6, 2026, 2:40pm UTC](https://discourse.haskell.org/t/spin-up-a-new-worktree-fast-with-cabal-buck2/14992/2 "2026-11-06T14:40:20Z")

</div>

One of the advantages cabal/stack have over solutions like buck2 or Bazel is that it’s very much pick-up-and-go. In contrast, above, the first step is to set up a build cache.

Is there a way to make `cabal-buck2` use a local directory like `~/.cache/cabal-buck2` as a default build cache? Or is the process of managing build caches fundamentally separate?

---

<div class="post-metadata">

**Author:** ![simonmar](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/simonmar/32/5058_2.png) [@simonmar](https://discourse.haskell.org/u/simonmar)\
**Post date:** [November 6, 2026, 4:21pm UTC](https://discourse.haskell.org/t/spin-up-a-new-worktree-fast-with-cabal-buck2/14992/3 "2026-11-06T16:21:56Z")

</div>

Yep. You do need a separate build cache service (Buck2 doesn’t have one built in) but there’s a lot we could do to automate parts of the workflow to make it more streamlined. We could distribute Buck2 and `bazel-remote` through ghcup; we could have `cabal-buck2` start the build cache itself; we could have `cabal-buck2` clone the `buck2/` directory if it doesn’t exist. Then it might just be a `ghcup` and a `cabal install cabal-buck2`, and you’re good to go.

---

<div class="post-metadata">

**Author:** ![MangoIV](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/mangoiv/32/3519_2.png) [@MangoIV](https://discourse.haskell.org/u/MangoIV)\
**Post date:** [November 6, 2026, 4:49pm UTC](https://discourse.haskell.org/t/spin-up-a-new-worktree-fast-with-cabal-buck2/14992/4 "2026-11-06T16:49:06Z")

</div>

Nixpkgs’ Haskell support looks a bit like stack in that they support a fixed package set but if your package happens to build with that package set you’ll be able to download all your dependencies from their cache, no need to set up anything yourself. Your local package can just be built using cabal.

---

<div class="post-metadata">

**Author:** ![michaelpj](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/michaelpj/32/417_2.png) [@michaelpj](https://discourse.haskell.org/u/michaelpj)\
**Post date:** [November 6, 2026, 5:18pm UTC](https://discourse.haskell.org/t/spin-up-a-new-worktree-fast-with-cabal-buck2/14992/5 "2026-11-06T17:18:11Z")

</div>

This works well if the main cost of a new worktree is dependencies. But if you have a big project, then often compiling your _own_ code is most of the cost.

It would be super if cabal could also have something similar. [Relocatable build tree · Issue #12137 · haskell/cabal · GitHub](https://github.com/haskell/cabal/issues/12137) is a good step in that direction.

---

<div class="post-metadata">

**Author:** ![alexfmpe](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/alexfmpe/32/5150_2.png) [@alexfmpe](https://discourse.haskell.org/u/alexfmpe)\
**Post date:** [November 6, 2026, 10:31pm UTC](https://discourse.haskell.org/t/spin-up-a-new-worktree-fast-with-cabal-buck2/14992/6 "2026-11-06T22:31:16Z")

</div>

Indeed, hence

> **[Nixpkgs support for incremental Haskell builds](https://haskellforall.com/2022/12/nixpkgs-support-for-incremental-haskell)**
>
> A post explaining the design behind a new Nixpkgs feature for building Haskell packages incrementally

---

<div class="post-metadata">

**Author:** ![LaurentRDC](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/laurentrdc/32/4950_2.png) [@LaurentRDC](https://discourse.haskell.org/u/LaurentRDC)\
**Post date:** [November 7, 2026, 2:26am UTC](https://discourse.haskell.org/t/spin-up-a-new-worktree-fast-with-cabal-buck2/14992/7 "2026-11-07T02:26:00Z")

</div>

I found this old cabal issue which might be relevant: [RFC: Remote cache support · Issue #5582 · haskell/cabal · GitHub](https://github.com/haskell/cabal/issues/5582)
