I have a fairly simple situation where I’m defining an overlay in one flake and using it in another.
In the dependency flake I’ve defined a package called zlib - nb, there is already a package with the same name in nixpkgs, and put it into that flake’s overlay:
zlib = with pkgs; callPackage ./zlib.nix {};
in {
packages.default = zlib;
overlays = final: prev: { inherit zlib; };
That all builds fine and no errors there. nix eval --raw .# gives me the store path for this, /nix/store/vn36lf7ilbcnwl2bd0qpsixi7gfxkvmi-zlib. So far so good.
I then have a second flake, which imports the dependency flake, and uses its overlay to define pkgs:
where the derivation in main_package.nix lists zlib as one of its parameters.
Unfortunately it’s taking the pre-existing nixpkgs zlib instead of my new one, as I can see by looking at the store paths in nix show-derivation .#mainPackage. Am I making some elementary mistake here? I can’t see how.
Overlays are not system-spaced, so I’m not sure what you’re doing zlib.overlays.${system} for, nor why it’s not yelling at you when you try.
Also, when defining the overlay, you should probably be using zlib = final.callPackage ./zlib.nix {};, rather than pulling in a separate nixpkgs invocation just for zlib.
However, for the main question, of why it’s not picking up the new package, the only thing I can think of is that you defined callPackage with a let or an argument binding somehow, and it’s overriding the with pkgs;.
Yeah, a quick check of the code says flake-utils.lib.eachDefaultSystem doesn’t know about overlays not being system-spaced. I think you might be expected to know that yourself and put them in with // outside of the call.