-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Description
Is your feature request related to a problem? Please describe.
Sometimes we pay a big cost evaluating stuff just to use a small set of what is available. A feature like this could reduce the impact for smaller evaluations.
Describe the solution you'd like
In the JavaScript world, there is a tool called proxy. Basically it allows you to create an object (like our attrset) that looks like a static object but any access or operation is handled by a function instead of a lookup.
Actually, the idea came from RFC 140. With this system, a lookup could be trivially implemented by a slice and sum of strings. A builtins.attrNames
could be very expensive, though.
A clear and concise description of what you want to happen.
A builtin function to create a proxy attrset. Example:
proxy = builtins.mkProxy {
lookup = key: "Hello, ${key}"; # proxy.world would return "Hello, world"
list = []; # what builtins.attrNames would return, this is the default value
}
The keys could be memoized, like a evaluation cache. I have no idea actually about the difference in number of evaluation thunks for something like nixpkgs though.
Describe alternatives you've considered
(pkgs "package").outPath
maybe
Additional context
Add any other context or screenshots about the feature request here.
Priorities
Add 👍 to issues you find important.