I have a Haskell package I’m developing and trying to write a flake.nix
for. Its tests use hspec-discover
and the cabal file contains
build-tool-depends:
hspec-discover:hspec-discover
After entering a shell with nix develop
I see that hspec-discover
is installed:
(ins)$ ghc-pkg list | rg hspec
hspec-2.9.7
hspec-core-2.9.7
(hspec-discover-2.9.7)
hspec-expectations-0.8.2
(ins)$ whereis hspec-discover
hspec-discover: /nix/store/vaq3gvak92whk5l169r06xrbkx6c0lqp-ghc-9.2.8-with-packages/bin/hspec-discover /nix/store/986bnyyhmi042kg4v6d918hli32lh9dw-hspec-discover-2.9.7/bin/hspec-discover
However, cabal
isn’t able to find hspec-discover
and thus building and running the tests fail in the shell:
(ins)$ cabal run test:my-test
Warning: The package list for 'hackage.haskell.org' does not exist. Run 'cabal
update' to download it.
Resolving dependencies...
Error: cabal: Could not resolve dependencies:
[__0] trying: my-pkg-0.0.1 (user goal)
[__1] trying: my-pkg:*test
[__2] next goal: my-pkg:hspec-discover:exe.hspec-discover (dependency of my-pkg *test)
[__2] rejecting: my-pkg:hspec-discover:exe.hspec-discover-2.9.7/installed-G6Vto7m4JRcDmAko2pMBBi (does not contain executable 'hspec-discover', which is required by my-pkg *test)
[__2] fail (backjumping, conflict set: my-pkg, my-pkg:hspec-discover:exe.hspec-discover, my-pkg:test)
After searching the rest of the dependency tree exhaustively, these were the
goals I've had most trouble fulfilling: my-pkg, my-pkg:test, my-pkg:hspec-discover:exe.hspec-discover, hspec, hspec-discover, servant-openapi3
Try running with --minimize-conflict-set to improve the error message.
What should I do to make sure hspec-discover
is found?