Nvidia legacy 390xx drivers for bumblebee

When I was going install nvidia driver on my laptop with GT 635m, I pasted this text in configuration.nix:

  hardware = {
    bluetooth.enable = false;
    pulseaudio.enable = true;
    bumblebee = {
      enable = true;
      driver = "nvidia";

Then nvidia 418.74 (that’s incompaitble with gt 625m) was installed. This version, of course, did not work. So then I found this way to install legacy 390xx driver:

boot.kernelPackages = pkgs.linuxPackages.extend (self: super: {
  nvidia_x11 = super.nvidia_x11_legacy390;

But after starting ‘optirun firefox’ I got this error:
[ 1299.637557] [ERROR]Cannot access secondary GPU - error: [XORG] (EE) /dev/dri/card0: failed to set DRM interface version 1.4: Permission denied

This was caused, as i understand, by incompatible 418.74 driver (/var/log/X.bumblebee.log):

[ 1299.637593] [ERROR]Aborting because fallback start is disabled.
[   773.416] (WW) NVIDIA(0): The NVIDIA GeForce GT 635M GPU installed in this system is
[   773.416] (WW) NVIDIA(0):     supported through the NVIDIA 390.xx Legacy drivers. Please
[   773.416] (WW) NVIDIA(0):     visit http://www.nvidia.com/object/unix.html for more
[   773.416] (WW) NVIDIA(0):     information.  The 418.74 NVIDIA driver will ignore this
[   773.416] (WW) NVIDIA(0):     GPU.  Continuing probe...

I tried to install 340xx driver (that supports gt 635m too), but it also didn’t work because 418.74 replaced it. I tried "nix-collect-garbage -d’ but all nvidia drivers were remained. How delete unnecessary drivers besides 390xx and turn it to start?

Adding services.xserver.videoDrivers = ["nvidiaLegacy390"]; doesn’t solve the problem, 418.74 is using instead.


Have you tried to run optirun under superuser, e.g. as root or using sudo ?

I have the same problem. Have you found a solution for this?

I added this

boot.kernelPackages = pkgs.linuxPackages.extend (self: super: {
  nvidia_x11 = super.nvidia_x11_legacy390;

But it gives this error [XORG] (EE) Failed to load module "mouse" (module does not exist, 0)