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:
- Create a cabal project (see Scaffold a Haskell project w/ IDE support + Nix)
-
Add your XMonad configuration to the
Main.hs
-
Add
xmonad
,xmonad-contrib
and other dependencies to the cabal file - Adjust your NixOS XMonad configuration to use this project
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: [
haskellPackages.xmonad-contrib
haskellPackages.containers
];
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.