Xmobar doesn't start with XMonad in NixOS

I’m having trouble getting Xmobar to start from within XMonad: When i run xmobar in a user terminal, it works, but when it should run from within XMonad it doesn’t appear. I’ve read about Xmobar issues with $PATH but i don’t know how to debug the $PATH variable from within xmonad. I also can’t find any logs in .xsession or systemd logs. Any solutions or ideas how to approach it?

# NixOS config
 services.xserver = {
    enable = true;
    displayManager.defaultSession = "xfce+xmonad";
    desktopManager = {
      gnome.enable = true;
      xterm.enable = false;
      xfce = {
        enable = true;
        noDesktop = true;
        enableXfwm = false;
      };
    };
    windowManager = {
      xmonad.enable = true;
      xmonad.enableContribAndExtras = true;
      xmonad.extraPackages = hPkgs: [ hPkgs.xmobar ];
    };
  };
-- xmonad.hs config
main = do
  xmonad
     . ewmhFullscreen
     . ewmh
     . withEasySB (statusBarProp "xmobar" (pure def)) defToggleStrutsKey
     $ xfceConfig

Okay, i found the issue. With the newer statusbarProp convenience helper functions (including withEasySB, dynamicEasySBs etc), the input format changes so that the default Xmobar config doesn’t work. You have to set a custom Xmobar config with RunXMonadLog plugin instead of the default StdinReader:

-- .xmobarrc
Config { 
       , commands = [ 
                    ...
                    , Run XMonadLog
                    -- , Run StdinReader -- infos coming from xmonad
                    ]
       , template = "%XMonadLog% ..."
       }

It’s mentioned in the XMonad setup guide but easy to overlook. Hint: for multiple Xmobars on multiple screens, you have to use different “log properties”:

Config { ...
       , commands = [ Run XPropertyLog "_XMONAD_LOG_1", ... ]
       , template = "%_XMONAD_LOG_1% }{ ..."
       }

See status bar documentation.