# How to specify in cabal file that external tool is needed

**URL:** <https://discourse.haskell.org/t/how-to-specify-in-cabal-file-that-external-tool-is-needed/6218>\
**Category:** Learn\
**Created:** [April 29, 2023, 11:49am UTC](https://discourse.haskell.org/t/how-to-specify-in-cabal-file-that-external-tool-is-needed/6218 "2023-04-29T11:49:36Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![kpadmasola](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/kpadmasola/32/2202_2.png) [@kpadmasola](https://discourse.haskell.org/u/kpadmasola)\
**Post date:** [April 29, 2023, 11:49am UTC](https://discourse.haskell.org/t/how-to-specify-in-cabal-file-that-external-tool-is-needed/6218/1 "2023-04-29T11:49:36Z")

</div>

Hi,

I am new to the Haskell ecosystem.

In a certain project I need to use `llvm-config` as a build/test dependency. This tool is not something cabal can download and build because it is not based on Haskell source code. So I think `build-depends` or `build-tool-depends` would not help here.

How would I specify this dependency in a cabal file?

Alternatively how would I do the same in a `package.yaml` file which can be used to generate cabal file by running `hpack`?

thanks in advance!

---

<div class="post-metadata">

**Author:** ![jaror](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/jaror/32/3271_2.png) [@jaror](https://discourse.haskell.org/u/jaror)\
**Post date:** [April 29, 2023, 12:01pm UTC](https://discourse.haskell.org/t/how-to-specify-in-cabal-file-that-external-tool-is-needed/6218/2 "2023-04-29T12:01:08Z")

</div>

What are you planning to use `llvm-config` for?

---

<div class="post-metadata">

**Author:** ![kpadmasola](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/kpadmasola/32/2202_2.png) [@kpadmasola](https://discourse.haskell.org/u/kpadmasola)\
**Post date:** [April 29, 2023, 1:04pm UTC](https://discourse.haskell.org/t/how-to-specify-in-cabal-file-that-external-tool-is-needed/6218/3 "2023-04-29T13:04:59Z")

</div>

@jaror  
`llvm-config` is used for figuring out the library path of llvm library for linking the generated code against. The project generates llvm bitcode for a DSL and the tests verify that the generated code can be linked with llvm and executed.

It is not my project, but I am trying to help with the CI for the project, and learn Haskell in the process 🙂

---

<div class="post-metadata">

**Author:** ![jaror](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/jaror/32/3271_2.png) [@jaror](https://discourse.haskell.org/u/jaror)\
**Post date:** [April 29, 2023, 1:12pm UTC](https://discourse.haskell.org/t/how-to-specify-in-cabal-file-that-external-tool-is-needed/6218/4 "2023-04-29T13:12:44Z")

</div>

Cabal doesn’t handle installing non-Haskell tools and I think even tools written in Haskell should be installed through the package manager of your distribution if it has them. In the case of CI, you can probably run a command like `apt install llvm`.

---

<div class="post-metadata">

**Author:** ![kpadmasola](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/kpadmasola/32/2202_2.png) [@kpadmasola](https://discourse.haskell.org/u/kpadmasola)\
**Post date:** [April 29, 2023, 1:14pm UTC](https://discourse.haskell.org/t/how-to-specify-in-cabal-file-that-external-tool-is-needed/6218/5 "2023-04-29T13:14:25Z")

</div>

I suspected as much, thanks for confirming!

---

<div class="post-metadata">

**Author:** ![jodak](https://avatars.discourse-cdn.com/v4/letter/j/7ab992/32.png) [@jodak](https://discourse.haskell.org/u/jodak)\
**Post date:** [April 29, 2023, 1:15pm UTC](https://discourse.haskell.org/t/how-to-specify-in-cabal-file-that-external-tool-is-needed/6218/6 "2023-04-29T13:15:27Z")

</div>

Cabal has the field `cxx-sources`.

---

<div class="post-metadata">

**Author:** ![jaror](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/jaror/32/3271_2.png) [@jaror](https://discourse.haskell.org/u/jaror)\
**Post date:** [April 29, 2023, 1:17pm UTC](https://discourse.haskell.org/t/how-to-specify-in-cabal-file-that-external-tool-is-needed/6218/7 "2023-04-29T13:17:52Z")

</div>

The `cxx-sources` field is for when you are writing Haskell programs that use the FFI to call into C++ code. I don’t think that is relevant in this case.

---

<div class="post-metadata">

**Author:** ![NicolasT](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/nicolast/32/2872_2.png) [@NicolasT](https://discourse.haskell.org/u/NicolasT)\
**Post date:** [April 29, 2023, 1:25pm UTC](https://discourse.haskell.org/t/how-to-specify-in-cabal-file-that-external-tool-is-needed/6218/8 "2023-04-29T13:25:29Z")

</div>

Not a direct answer to your question (since indeed, I don’t believe Cabal supports this as-is): you could consider using Cabal’s `pkg-config` support, with a `.pc` file generated in some `PKG_CONFIG_PATH` using [llvm-pkg-config: Generate Pkg-Config configuration file for LLVM](https://hackage.haskell.org/package/llvm-pkg-config).

---

<div class="post-metadata">

**Author:** ![chreekat](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/chreekat/32/2669_2.png) [@chreekat](https://discourse.haskell.org/u/chreekat)\
**Post date:** [April 29, 2023, 1:37pm UTC](https://discourse.haskell.org/t/how-to-specify-in-cabal-file-that-external-tool-is-needed/6218/9 "2023-04-29T13:37:24Z")

</div>

I’m not sure to what degree it “just works”, but you _can_ specify external things in a cabal file with [6. Package Description — Cabal 3.10.1.0 User's Guide](https://cabal.readthedocs.io/en/stable/cabal-package.html#pkg-field-pkgconfig-depends) .

Otherwise, you could try looking at something like [https://devenv.sh/](https://devenv.sh/) as a general purpose tool for building dev environments.

---

<div class="post-metadata">

**Author:** ![kpadmasola](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/kpadmasola/32/2202_2.png) [@kpadmasola](https://discourse.haskell.org/u/kpadmasola)\
**Post date:** [April 29, 2023, 2:01pm UTC](https://discourse.haskell.org/t/how-to-specify-in-cabal-file-that-external-tool-is-needed/6218/10 "2023-04-29T14:01:17Z")

</div>

@chreekat yes, nix dev shell is a good option that could work, but I am trying to postpone learning nix for the time being 🙂

`pkg-confg` is probably a linux specific mechanism? I am trying to get something working for both linux and macOS. I have llvm installed on macOS via `brew` and it doesn’t showup in `pkg-config` listing

---

<div class="post-metadata">

**Author:** ![NicolasT](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/nicolast/32/2872_2.png) [@NicolasT](https://discourse.haskell.org/u/NicolasT)\
**Post date:** [April 29, 2023, 2:14pm UTC](https://discourse.haskell.org/t/how-to-specify-in-cabal-file-that-external-tool-is-needed/6218/11 "2023-04-29T14:14:32Z")

</div>

It won’t show up on Linux either, because for some reason the LLVM devs seem not to ship a `pc` file but insist on using `llvm-config`. The tool I linked provides a work-around.
