How do I pass an overlay to a flake input so *it* builds using the overlay'd package.?

I have a simple CMake based flake that as the ‘openscenegraph’ package as one of its buildInputs. I want to be able to use this flake in several other flake based projects. All good so far, now, one of the consumers of this flake has a modified openscenegraph (via an overlay) that it’s using. I want to be able to use this same modified openscenegraph in the first flake. However, when I simply add the first flake as an input to the second, the first flake picks up the non-patched openscenegraph instead of the “overlayed” one. It seems like if I want the input flake to use my overlay, I need to pass a modified Nixpkgs to it in some way? Any idea how to do this or is there another way to handle this?

Thanks for any suggestions/insights.

-John

Flakes and overlays are two different ways to compose package trees. Unless you expose your packages through the overlays output you can’t do this.

You need to either compose the packages via flakes or overlays, not both.

More specifically, whatever you’re doing in packages.<system>.openscenegraph is using its own nixpkgs instance (which you’ve created via import nixpkgs { ... } or nixpkgs.legacyPackages.<system>).

Overlays only apply to a specific instance of nixpkgs.

If you want to share instances you’ll have to expose overlays.<name> in the producing flake, and then use that overlay in the consuming flake.

1 Like

Thanks for the insight. I’ll go investigate the best way to send the overlay into the input flakes.