1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-24 18:01:16 +02:00

Group subcommands by category

This commit is contained in:
Eelco Dolstra 2021-01-25 18:19:32 +01:00
parent 3ba98ba8f0
commit 807d963ee8
3 changed files with 32 additions and 6 deletions

View file

@ -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));
}