NixOS / nix

Nix, the purely functional package manager
https://nixos.org/
GNU Lesser General Public License v2.1
12.74k stars 1.52k forks source link

Extend function reflection #10350

Open roberth opened 7 months ago

roberth commented 7 months ago

Is your feature request related to a problem? Please describe.

Function reflection is an important part of everyday use of the Nix language, in callPackage and the module system, to improve syntax and to make strict functions lazy.

However, the information is too limited, creating pitfalls that "library" code such as callPackage can not currently compensate.

Furthermore, it prevents improvements to be made without breaking compatibility:

Describe the solution you'd like

Two solutions have been already been proposed:

They could hardly be more different. Open design questions:

Currently implemented by neither:

Describe alternatives you've considered

Additional context

Priorities

Add :+1: to issues you find important.

anna328p commented 7 months ago

https://github.com/anna328p/nix-prelude/blob/main/introspection.nix

Most of this is already possible in a hacky way using toXML. I use it in my Nix code.

roberth commented 7 months ago

@infinisil has also written something like that in https://github.com/NixOS/nixpkgs/pull/194992

I suppose it's an extra argument for making this info available: it already is available. Of course it shouldn't have to be hacky or slow.