Why the overlays defined in flake.nix must use "final" and "prev" as arguments?

So I just notice that the name of the overlays’s argument is checked here, and I’m confused, since overlays are lambda expressions, why can’t I use self: super: {...} instead of final: prev: {...}?

6 Likes

It would work as well, were not for the check, but Nix is trying to be more user friendly these days so we want to standardize as much stuff as possible. final and prev were chosen as more understandable names for building the fix point.

4 Likes

I’d argue this behavior causes more confusing rather than convenience, as these arguments are not named parameters.

If someone has written an overlay before flakes using self: super: pairs, he cannot simply reuse it as overlay = import ./overlay.nix but forced to write overlay = final: prev: (import ./overlay.nix) final prev.

For existing users, this is not elegent. For newcommers, they may be surprised and think alpha equivalence does not hold here.

1 Like

If I am not mistaken, you should still be able to use overlays with arbitrary argument name. nix flake check is only an optional tool that checks for evaluation, build and style issues. This belongs to the lattermost category.

I guess we could make the error message a little more explanatory by saying it is a convention.

1 Like

w.r.t. this convention, I wonder how much final: prev: has caught on.

I’ve always been writing self: super: so I’m not used to it at all. Indeed, my own flake.nix has an eta-expanded overlay to satisfy the check.

https://github.com/dramforever/config/blob/2b3883db27e9587fc9e820873874e346260e6f4f/nixos/flake.nix

I see this as a plus though; it means everyone is going to use the same convention so you can copy/paste overlays. It is also clearer than self: super: imo .

3 Likes