nix/doc/manual/utils.nix

16 lines
427 B
Nix
Raw Normal View History

2020-09-16 12:55:24 +00:00
with builtins;
2021-01-25 17:19:32 +00:00
rec {
2020-09-16 12:55:24 +00:00
splitLines = s: filter (x: !isList x) (split "\n" s);
concatStrings = concatStringsSep "";
2021-01-25 17:19:32 +00:00
# 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));
2020-09-16 12:55:24 +00:00
}