summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/attrsets.nix10
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/attrsets.nix b/lib/attrsets.nix
index 8fac72e741c7..124c22a885e1 100644
--- a/lib/attrsets.nix
+++ b/lib/attrsets.nix
@@ -633,6 +633,16 @@ rec {
: Predicate taking an attribute name and an attribute value, which returns `true` to include the attribute, or `false` to exclude the attribute.
+ <!-- TIP -->
+ If possible, decide on `name` first and on `value` only if necessary.
+ This avoids evaluating the value if the name is already enough, making it possible, potentially, to have the argument reference the return value.
+ (Depending on context, that could still be considered a self reference by users; a common pattern in Nix.)
+
+ <!-- TIP -->
+ `filterAttrs` is occasionally the cause of infinite recursion in configuration systems that allow self-references.
+ To support the widest range of user-provided logic, perform the `filterAttrs` call as late as possible.
+ Typically that's right before using it in a derivation, as opposed to an implicit conversion whose result is accessible to the user's expressions.
+
`set`
: The attribute set to filter