2024-02-11 07:16:25 +00:00
|
|
|
# All of the custom functions suitable for all environments.
|
2022-01-07 03:08:50 +00:00
|
|
|
{ lib }:
|
2021-12-06 09:55:40 +00:00
|
|
|
|
2021-12-08 04:20:18 +00:00
|
|
|
rec {
|
2021-11-25 11:55:30 +00:00
|
|
|
/* 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
|
2021-11-25 11:55:30 +00:00
|
|
|
*/
|
|
|
|
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);
|
2023-07-14 02:50:37 +00:00
|
|
|
|
2024-02-11 07:16:25 +00:00
|
|
|
getConfig = type: config: ../configs/${type}/${config};
|
2023-07-14 02:50:37 +00:00
|
|
|
|
2024-02-11 07:16:25 +00:00
|
|
|
getUser = type: user: ../configs/${type}/_users/${user};
|
2021-11-25 11:55:30 +00:00
|
|
|
}
|