aboutsummaryrefslogtreecommitdiff
path: root/doc/manual/utils.nix
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2021-01-25 18:19:32 +0100
committerEelco Dolstra <edolstra@gmail.com>2021-01-25 18:19:32 +0100
commit807d963ee8d23e88f09e28365b045d322530c5aa (patch)
tree69a055b564097daa62b15a84aa3458b1c80df178 /doc/manual/utils.nix
parent3ba98ba8f08523e60310cf75ec809bd21d0ce977 (diff)
Group subcommands by category
Diffstat (limited to 'doc/manual/utils.nix')
-rw-r--r--doc/manual/utils.nix10
1 files changed, 9 insertions, 1 deletions
diff --git a/doc/manual/utils.nix b/doc/manual/utils.nix
index 50150bf3e..d4b18472f 100644
--- a/doc/manual/utils.nix
+++ b/doc/manual/utils.nix
@@ -1,7 +1,15 @@
with builtins;
-{
+rec {
splitLines = s: filter (x: !isList x) (split "\n" s);
concatStrings = concatStringsSep "";
+
+ # FIXME: O(n^2)
+ unique = foldl' (acc: e: if elem e acc then acc else acc ++ [ e ]) [];
+
+ nameValuePair = name: value: { inherit name value; };
+
+ filterAttrs = pred: set:
+ listToAttrs (concatMap (name: let v = set.${name}; in if pred name v then [(nameValuePair name v)] else []) (attrNames set));
}