Edit XMonad configuration with IDE support

Why XMonad? Because this opens me up to write complex workflows in Haskell with its type-safety benefits.

Over at FP Zulip, when I floated the idea of writing Haskell DSL for i3 configuration, someone suggested to just use XMonad instead. XMonad is a window manager where your configuration file is just Haskell code.

Because it is all Haskell, we can use haskell-language-server to provide full IDE support – autocomplete, hover popups, documentation links, etc. – for editing window manager configuration.


Here’s how you do it:

Step 4 basically involves using the Main.hs as the config file, as well as copying over the Cabal dependencies. So, in your configuration.nix you would do something like:

services.xserver.windowManager.xmonad = {
  enable = true;
  extraPackages = haskellPackages: [
  enableContribAndExtras = true;
  config = pkgs.lib.readFile ./xmonad-config/Main.hs;

Your Cabal project lives at ./xmonad-config … and, if you followed the instructions in Scaffold a Haskell project w/ IDE support + Nix to setup IDE configuration, you can simply launch VSCode using code ./xmonad-config to start editing your configuration.



Links to this page