forked from mirrors/nixpkgs
modules: add mkAliasOptionModuleMD
mkAliasOptionModule should not default to mdDoc descriptions because that can break out-of-tree users of documentation infrastructure. add an explicitly-MD variant for now, to be removed some time after the MD transition is complete.
This commit is contained in:
parent
b2054d3f2d
commit
4c1cfbdb84
|
@ -131,7 +131,8 @@ let
|
|||
mkAliasAndWrapDefinitions fixMergeModules mkRemovedOptionModule
|
||||
mkRenamedOptionModule mkRenamedOptionModuleWith
|
||||
mkMergedOptionModule mkChangedOptionModule
|
||||
mkAliasOptionModule mkDerivedConfig doRename;
|
||||
mkAliasOptionModule mkDerivedConfig doRename
|
||||
mkAliasOptionModuleMD;
|
||||
inherit (self.options) isOption mkEnableOption mkSinkUndeclaredOptions
|
||||
mergeDefaultOption mergeOneOption mergeEqualOption mergeUniqueOption
|
||||
getValues getFiles
|
||||
|
|
|
@ -1108,6 +1108,15 @@ rec {
|
|||
visible = true;
|
||||
warn = false;
|
||||
use = id;
|
||||
wrapDescription = lib.id;
|
||||
};
|
||||
|
||||
/* Transitional version of mkAliasOptionModule that uses MD docs. */
|
||||
mkAliasOptionModuleMD = from: to: doRename {
|
||||
inherit from to;
|
||||
visible = true;
|
||||
warn = false;
|
||||
use = id;
|
||||
};
|
||||
|
||||
/* mkDerivedConfig : Option a -> (a -> Definition b) -> Definition b
|
||||
|
@ -1130,7 +1139,7 @@ rec {
|
|||
(opt.highestPrio or defaultOverridePriority)
|
||||
(f opt.value);
|
||||
|
||||
doRename = { from, to, visible, warn, use, withPriority ? true }:
|
||||
doRename = { from, to, visible, warn, use, withPriority ? true, wrapDescription ? lib.mdDoc }:
|
||||
{ config, options, ... }:
|
||||
let
|
||||
fromOpt = getAttrFromPath from options;
|
||||
|
@ -1141,7 +1150,7 @@ rec {
|
|||
{
|
||||
options = setAttrByPath from (mkOption {
|
||||
inherit visible;
|
||||
description = lib.mdDoc "Alias of {option}`${showOption to}`.";
|
||||
description = wrapDescription "Alias of {option}`${showOption to}`.";
|
||||
apply = x: use (toOf config);
|
||||
} // optionalAttrs (toType != null) {
|
||||
type = toType;
|
||||
|
|
|
@ -306,14 +306,16 @@ if hasDocBookErrors:
|
|||
print("Explanation: The documentation contains descriptions, examples, or defaults written in DocBook. " +
|
||||
"NixOS is in the process of migrating from DocBook to Markdown, and " +
|
||||
"DocBook is disallowed for in-tree modules. To change your contribution to "+
|
||||
"use Markdown, apply mdDoc and literalMD. For example:\n" +
|
||||
"use Markdown, apply mdDoc and literalMD and use the *MD variants of option creation " +
|
||||
"functions where they are available. For example:\n" +
|
||||
"\n" +
|
||||
" example.foo = mkOption {\n" +
|
||||
" description = lib.mdDoc ''your description'';\n" +
|
||||
" defaultText = lib.literalMD ''your description of default'';\n" +
|
||||
" }\n" +
|
||||
" };\n" +
|
||||
"\n" +
|
||||
" example.enable = mkEnableOption (lib.mdDoc ''your thing'');",
|
||||
" example.enable = mkEnableOption (lib.mdDoc ''your thing'');\n" +
|
||||
" imports = [ (mkAliasOptionModuleMD [ \"example\" \"args\" ] [ \"example\" \"settings\" ]) ];",
|
||||
file = sys.stderr)
|
||||
|
||||
if hasErrors:
|
||||
|
|
|
@ -444,8 +444,8 @@ let
|
|||
|
||||
in {
|
||||
imports = [
|
||||
(mkAliasOptionModule [ "users" "extraUsers" ] [ "users" "users" ])
|
||||
(mkAliasOptionModule [ "users" "extraGroups" ] [ "users" "groups" ])
|
||||
(mkAliasOptionModuleMD [ "users" "extraUsers" ] [ "users" "users" ])
|
||||
(mkAliasOptionModuleMD [ "users" "extraGroups" ] [ "users" "groups" ])
|
||||
(mkRenamedOptionModule ["security" "initialRootPassword"] ["users" "users" "root" "initialHashedPassword"])
|
||||
];
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ with lib;
|
|||
|
||||
# This alias module can't be where _module.check is defined because it would
|
||||
# be added to submodules as well there
|
||||
(mkAliasOptionModule [ "environment" "checkConfigurationOptions" ] [ "_module" "check" ])
|
||||
(mkAliasOptionModuleMD [ "environment" "checkConfigurationOptions" ] [ "_module" "check" ])
|
||||
|
||||
# Completely removed modules
|
||||
(mkRemovedOptionModule [ "environment" "blcr" "enable" ] "The BLCR module has been removed")
|
||||
|
|
|
@ -79,8 +79,8 @@ in
|
|||
|
||||
{
|
||||
imports = [
|
||||
(mkAliasOptionModule [ "services" "sshd" "enable" ] [ "services" "openssh" "enable" ])
|
||||
(mkAliasOptionModule [ "services" "openssh" "knownHosts" ] [ "programs" "ssh" "knownHosts" ])
|
||||
(mkAliasOptionModuleMD [ "services" "sshd" "enable" ] [ "services" "openssh" "enable" ])
|
||||
(mkAliasOptionModuleMD [ "services" "openssh" "knownHosts" ] [ "programs" "ssh" "knownHosts" ])
|
||||
(mkRenamedOptionModule [ "services" "openssh" "challengeResponseAuthentication" ] [ "services" "openssh" "kbdInteractiveAuthentication" ])
|
||||
];
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ in
|
|||
imports = [
|
||||
(mkRenamedOptionModule ["services" "transmission" "port"]
|
||||
["services" "transmission" "settings" "rpc-port"])
|
||||
(mkAliasOptionModule ["services" "transmission" "openFirewall"]
|
||||
(mkAliasOptionModuleMD ["services" "transmission" "openFirewall"]
|
||||
["services" "transmission" "openPeerPorts"])
|
||||
];
|
||||
options = {
|
||||
|
|
|
@ -41,7 +41,7 @@ let
|
|||
in {
|
||||
|
||||
imports = [
|
||||
(mkAliasOptionModule [ "services" "compton" ] [ "services" "picom" ])
|
||||
(mkAliasOptionModuleMD [ "services" "compton" ] [ "services" "picom" ])
|
||||
(mkRemovedOptionModule [ "services" "picom" "refreshRate" ] ''
|
||||
This option corresponds to `refresh-rate`, which has been unused
|
||||
since picom v6 and was subsequently removed by upstream.
|
||||
|
|
Loading…
Reference in a new issue