How to replace package from nixpkgs with a different derivation

Hello. I am trying to trace a bug in nixos that affects my system. In 24.11, the intel DDX (xf86videoIntel) is broken. However, in 24.05, it is working. I have determined that this is an issue with some derivation, likely mesa.

What I am trying to figure out right now though is how I can replace the 24.05 version of mesa with a completely different derivation, not just simply using overridingAttrs, etc. I have a system running 24.05, and I want to see if building mesa on 24.05 with the 24.11 version of its derivation (much different from 24.05) causes the same issue I am having on 24.11.

Here is what I have tried so far:

nixpkgs.overlays = [
  (final: prev: {
    mesa = prev.callPackage ./mesa { };
  })
];

But this seems to try and compile all dependent packages in nixpkgs, including ones that arent installed on my system. Unfortunately, I do not have the patience for that, let alone the disk space!

Is there a way I can make the overlay only compile dependent packages that are installed on my system? Or is there another method available? Surely I am missing something obvious!

I think what’s being downloaded will just be build dependencies not usually in your system closure. If you copied the old derivation into ./mesa your code does exactly what you intend. That said, all reverse dependencies will have to be rebuilt, which is pretty much everything graphical on your system. No way around it, and not doing that would anyway mean you aren’t really testing the old mesa.

You can also just override the mesa input in various packages instead of doing it system-wide with some well-placed .overrides, if you have a more narrow test case.

YMMV, anyway, good chance the derivation won’t work with the new packages etc.

1 Like