3
0
Fork 0
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:
pennae 2022-12-30 20:43:53 +01:00 committed by pennae
parent b2054d3f2d
commit 4c1cfbdb84
8 changed files with 26 additions and 14 deletions

View file

@ -131,7 +131,8 @@ let
mkAliasAndWrapDefinitions fixMergeModules mkRemovedOptionModule mkAliasAndWrapDefinitions fixMergeModules mkRemovedOptionModule
mkRenamedOptionModule mkRenamedOptionModuleWith mkRenamedOptionModule mkRenamedOptionModuleWith
mkMergedOptionModule mkChangedOptionModule mkMergedOptionModule mkChangedOptionModule
mkAliasOptionModule mkDerivedConfig doRename; mkAliasOptionModule mkDerivedConfig doRename
mkAliasOptionModuleMD;
inherit (self.options) isOption mkEnableOption mkSinkUndeclaredOptions inherit (self.options) isOption mkEnableOption mkSinkUndeclaredOptions
mergeDefaultOption mergeOneOption mergeEqualOption mergeUniqueOption mergeDefaultOption mergeOneOption mergeEqualOption mergeUniqueOption
getValues getFiles getValues getFiles

View file

@ -1108,6 +1108,15 @@ rec {
visible = true; visible = true;
warn = false; warn = false;
use = id; 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 /* mkDerivedConfig : Option a -> (a -> Definition b) -> Definition b
@ -1130,7 +1139,7 @@ rec {
(opt.highestPrio or defaultOverridePriority) (opt.highestPrio or defaultOverridePriority)
(f opt.value); (f opt.value);
doRename = { from, to, visible, warn, use, withPriority ? true }: doRename = { from, to, visible, warn, use, withPriority ? true, wrapDescription ? lib.mdDoc }:
{ config, options, ... }: { config, options, ... }:
let let
fromOpt = getAttrFromPath from options; fromOpt = getAttrFromPath from options;
@ -1141,7 +1150,7 @@ rec {
{ {
options = setAttrByPath from (mkOption { options = setAttrByPath from (mkOption {
inherit visible; inherit visible;
description = lib.mdDoc "Alias of {option}`${showOption to}`."; description = wrapDescription "Alias of {option}`${showOption to}`.";
apply = x: use (toOf config); apply = x: use (toOf config);
} // optionalAttrs (toType != null) { } // optionalAttrs (toType != null) {
type = toType; type = toType;

View file

@ -306,14 +306,16 @@ if hasDocBookErrors:
print("Explanation: The documentation contains descriptions, examples, or defaults written in DocBook. " + print("Explanation: The documentation contains descriptions, examples, or defaults written in DocBook. " +
"NixOS is in the process of migrating from DocBook to Markdown, and " + "NixOS is in the process of migrating from DocBook to Markdown, and " +
"DocBook is disallowed for in-tree modules. To change your contribution to "+ "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" + "\n" +
" example.foo = mkOption {\n" + " example.foo = mkOption {\n" +
" description = lib.mdDoc ''your description'';\n" + " description = lib.mdDoc ''your description'';\n" +
" defaultText = lib.literalMD ''your description of default'';\n" + " defaultText = lib.literalMD ''your description of default'';\n" +
" }\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) file = sys.stderr)
if hasErrors: if hasErrors:

View file

@ -444,8 +444,8 @@ let
in { in {
imports = [ imports = [
(mkAliasOptionModule [ "users" "extraUsers" ] [ "users" "users" ]) (mkAliasOptionModuleMD [ "users" "extraUsers" ] [ "users" "users" ])
(mkAliasOptionModule [ "users" "extraGroups" ] [ "users" "groups" ]) (mkAliasOptionModuleMD [ "users" "extraGroups" ] [ "users" "groups" ])
(mkRenamedOptionModule ["security" "initialRootPassword"] ["users" "users" "root" "initialHashedPassword"]) (mkRenamedOptionModule ["security" "initialRootPassword"] ["users" "users" "root" "initialHashedPassword"])
]; ];

View file

@ -14,7 +14,7 @@ with lib;
# This alias module can't be where _module.check is defined because it would # This alias module can't be where _module.check is defined because it would
# be added to submodules as well there # be added to submodules as well there
(mkAliasOptionModule [ "environment" "checkConfigurationOptions" ] [ "_module" "check" ]) (mkAliasOptionModuleMD [ "environment" "checkConfigurationOptions" ] [ "_module" "check" ])
# Completely removed modules # Completely removed modules
(mkRemovedOptionModule [ "environment" "blcr" "enable" ] "The BLCR module has been removed") (mkRemovedOptionModule [ "environment" "blcr" "enable" ] "The BLCR module has been removed")

View file

@ -79,8 +79,8 @@ in
{ {
imports = [ imports = [
(mkAliasOptionModule [ "services" "sshd" "enable" ] [ "services" "openssh" "enable" ]) (mkAliasOptionModuleMD [ "services" "sshd" "enable" ] [ "services" "openssh" "enable" ])
(mkAliasOptionModule [ "services" "openssh" "knownHosts" ] [ "programs" "ssh" "knownHosts" ]) (mkAliasOptionModuleMD [ "services" "openssh" "knownHosts" ] [ "programs" "ssh" "knownHosts" ])
(mkRenamedOptionModule [ "services" "openssh" "challengeResponseAuthentication" ] [ "services" "openssh" "kbdInteractiveAuthentication" ]) (mkRenamedOptionModule [ "services" "openssh" "challengeResponseAuthentication" ] [ "services" "openssh" "kbdInteractiveAuthentication" ])
]; ];

View file

@ -19,8 +19,8 @@ in
imports = [ imports = [
(mkRenamedOptionModule ["services" "transmission" "port"] (mkRenamedOptionModule ["services" "transmission" "port"]
["services" "transmission" "settings" "rpc-port"]) ["services" "transmission" "settings" "rpc-port"])
(mkAliasOptionModule ["services" "transmission" "openFirewall"] (mkAliasOptionModuleMD ["services" "transmission" "openFirewall"]
["services" "transmission" "openPeerPorts"]) ["services" "transmission" "openPeerPorts"])
]; ];
options = { options = {
services.transmission = { services.transmission = {

View file

@ -41,7 +41,7 @@ let
in { in {
imports = [ imports = [
(mkAliasOptionModule [ "services" "compton" ] [ "services" "picom" ]) (mkAliasOptionModuleMD [ "services" "compton" ] [ "services" "picom" ])
(mkRemovedOptionModule [ "services" "picom" "refreshRate" ] '' (mkRemovedOptionModule [ "services" "picom" "refreshRate" ] ''
This option corresponds to `refresh-rate`, which has been unused This option corresponds to `refresh-rate`, which has been unused
since picom v6 and was subsequently removed by upstream. since picom v6 and was subsequently removed by upstream.