modules: add mkPackageOptionMD

another transitional option factory, like mkAliasOptionModuleMD.

pennae 9da5f12e 4c1cfbdb

Changed files
+42 -24
lib
nixos
+1 -1
lib/default.nix
···
optionAttrSetToDocList optionAttrSetToDocList'
scrubOptionValue literalExpression literalExample literalDocBook
showOption showOptionWithDefLocs showFiles
-
unknownModule mkOption mkPackageOption
+
unknownModule mkOption mkPackageOption mkPackageOptionMD
mdDoc literalMD;
inherit (self.types) isType setType defaultTypeMerge defaultFunctor
isOptionType mkOptionType;
+6 -1
lib/options.nix
···
let default' = if !isList default then [ default ] else default;
in mkOption {
type = lib.types.package;
-
description = lib.mdDoc "The ${name} package to use.";
+
description = "The ${name} package to use.";
default = attrByPath default'
(throw "${concatStringsSep "." default'} cannot be found in pkgs") pkgs;
defaultText = literalExpression ("pkgs." + concatStringsSep "." default');
${if example != null then "example" else null} = literalExpression
(if isList example then "pkgs." + concatStringsSep "." example else example);
};
+
+
/* Like mkPackageOption, but emit an mdDoc description instead of DocBook. */
+
mkPackageOptionMD = args: name: extra:
+
let option = mkPackageOption args name extra;
+
in option // { description = lib.mdDoc option.description; };
/* This option accepts anything, but it does not produce any result.
+3 -1
nixos/doc/manual/development/option-declarations.section.md
···
}
```
-
### `mkPackageOption` {#sec-option-declarations-util-mkPackageOption}
+
### `mkPackageOption`, `mkPackageOptionMD` {#sec-option-declarations-util-mkPackageOption}
Usage:
···
The second argument is the name of the option, used in the description "The \<name\> package to use.". You can also pass an example value, either a literal string or a package's attribute path.
You can omit the default path if the name of the option is also attribute path in nixpkgs.
+
+
During the transition to CommonMark documentation `mkPackageOption` creates an option with a DocBook description attribute, once the transition is completed it will create a CommonMark description instead. `mkPackageOptionMD` always creates an option with a CommonMark description attribute and will be removed some time after the transition is completed.
::: {#ex-options-declarations-util-mkPackageOption .title}
Examples:
+11 -1
nixos/doc/manual/from_md/development/option-declarations.section.xml
···
}
</programlisting>
<section xml:id="sec-option-declarations-util-mkPackageOption">
-
<title><literal>mkPackageOption</literal></title>
+
<title><literal>mkPackageOption</literal>,
+
<literal>mkPackageOptionMD</literal></title>
<para>
Usage:
</para>
···
<para>
You can omit the default path if the name of the option is
also attribute path in nixpkgs.
+
</para>
+
<para>
+
During the transition to CommonMark documentation
+
<literal>mkPackageOption</literal> creates an option with a
+
DocBook description attribute, once the transition is
+
completed it will create a CommonMark description instead.
+
<literal>mkPackageOptionMD</literal> always creates an option
+
with a CommonMark description attribute and will be removed
+
some time after the transition is completed.
</para>
<anchor xml:id="ex-options-declarations-util-mkPackageOption" />
<para>
+1
nixos/lib/make-options-doc/mergeJSON.py
···
" };\n" +
"\n" +
" example.enable = mkEnableOption (lib.mdDoc ''your thing'');\n" +
+
" example.package = mkPackageOptionMD pkgs \"your-package\" {};\n" +
" imports = [ (mkAliasOptionModuleMD [ \"example\" \"args\" ] [ \"example\" \"settings\" ]) ];",
file = sys.stderr)
+1 -1
nixos/modules/misc/documentation.nix
···
(name: value:
let
wholeName = "${namePrefix}.${name}";
-
guard = lib.warn "Attempt to evaluate package ${wholeName} in option documentation; this is not supported and will eventually be an error. Use `mkPackageOption` or `literalExpression` instead.";
+
guard = lib.warn "Attempt to evaluate package ${wholeName} in option documentation; this is not supported and will eventually be an error. Use `mkPackageOption{,MD}` or `literalExpression` instead.";
in if isAttrs value then
scrubDerivations wholeName value
// optionalAttrs (isDerivation value) {
+1 -1
nixos/modules/programs/_1password-gui.nix
···
'';
};
-
package = mkPackageOption pkgs "1Password GUI" {
+
package = mkPackageOptionMD pkgs "1Password GUI" {
default = [ "_1password-gui" ];
};
};
+1 -1
nixos/modules/programs/_1password.nix
···
programs._1password = {
enable = mkEnableOption (lib.mdDoc "the 1Password CLI tool");
-
package = mkPackageOption pkgs "1Password CLI" {
+
package = mkPackageOptionMD pkgs "1Password CLI" {
default = [ "_1password" ];
};
};
+1 -1
nixos/modules/programs/flashrom.nix
···
group.
'';
};
-
package = mkPackageOption pkgs "flashrom" { };
+
package = mkPackageOptionMD pkgs "flashrom" { };
};
config = mkIf cfg.enable {
+2 -2
nixos/modules/programs/skim.nix
···
{ pkgs, config, lib, ... }:
let
-
inherit (lib) mdDoc mkEnableOption mkPackageOption optional optionalString;
+
inherit (lib) mdDoc mkEnableOption mkPackageOptionMD optional optionalString;
cfg = config.programs.skim;
in
{
···
programs.skim = {
fuzzyCompletion = mkEnableOption (mdDoc "fuzzy completion with skim");
keybindings = mkEnableOption (mdDoc "skim keybindings");
-
package = mkPackageOption pkgs "skim" {};
+
package = mkPackageOptionMD pkgs "skim" {};
};
};
+1 -1
nixos/modules/programs/streamdeck-ui.nix
···
description = lib.mdDoc "Whether streamdeck-ui should be started automatically.";
};
-
package = mkPackageOption pkgs "streamdeck-ui" {
+
package = mkPackageOptionMD pkgs "streamdeck-ui" {
default = [ "streamdeck-ui" ];
};
+1 -1
nixos/modules/services/databases/dgraph.nix
···
services.dgraph = {
enable = mkEnableOption (lib.mdDoc "Dgraph native GraphQL database with a graph backend");
-
package = lib.mkPackageOption pkgs "dgraph" { };
+
package = lib.mkPackageOptionMD pkgs "dgraph" { };
settings = mkOption {
type = settingsFormat.type;
+1 -1
nixos/modules/services/mail/listmonk.nix
···
'';
};
};
-
package = mkPackageOption pkgs "listmonk" {};
+
package = mkPackageOptionMD pkgs "listmonk" {};
settings = mkOption {
type = types.submodule { freeformType = tomlFormat.type; };
description = lib.mdDoc ''
+1 -1
nixos/modules/services/misc/input-remapper.nix
···
options = {
services.input-remapper = {
enable = mkEnableOption (lib.mdDoc "input-remapper, an easy to use tool to change the mapping of your input device buttons.");
-
package = options.mkPackageOption pkgs "input-remapper" { };
+
package = mkPackageOptionMD pkgs "input-remapper" { };
enableUdevRules = mkEnableOption (lib.mdDoc "udev rules added by input-remapper to handle hotplugged devices. Currently disabled by default due to https://github.com/sezanzeb/input-remapper/issues/140");
serviceWantedBy = mkOption {
default = [ "graphical.target" ];
+1 -1
nixos/modules/services/misc/polaris.nix
···
services.polaris = {
enable = mkEnableOption (lib.mdDoc "Polaris Music Server");
-
package = mkPackageOption pkgs "polaris" { };
+
package = mkPackageOptionMD pkgs "polaris" { };
user = mkOption {
type = types.str;
+1 -1
nixos/modules/services/networking/openconnect.nix
···
};
in {
options.networking.openconnect = {
-
package = mkPackageOption pkgs "openconnect" { };
+
package = mkPackageOptionMD pkgs "openconnect" { };
interfaces = mkOption {
description = lib.mdDoc "OpenConnect interfaces.";
+1 -1
nixos/modules/services/networking/shellhub-agent.nix
···
enable = mkEnableOption (lib.mdDoc "ShellHub Agent daemon");
-
package = mkPackageOption pkgs "shellhub-agent" { };
+
package = mkPackageOptionMD pkgs "shellhub-agent" { };
preferredHostname = mkOption {
type = types.str;
+1 -1
nixos/modules/services/networking/vdirsyncer.nix
···
services.vdirsyncer = {
enable = mkEnableOption (mdDoc "vdirsyncer");
-
package = mkPackageOption pkgs "vdirsyncer" {};
+
package = mkPackageOptionMD pkgs "vdirsyncer" {};
jobs = mkOption {
description = mdDoc "vdirsyncer job configurations";
+1 -1
nixos/modules/services/networking/webhook.nix
···
which execute configured commands for any person or service that knows the URL
'');
-
package = mkPackageOption pkgs "webhook" {};
+
package = mkPackageOptionMD pkgs "webhook" {};
user = mkOption {
type = types.str;
default = defaultUser;
+1 -1
nixos/modules/services/torrent/transmission.nix
···
};
};
-
package = mkPackageOption pkgs "transmission" {};
+
package = mkPackageOptionMD pkgs "transmission" {};
downloadDirPermissions = mkOption {
type = with types; nullOr str;
+2 -2
nixos/modules/services/x11/window-managers/katriawm.nix
···
{ config, lib, pkgs, ... }:
let
-
inherit (lib) mdDoc mkEnableOption mkIf mkPackageOption singleton;
+
inherit (lib) mdDoc mkEnableOption mkIf mkPackageOptionMD singleton;
cfg = config.services.xserver.windowManager.katriawm;
in
{
···
options = {
services.xserver.windowManager.katriawm = {
enable = mkEnableOption (mdDoc "katriawm");
-
package = mkPackageOption pkgs "katriawm" {};
+
package = mkPackageOptionMD pkgs "katriawm" {};
};
};
+1 -1
nixos/modules/services/x11/window-managers/qtile.nix
···
options.services.xserver.windowManager.qtile = {
enable = mkEnableOption (lib.mdDoc "qtile");
-
package = mkPackageOption pkgs "qtile" { };
+
package = mkPackageOptionMD pkgs "qtile" { };
};
config = mkIf cfg.enable {
+1 -1
nixos/modules/system/boot/systemd/initrd.nix
···
'';
};
-
package = (mkPackageOption pkgs "systemd" {
+
package = (mkPackageOptionMD pkgs "systemd" {
default = "systemdStage1";
}) // {
visible = false;