numtide/flake-utils

name spacing overlay

blaggacao opened this issue · 1 comments

I can faintly see why package overlays are namespaced, even though simple flake does not reexport them in output.overlay.

Is it enough to encourage this as a convention vs enforcing it in the flake spec?

I agree, It would be good to enforce that convention. The main thing that has been holding me back is about what to do with the overlay function signature.
Let's say we have a wrapper like this:

name: overlay:
# The wrapping overlay
final: prev: {
  "${name}" = import overlay final prev;
}

Where name is the name of the flake, and overlay the location of the user overlay.

In that case, the user overlay can not use final to access its own attributes.

./overlay.nix

final: prev: {
  one = prev.runCommand "dummy" {} "echo dummy > $out";
  two = prev.mkDerivation {
    buildInputs = [ final.myflake.one ]; # <---
  };
}

Here the user has to know the name of the flake to access one.
We could recommend to use the rec keyword, but then the flake becomes un-overridable because it's bound to the local scope.

So the only option is to add a third argument and change the function signature. It also means that the overlay becomes unusable outside of flake-utils without a similar wrapper.