Developping Haskell on NixOS with haskell-language-server and reflex-platform

reflex-platform is a nix-based framework that allows me to develop web apps (as well as android and iOS apps) completely in Haskell. Awesome.

The type-checking of Haskell in combination with complex UI is extremely powerful.

haskell-language-server is a comprehensive effort to provide haskell developers with powerful IDEs. I use it with emacs (cf. lsp-haskell).

Together with the last building block, servant-reflex, I can have a type-checked API, backend and frontend completely integrated, all covered by my IDE.

To me, all of this is ground-breaking stuff. Haskell’s type system in principle allows for an extremely powerful IDE and it seems like the community is actually arriving there, improving the productivity of us Haskell developers tenfold.

However …

There is some set-up work required to get everything to work together.

And certain things still don’t work fully.

For example:

reflex-dom is a package required by reflex-platform and requires a GHC version no newer than 8.6.5. Which wouldn’t be any problem, if not …

haskell-language-server required for Template Haskell (cf. the relevant issue) a GHC version >= 8.10.2

My temporary solution is thus to work on the backend with a GHC-8.10.2 setup, while I work on the frontend with a GHC-8.6.5/ghcjs setup. Luckily, reflex-platform allows such adaptations without big problems.

I would like to get to know everyone who uses this same setup. It’s awesome. Let’s share solutions, workarounds, configuration, etc.

In case someone’s interested, I will make my setup public here. I am not a Nix-pro by any means. If I could do it, anyone can :slight_smile:


Regarding a working version of haskell-language-server I received some help by Malte, who agreed that I share our conversation here.

Jan 14th, 2021 Ruben wrote:


I am trying to get haskell-language-server to work with reflex-platform.

For both projects the support for nixos is there, but sometimes combining stuff still is difficult.

My current problem is this:

The nixos binaries for haskell-language-server are compiled with GHC-8.10.

reflex-platform supports up to GHC-8.8.

Now I have a particular question. In the nixos package search, I find haskell-language-server version on the unstable channel with this:

Long description
This package provides haskell-language-server, haskell-language-server-wrapper, haskell-language-server-8.6.5, haskell-language-server-8.6, haskell-language-server-8.8.4, haskell-language-server-8.8, haskell-language-server-8.10.2, haskell-language-server-8.10. You can override the list supportedGhcVersions.

However, checking out the actual .nix files in nixpkgs/pkgs/development/tools/haskell/haskell-language-server/ there is no such thing as “supportedGhcVersion”. And: The version of haskell-language-server seems to be fixed to GHC-8.10.

Any clue what the origin of this inconsistency might be? Is there, somewhere, a nix-package ready to use, with haskell-language-server compiled by GHC-8.6.5?


If you point me to some repo, I will gladly post this as a public issue.

Jan 14th, 2021 Ruben wrote:

I just realized, there is a difference between




The latter one might be the solution to my problems.

Still interesting how this all comes about.

Jan 14th, 2021 Malte Brandy wrote:

Hey Ruben,

I have my project setup in a way, that the majority of my code compiles
against reflex out of current nixpkgs master.
And I only compile the server and for android using reflex-platform with
a very thin layer of code that does not work without it.
The part that compiles to native+webkit via ghc+jsaddle works on ghc
8.10 and I really like that.

If you are curious you can see my project which uses this approach here:

All those words were just to say: I don‘t have a running setup for what
you which for because I didn‘t want the trouble.

That being said: Using hls from one nixpkgs version so far apart from
the one your ghc is from. i.e hls from unstable + ghc from
reflex-platform won‘t work for various reasons. a) Incompatible glibc
versions b) at least the ghc used by obelisk is even a patched ghc so
it’s not the same as ghc-8.6.5 from unstable.
So I think the only chance you have to get this to run would be to
compile hls with the nixpkgs pinned by reflex-platform. I would not say
this is impossible. I have done this with ghcide about a year ago and it
was challenging. But hls is quite a beast with a lot of quite new
dependencies so manually updating/introducing all of those dependencies
into the old nixpkgs will take days and probably end in hundreds of
lines of overrides.
Right now the haskellPackages infrastructure is very unflexible in
generating all dependencies from a Cabal build plan. haskell.nix is
better in that, but reflex-platform does not use haskell.nix so I don‘t
think this helps you very much either.

So I am not saying what you want is impossible I can just say from my
experience that I don‘t know a realiable or practical way to achieve it.

Other than that it seems you have figured out the structure. Our manual
has a section on it:

I which I had better news.

Btw. good places to have these discussions more openly is or just the GitHub - NixOS/nixpkgs: Nix Packages collection
issue tracker. Feel free to ping me on either if you have issues either
with reflex or with hls. I am deep down those rabbit-holes.


@maralorn cheers!

1 Like