In Nix, how to tell `haskell-language-server` to enable a flag in current project?

521 Views Asked by At

My Nix project's cabal file defines a flag but leaves it disabled by default:

flag with-examples
  description: Include examples and their dependencies
  default:     False

But when I run haskell-language-server in the nix-shell, it says:

Hidden:   no
Range:    1:1-2:1
Source:   cradle
Severity: DsError
Message: 
  Error when calling cabal exec -v0 -- ghc --print-libdir

  cabal: Could not resolve dependencies:
  [__0] trying: ema-0.7.2.0 (user goal)
  [__1] rejecting: ema:-with-examples (constraint from config file, command line
  flag, or user target requires opposite flag selection)
  [__1] trying: ema:+with-examples
  [__2] unknown package: fsnotify (dependency of ema +with-examples)
  [__2] fail (backjumping, conflict set: ema, fsnotify, ema:with-examples)
  After searching the rest of the dependency tree exhaustively, these were the
  goals I've had most trouble fulfilling: ema, ema:with-examples, fsnotify

The error goes away after making the flag True by default, but this is a clearly undesired behavior. Is there a way to fix this behavior of HLS?

I tried adding a cabal.project file with flags: +with-examples but that makes no difference.


To reproduce this error:

git clone https://github.com/EmaApps/ema.git -b multisite
cd multisite && nix develop
nvim ema.cabal ## Make both the flags default: False
haskell-language-server

(edited to clarify this is unique to Nix)

0

There are 0 best solutions below