Hi! In a Haskell project, Instead of source-repository-package
in cabal.project
, I’d like to use in overrides
for
haskell.packages.ghc92.override
a package from GitHub
. This package is a build-tool-depends
for a local package.
UPD: solution - put lima
into testHaskellDepends of clerk
.
Here’s the code .
lima
executable is in build-tool-depends
of a clerk
's test.
For now, when doing cabal test
, I receive
Error: cabal: Could not resolve dependencies:
[__0] trying: clerk-0.1.0.3 (user goal)
[__1] trying: clerk:*test
[__2] next goal: clerk:lima:exe.lima (dependency of clerk *test)
[__2] rejecting: clerk:lima:exe.lima-0.1.0.1/installed-2kIeGpvCN9f3vHWycpixcw
(does not contain executable 'lima', which is required by clerk *test)
[__2] fail (backjumping, conflict set: clerk, clerk:lima:exe.lima, clerk:test)
After searching the rest of the dependency tree exhaustively, these were the
goals I've had most trouble fulfilling: clerk, clerk:test, clerk:lima:exe.lima
I am wondering if you’re hitting:
opened 12:11PM - 08 Jun 22 UTC
0.kind: bug
6.topic: haskell
### Describe the bug
I have a Haskell package using `callCabal2nix`, with `bu… ild-tool-depends` on `alex` and `happy`. If I `nix-shell` straight into my `default.nix` and use the phase hooks, including the less commonly known `compileBuildDriverPhase`, I can build the project in a Nix shell environment. However, if I use a shell.nix that adds `cabal-install` and uses `.env` then I get an error from `cabal build` claiming it can't find/build `happy` (and the phase hooks aren't there).
Upstream issue: https://github.com/haskell/cabal/issues/7197#issuecomment-745424085
While my minimal example uses `callCabal2nix`, the same issue also affects IOG's haskell.nix (where `.shellFor` is equivalent to `.env` and is needed to `nix-shell` at all unless you want to specify individual components for `nix-shell` with `-A tmp.components.exes.tmp`): https://github.com/input-output-hk/haskell.nix/issues/798
### Steps To Reproduce
tmp.cabal:
```cabal
cabal-version: 3.0
name: tmp
version: 0.1.0.0
author: Demo
executable tmp
main-is: Main.hs
build-depends: base ^>=4.15.1.0
hs-source-dirs: app
default-language: Haskell2010
build-tool-depends:
alex:alex
, happy:happy
```
default.nix:
```nix
{ pkgs ? import <nixpkgs> {} }:
pkgs.haskellPackages.callCabal2nix "tmp" ./. {}
```
shell.nix:
```nix
{ pkgs ? import <nixpkgs> {} }:
(pkgs.haskell.lib.addBuildTool
(import ./. { inherit pkgs; })
pkgs.cabal-install
).env
```
How to get the error:
1. `nix-shell`
2. `cabal build`
#### output
> Warning: No remote package servers have been specified. Usually you would have
one specified in the config file.
Resolving dependencies...
cabal: Could not resolve dependencies:
[__0] trying: tmp-0.1.0.0 (user goal)
[__1] unknown package: tmp:happy:exe.happy (dependency of tmp)
[__1] fail (backjumping, conflict set: tmp, tmp:happy:exe.happy)
After searching the rest of the dependency tree exhaustively, these were the
goals I've had most trouble fulfilling: tmp, tmp:happy:exe.happy
### Expected behavior
Cabal builds the project locally.
### Screenshots
N/A
### Additional context
If you do the following, you bypass the issue:
app/Main.hs:
```haskell
main = print "Hello world"
```
1. `nix-shell default.nix` (i.e. don't use .env)
2. `eval "$compileBuildDriverPhase"`
3. `eval "$configurePhase"`
4. `eval "$buildPhase"`
Program is built to: dist/build/tmp/tmp
The way that nix-build does it (and which avoiding .env allows you to do by explicitly evaling the hooks) uses Setup.hs instead of the cabal executable. The default Setup.hs it uses appears to be:
```haskell
import Distribution.Simple
main = defaultMain
```
It looks like it prefers a local Setup.hs, even though I don't have custom build type set, so that's… interesting and potentially an incorrectly handled edge case?
### Notify maintainers
@cdepillabout
### Metadata
```console
[user@system:~]$ nix-shell -p nix-info --run "nix-info -m"
- system: `"x86_64-linux"`
- host os: `Linux 5.15.43, NixOS, 22.05 (Quokka), 22.05.481.40e2b1ae053`
- multi-user?: `yes`
- sandbox: `yes`
- version: `nix-env (Nix) 2.8.1`
- channels(root): `"nixos-22.05"`
- channels(scott): `""`
- nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`
```
What happens if you do cabal v1-test
?
Thank you! v1
-commands work without problems both locally and on GH Actions .
However, cabal test
works locally, but fails on GH Actions .
1 Like
That’s pretty strange. If you can figure it out, I would be interested in what’s going on here.