Working on modularizing stuff
This commit is contained in:
parent
835faf218d
commit
8349809fec
15 changed files with 256 additions and 41 deletions
21
lib/attrs.nix
Normal file
21
lib/attrs.nix
Normal file
|
@ -0,0 +1,21 @@
|
|||
{ lib, ... }:
|
||||
let
|
||||
inherit (lib.lists) any count;
|
||||
inherit (lib.attrsets) filterAttrs listToAttrs mapAttrs' mapAttrsToList;
|
||||
in rec
|
||||
{
|
||||
attrsToList = attrs:
|
||||
mapAttrsToList (name: value: { inherit name value; }) attrs;
|
||||
|
||||
mapFilterAttrs = pred: f: attrs:
|
||||
filterAttrs pred (mapAttrs' f attrs);
|
||||
|
||||
getAttrs' = values: f:
|
||||
listToAttrs (map f values);
|
||||
|
||||
anyAttrs = pred: attrs:
|
||||
any (attr: pred attr.name attr.value) (attrsToList attrs);
|
||||
|
||||
countAttrs = pred: attrs:
|
||||
count (attr: pred attr.name attr.value) (attrsToList attrs);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue