Format using nixfmt rfc style

This commit is contained in:
Paul-Henri Froidmont 2024-08-20 22:58:24 +02:00
parent d07a224bbc
commit f6be5f8b80
Signed by: phfroidmont
GPG key ID: BE948AFD7E7873BE
37 changed files with 934 additions and 612 deletions

View file

@ -1,26 +1,22 @@
{ lib, ... }:
with builtins;
with lib;
rec {
# attrsToList
attrsToList = attrs:
mapAttrsToList (name: value: { inherit name value; }) attrs;
attrsToList = attrs: lib.mapAttrsToList (name: value: { inherit name value; }) attrs;
# mapFilterAttrs ::
# (name -> value -> bool)
# (name -> value -> { name = any; value = any; })
# attrs
mapFilterAttrs = pred: f: attrs: filterAttrs pred (mapAttrs' f attrs);
mapFilterAttrs =
pred: f: attrs:
lib.filterAttrs pred (lib.mapAttrs' f attrs);
# Generate an attribute set by mapping a function over a list of values.
genAttrs' = values: f: listToAttrs (map f values);
genAttrs' = values: f: lib.listToAttrs (map f values);
# anyAttrs :: (name -> value -> bool) attrs
anyAttrs = pred: attrs:
any (attr: pred attr.name attr.value) (attrsToList attrs);
anyAttrs = pred: attrs: lib.any (attr: pred attr.name attr.value) (attrsToList attrs);
# countAttrs :: (name -> value -> bool) attrs
countAttrs = pred: attrs:
count (attr: pred attr.name attr.value) (attrsToList attrs);
countAttrs = pred: attrs: lib.count (attr: pred attr.name attr.value) (attrsToList attrs);
}