summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authordotlambda <github@dotlambda.de>2025-11-29 19:37:08 +0000
committerGitHub <noreply@github.com>2025-11-29 19:37:08 +0000
commita09378c0108815dbf3961a0e085936f4146ec415 (patch)
treeea06bbbefff11b891ec1fb6968883751f00ed3cc /lib
parentec69ac126baf26154d60f580866486ac93351b35 (diff)
parent82c4e4f1ef9a89c1573b245d226d689651df569f (diff)
treewide: use lib.concatAttrValues to obtain all optional-dependencies (#465847)
Diffstat (limited to 'lib')
-rw-r--r--lib/default.nix1
-rw-r--r--lib/lists.nix24
2 files changed, 24 insertions, 1 deletions
diff --git a/lib/default.nix b/lib/default.nix
index e10332ca58dd..044277fa24f5 100644
--- a/lib/default.nix
+++ b/lib/default.nix
@@ -303,6 +303,7 @@ let
elem
elemAt
isList
+ concatAttrValues
;
inherit (self.strings)
concatStrings
diff --git a/lib/lists.nix b/lib/lists.nix
index fa2a526d1602..3be3715b9200 100644
--- a/lib/lists.nix
+++ b/lib/lists.nix
@@ -10,7 +10,7 @@ let
id
warn
;
- inherit (lib.attrsets) mapAttrs attrNames;
+ inherit (lib.attrsets) mapAttrs attrNames attrValues;
inherit (lib) max;
in
rec {
@@ -1997,4 +1997,26 @@ rec {
*/
mutuallyExclusive = a: b: length a == 0 || !(any (x: elem x a) b);
+ /**
+ Concatenate all attributes of an attribute set.
+ This assumes that every attribute of the set is a list.
+
+ # Inputs
+
+ `set`
+
+ : Attribute set with attributes that are lists
+
+ # Examples
+ :::{.example}
+ ## `lib.concatAttrValues` usage example
+
+ ```nix
+ concatAttrValues { a = [ 1 2 ]; b = [ 3 ]; }
+ => [ 1 2 3 ]
+ ```
+
+ :::
+ */
+ concatAttrValues = set: concatLists (attrValues set);
}