aboutsummaryrefslogtreecommitdiff
path: root/doc/manual/utils.nix
diff options
context:
space:
mode:
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));
}