@otini FWIW there a NixOS module https://nixos.org/nixos/manual/options.html#opt-services.xserver.windowManager.xmonad.extraPackages that should setup everything required for a properly working XMonad. No need to install XMonad ad-hoc in your user environment.
PS I cannot answer the direct question because I do not understand what is your goal there.