XMonad stopped compiling

I’ve been happily using XMonad for years without the slightest hint of trouble.

After upgrading some machines to 22.05 and switching to using flakes in the home-manager configuration, XMonad now gives this error when recompiling.

xmonad --recompile   
XMonad will use ghc to recompile, because neither "/home/jacg/.xmonad/build" nor "/home/jacg/.xmonad/stack.yaml" exists.
XMonad recompiling (forced).
Errors detected while compiling xmonad config: /home/jacg/.xmonad/xmonad.hs
$ /nix/store/k04rwak83lpsssixmv4c1v4jq7c2d8n9-ghc-9.0.2-with-packages/bin/ghc --make xmonad.hs -i -ilib -fforce-recomp -main-is main -v0 -outputdir /home/jacg/.xmonad/build-x86_64-linux -o /home/jacg/.xmonad/xmonad-x86_64-linux

xmonad.hs:84:34: error:
    Module ‘XMonad.Hooks.DynamicLog’ does not export ‘defaultPP’
   |
84 | import XMonad.Hooks.DynamicLog ( defaultPP
   |                                  ^^^^^^^^^

xmonad.hs:133:37: error:
    Module ‘XMonad.Prompt’ does not export ‘defaultXPConfig’
    |
133 | import XMonad.Prompt (autoComplete, defaultXPConfig)
    |                                     ^^^^^^^^^^^^^^^

Bizarrely enough, my daily driver (alone among all the machines I upgraded this way) did NOT suffer from this problem when recompiling with the XMonad keystroke MOD-q, until I tried to recompile XMonad from the command line with xmonad --recompile, at which point I got the same error, which now also appears in response to Mod-q.

How should I go about getting to the bottom of this problem?

That’s because when you run xmonad --recompile, it builds your code into a binary and stores that at $HOME/.xmonad/xmonad-x86_64-linux. When you upgraded, that binary didn’t get altered, so you were still running with the old version of xmonad (fun fact: if you’d deleted the old nixos generation and ran a GC, that binary would be dynamically linked to libraries that no longer exist and it wouldn’t have launched).

Anyway it sounds like xmonad changed its API for those two modules. You just need to consult the docs/changelogs for xmonad and see what you’re expected to use instead now.

Tried that. AFAICT, DynamicLog is now a deprecated (but still supposedly working) wrapper around StatusBar and StatusBar.PP. Both the old and the new give me similar errors.

In 0.17.0 the various default... functions have been unified into a single def which can be imported from the top-level XMonad.

So:

  • don’t import any default...
  • do import XMonad (def)
  • replace all uses of default... with def