2024-11-15 19:05:46 -08:00
|
|
|
{ lib, namespace, ... }:
|
2024-11-14 21:28:56 -08:00
|
|
|
with lib;
|
|
|
|
rec {
|
2024-11-15 19:05:46 -08:00
|
|
|
## Create a module option with only an enable option.
|
|
|
|
## ```nix
|
|
|
|
## options = lib.mkEnableModule "module-name"
|
|
|
|
## ```
|
|
|
|
##
|
|
|
|
#@ String
|
|
|
|
mkEnableModule = name: {
|
|
|
|
${namespace}.${name}.enable = mkEnableModule "${name}";
|
|
|
|
};
|
|
|
|
|
2024-11-14 21:28:56 -08:00
|
|
|
## Create a NixOS module option.
|
|
|
|
##
|
|
|
|
## ```nix
|
|
|
|
## lib.mkOpt nixpkgs.lib.types.str "My default" "Description of my option."
|
|
|
|
## ```
|
|
|
|
##
|
|
|
|
#@ Type -> Any -> String
|
|
|
|
mkOpt =
|
|
|
|
type: default: description:
|
|
|
|
mkOption {
|
|
|
|
inherit
|
|
|
|
type
|
|
|
|
default
|
|
|
|
description
|
|
|
|
;
|
|
|
|
};
|
|
|
|
|
|
|
|
## Create a boolean NixOS module option.
|
|
|
|
##
|
|
|
|
## ```nix
|
|
|
|
## lib.mkBoolOpt true "Description of my option."
|
|
|
|
## ```
|
|
|
|
##
|
|
|
|
#@ Type -> Any -> String
|
|
|
|
mkBoolOpt = mkOpt types.bool;
|
|
|
|
|
|
|
|
enabled = {
|
|
|
|
## Quickly enable an option.
|
|
|
|
##
|
|
|
|
## ```nix
|
|
|
|
## services.nginx = enabled;
|
|
|
|
## ```
|
|
|
|
##
|
|
|
|
#@ true
|
|
|
|
enable = true;
|
|
|
|
};
|
|
|
|
|
|
|
|
disabled = {
|
|
|
|
## Quickly disable an option.
|
|
|
|
##
|
|
|
|
## ```nix
|
|
|
|
## services.nginx = enabled;
|
|
|
|
## ```
|
|
|
|
##
|
|
|
|
#@ false
|
|
|
|
enable = false;
|
|
|
|
};
|
|
|
|
}
|