summaryrefslogtreecommitdiff
path: root/lib/attrsets.nix
diff options
context:
space:
mode:
authornixpkgs-ci[bot] <190413589+nixpkgs-ci[bot]@users.noreply.github.com>2025-08-11 00:24:16 +0000
committerGitHub <noreply@github.com>2025-08-11 00:24:16 +0000
commitef3238a84cc5d5b60de2aec6ecc7d434c8da1b5c (patch)
tree5605011b7d6dad28bac39254aa1488cadddac7c3 /lib/attrsets.nix
parenthaskellPackages.cabal2nix-unstable: 2025-06-14 -> 2025-08-10 (diff)
parentbalena-cli: 22.1.5 -> 22.2.4 (#432566) (diff)
downloadnixpkgs-origin/haskell-updates.tar.gz
Merge b1b0d690fbb0e4a2fa029ab625a3b1646487fee1 into haskell-updatesorigin/haskell-updates
Diffstat (limited to 'lib/attrsets.nix')
-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