Conversation
|
Can you tell me a bit more about the use case of this? Would be great to have some links to code where this could be used :) |
I imagine it would be most useful for collecting leaf nodes for freeform trees. The current usecase I have for this is #342372, where I want to collect warnings and assertions from a freeform tree and include the names of the warnings / assertions that trigger in the error message. It could be used for similar purposes in places where we already use |
6773c45 to
4d27868
Compare
4d27868 to
bbf2f01
Compare
hsjobeki
left a comment
There was a problem hiding this comment.
Hm after thinking about #395160
These are kind of duplicates of each other.
The only major difference is that the other PR has a value function f to produce the result.
Also it has a slight difference in the recursion flow.
Description of changes
This PR adds a new function
lib.attrsets.collect'. Similarly tocollect, it will recursively collect items that satisfy a predicate from an attrset tree, but this version will also track the attribute path to the items it collects.This can be useful for collecting leaves in a tree, and either reporting detailed errors to the user, or for use in configuration file generation.
I've also added tests for the normal
collectimplementation, since it seemed to be missing.Things done
nix.conf? (See Nix manual)sandbox = relaxedsandbox = truenix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/)Add a 👍 reaction to pull requests you find important.