Search code examples
haskellcabal

How to pass a package flag with cabal tool?


I had a command line with stack:

stack --flag "cryptonite:-integer-gmp" build

How to pass the same flag with cabal?

Is this attempt correct (at least it does not fail):

cabal --flags="cryptonite -integer-gmp" build  # space instead of ':'

?


Solution

  • --flags sets flags for the local package, so --flags="cryptonite -integer-gmp means "enable the flag cryptonite and disable integer-gmp for my package", which is not what you mean.

    The right command-line option is --constraint="cryptonite -integer-gmp". You can have multiple --constraint options for more than one package. (See also Cabal User Guide: --constraint.)

    Or you can set it in cabal.project. (See also Cabal User Guide: flags in cabal.project.)

    -- cabal.project
    
    packages: .
    
    package cryptonite
      flags: -integer-gmp