57 lines
1.2 KiB
Nix
57 lines
1.2 KiB
Nix
{lib}: {
|
|
## Quickly enable an option.
|
|
##
|
|
## ```nix
|
|
## services.nginx = enabled;
|
|
## ```
|
|
##
|
|
#@ true
|
|
enabled = {
|
|
enable = true;
|
|
};
|
|
|
|
## Quickly disable an option.
|
|
##
|
|
## ```nix
|
|
## services.nginx = enabled;
|
|
## ```
|
|
##
|
|
#@ false
|
|
disabled = {
|
|
enable = false;
|
|
};
|
|
|
|
## Like lib.mkEnableOption, but allows specifying the default.
|
|
##
|
|
## ```nix
|
|
## options.marleyos.wayland = mkEnableOption' "wayland" false;
|
|
## ```
|
|
mkEnableOption' = name: default:
|
|
lib.mkOption {
|
|
inherit default;
|
|
example = true;
|
|
description =
|
|
if name ? _type && name._type == "mdDoc"
|
|
then lib.mdDoc "Whether to enable ${name.text}."
|
|
else "Whether to enable ${name}.";
|
|
type = lib.types.bool;
|
|
};
|
|
|
|
## Like lib.mkDefault, but uses lib.mapAttrsRecursive to apply mkDefault to
|
|
## every attr in the set.
|
|
##
|
|
## ```nix
|
|
## starship.settings.username = mkDefault' {
|
|
## enabled = true;
|
|
## show_always = false;
|
|
## };
|
|
## ```
|
|
## is equivalent to:
|
|
## ```nix
|
|
## starship.settings.username = {
|
|
## enabled = mkDefault true;
|
|
## show_always = mkDefault false;
|
|
## };
|
|
## ```
|
|
mkDefault' = set: lib.mapAttrsRecursive (_: value: lib.mkDefault value) set;
|
|
}
|