Nividia driver not working

Hello dear NixOS wizards

I installed the Nvidia legacy driver for an iMac late 2013

Here is the part from the config.nix file:

  # Nvidia
  services.xserver.videoDrivers = [ "nvidia" ];
  hardware.nvidia.package = config.boot.kernelPackages.nvidiaPackages.legacy_390;
  hardware.opengl.enable = true;

Somehow it doesn’t work, the two external displays HP M27ffq with free sync are recognized by the Nvidia application and also by the Gnome settings. But the screen stays blank, has no connection.

With Wayland everything woks fine.
With X Window System and the open source driver Nuveau the OS is crashing frequently.

What would be the best steps going forward to get them monitors working? where can I find logfiles that are interesting.

Maybe I should add that I had the Nvidia driver working with the two screens before. Only the resolution war to low, but I could live with that. But after a reboot, it did not work anymore and no matter what I do I can’t get it to work. I even reinstalled NixOS.

Thank you in advance for your help!