I tried something similar using source-repository-package in a cabal.project file and was able to override the binary package with my own version. The problem seems to be a limitation with stack.

On Tue, Jun 14, 2022 at 11:42 PM Ruben Astudillo <ruben.astud@gmail.com> wrote:
Hi Josh

On 14-06-22 11:33, ☂Josh Chia (謝任中) wrote:
> Given that binary is one of the packages that comes with GHC, it seems that
> it can't be overridden with my own version using the standard ways (e.g.
> extra-deps in stack.yaml), at least not easily.
>
> On GHC 9.2.3, using stack, I would like to use my own version from my
> github repo. I've tried extra-deps referencing the github repo commit and
> it did not work; judging by the behavior of some functions, I was still
> getting the standard binary package instead of my own version. Is there a
> way to override?

Given that stack generates a .cabal file while trying to build your project,
you could bypass stack after the initial run, modify the .cabal file
directly (possibly with `cabal v2-freeze` and then use cabal directly.

--
Rubén. (pgp: 1E88 3AC4 89EB FA22)