nixos-config/lib/default.nix
Gabriel Arazas a4177f9382
flake-parts/setups: set separate namespace for custom library
This at least allows us to make custom environment-specific library sets.
2024-02-11 15:16:25 +08:00

22 lines
612 B
Nix

# All of the custom functions suitable for all environments.
{ lib }:
rec {
/* Count the attributes with the given predicate.
Examples:
countAttrs (name: value: value) { d = true; f = true; a = false; }
=> 2
countAttrs (name: value: value.enable) { d = { enable = true; }; f = { enable = false; package = [ ]; }; }
=> 1
*/
countAttrs = pred: attrs:
lib.count (attr: pred attr.name attr.value)
(lib.mapAttrsToList lib.nameValuePair attrs);
getConfig = type: config: ../configs/${type}/${config};
getUser = type: user: ../configs/${type}/_users/${user};
}