Firefox memory leak | firefox bad performance on intel integrated graphics

I recently installed nixos on an off-brand laptop from a local manufacturer. Whenever I opened firefox I would start noticing a huge performance drop, as well as memory ramping up (even after killing firefox) until I had to hit the power button as the system deemed unusable. I also noticed a few posts from reddit and nixpkgs github’s issues but none of them seemed to solve the problem

After looking for a while, I found out that firefox was trying to use VAAPI, which was not available in my system.

[GFX1-]: vaapitest: VA-API test failed: failed to initialise VAAPI connection.

Just add the following lines to your configuration.nix

  hardware.opengl.extraPackages = with pkgs; [                                                                                                                              
    vaapiIntel                                                                                                                                                              
    libvdpau-va-gl                                                                                                                                                          
    intel-media-driver                                                                                                                                                      
  ];

I’m unaware if this is an nixos specific issue