You could add a marker to nixpkgs to check if the overlay has been applied already:
let
overlayFoo = super.lib.optionalAttrs (!super.__fooHasBeenApplied or false) {
__fooHasBeenApplied = true;
# …
};
in
#…
It is probably simpler to get rid of the composeExtensions
though.