diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2021-01-25 18:19:32 +0100 |
---|---|---|
committer | Eelco Dolstra <edolstra@gmail.com> | 2021-01-25 18:19:32 +0100 |
commit | 807d963ee8d23e88f09e28365b045d322530c5aa (patch) | |
tree | 69a055b564097daa62b15a84aa3458b1c80df178 /doc/manual/utils.nix | |
parent | 3ba98ba8f08523e60310cf75ec809bd21d0ce977 (diff) |
Group subcommands by category
Diffstat (limited to 'doc/manual/utils.nix')
-rw-r--r-- | doc/manual/utils.nix | 10 |
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)); } |