nixos-config/lib/default.nix

22 lines
612 B
Nix
Raw Normal View History

# All of the custom functions suitable for all environments.
{ lib }:
2021-12-06 09:55:40 +00:00
rec {
/* Count the attributes with the given predicate.
Examples:
countAttrs (name: value: value) { d = true; f = true; a = false; }
2021-12-06 07:27:51 +00:00
=> 2
countAttrs (name: value: value.enable) { d = { enable = true; }; f = { enable = false; package = [ ]; }; }
=> 1
*/
countAttrs = pred: attrs:
2021-11-25 13:45:48 +00:00
lib.count (attr: pred attr.name attr.value)
2022-11-19 03:05:31 +00:00
(lib.mapAttrsToList lib.nameValuePair attrs);
getConfig = type: config: ../configs/${type}/${config};
getUser = type: user: ../configs/${type}/_users/${user};
}