Search code examples
haskellcabalnix

How do I change the directory my silly-code.cabal project looks for a parent cabal.project file in?


I'm in a monorepo containing projects of many different languages. At the root of it, we want to have this:

└── haskell
    ├── cabal.project
    ├── one-lib
    │   ├── one-lib.cabal
    │   └── src
    │       └── OneLib.hs
    └── two-lib
        ├── two-lib.cabal
        └── src
            └── TwoLib.hs

and then from within other directories, like inside some/nested-path I want to have a silly-code.cabal that looks like

name: silly-code
build-type: Simple

-- Imaginary option
cabal.project-root-folder: ../../haskell/

library
  hs-source-dirs:
    src
  main-is:
    Main.hs
  build-depends:
    , one-lib   -- listed in ../../haskell/cabal.project
    , base < 5

is this possible?


Solution

  • It is possible, but not from your .cabal file. It must be specified on the cabal command-line, using the --project-file command-line flag.