Running Haskell on Guix

Goal: I want to run haskell programs in Guix, I’m using Guix OS/System.

There are examples of how to package a haskell development environment using the Guix channels, packages and services, but some are dated and I’m wondering if there’s a better way of doing things now. I want to avoid complicating my home configuration before knowing if there’s a better way to go about things.

So far, I can install ghc and run haskell programs without any engineering effort. But I’m missing the haskell-language-server, cabal, and stack.


The first thing I tried was using the manifest.scm and .envrc to create a per-project environment for experimentation. This is a technique that I have tried for common-lisp, python and javascript projects and I like it.

Example in Common-lisp:
manifest.scm:

;; This manifest defines the development env for this project.
;; Run 'guix shell' in this directory to activate it.

(specifications->manifest 
  (list "sbcl" "git" "cl-cffi" "openssl" "sqlite" "postgresql" "libpng" "libjpeg-turbo"))

.envrc:

eval "$(guix shell -m manifest.scm --search-paths)"

In Python, it’s the same thing but I’m able to add other things like pyright for language-server support. I mention that because, emacs can pick it up no problem, then I can use eglot and get the blessings of an IDE.

In Haskell, so far I can use that same pattern to run haskell programs and the ghc is available in Guix but I cannot find the haskell-language-server, stack, nor cabal (there is cabal-install, but…).

If it can be helped I want to avoid engineering through this. Any pointers?

cabal-install is the cli program for cabal. you actually want that to do package managament. If you pull in both cabal-install and ghc then you can build packages in the “mutable” way (not using guix store and not pinned, but iirc guix don’t like pinning stuff anyway). You may have to pull in other native libraries like zlib onto the path if you start using dependencies.