2024-02-25 12:02:41 +00:00
|
|
|
# The entrypoint for our custom library set.
|
2024-02-25 14:27:05 +00:00
|
|
|
{ pkgs }:
|
2021-12-06 09:55:40 +00:00
|
|
|
|
2024-02-25 14:27:05 +00:00
|
|
|
pkgs.lib.makeExtensible
|
2024-02-25 12:02:41 +00:00
|
|
|
(self:
|
|
|
|
rec {
|
|
|
|
/* Count the attributes with the given predicate.
|
2021-11-25 11:55:30 +00:00
|
|
|
|
2024-02-25 12:02:41 +00:00
|
|
|
Examples:
|
|
|
|
countAttrs (name: value: value) { d = true; f = true; a = false; }
|
|
|
|
=> 2
|
2021-12-06 07:27:51 +00:00
|
|
|
|
2024-02-25 12:02:41 +00:00
|
|
|
countAttrs (name: value: value.enable) { d = { enable = true; }; f = { enable = false; package = [ ]; }; }
|
|
|
|
=> 1
|
|
|
|
*/
|
|
|
|
countAttrs = pred: attrs:
|
2024-02-25 14:27:05 +00:00
|
|
|
pkgs.lib.count (attr: pred attr.name attr.value)
|
|
|
|
(pkgs.lib.mapAttrsToList pkgs.lib.nameValuePair attrs);
|
2023-07-14 02:50:37 +00:00
|
|
|
|
2024-02-25 12:02:41 +00:00
|
|
|
/* Returns the file path of the given config of the given environment.
|
2023-07-14 02:50:37 +00:00
|
|
|
|
2024-02-25 12:02:41 +00:00
|
|
|
Type: getConfig :: String -> String -> Path
|
|
|
|
|
|
|
|
Example:
|
|
|
|
getConfig "home-manager" "foo-dogsquared"
|
|
|
|
=> ../configs/home-manager/foo-dogsquared
|
|
|
|
*/
|
|
|
|
getConfig = type: config: ../configs/${type}/${config};
|
|
|
|
|
|
|
|
|
|
|
|
/* Returns the file path of the given user subpart of the given
|
|
|
|
environment. Only certain environments such as NixOS have this type of
|
|
|
|
setup.
|
|
|
|
|
|
|
|
Type: getConfig :: String -> String -> Path
|
|
|
|
|
|
|
|
Example:
|
|
|
|
getUser "nixos" "foo-dogsquared"
|
|
|
|
=> ../configs/nixos/_users/foo-dogsquared
|
|
|
|
*/
|
|
|
|
getUser = type: user: ../configs/${type}/_users/${user};
|
|
|
|
})
|