lib/modules: Use module-builtin assertions for mkRemovedOptionModule and co.
This commit is contained in:
parent
9523df7eb6
commit
20131348db
@ -924,14 +924,16 @@ rec {
|
|||||||
visible = false;
|
visible = false;
|
||||||
apply = x: throw "The option `${showOption optionName}' can no longer be used since it's been removed. ${replacementInstructions}";
|
apply = x: throw "The option `${showOption optionName}' can no longer be used since it's been removed. ${replacementInstructions}";
|
||||||
});
|
});
|
||||||
config.assertions =
|
config._module.assertions =
|
||||||
let opt = getAttrFromPath optionName options; in [{
|
let opt = getAttrFromPath optionName options; in {
|
||||||
assertion = !opt.isDefined;
|
${showOption optionName} = {
|
||||||
|
enable = mkDefault opt.isDefined;
|
||||||
message = ''
|
message = ''
|
||||||
The option definition `${showOption optionName}' in ${showFiles opt.files} no longer has any effect; please remove it.
|
The option definition `${showOption optionName}' in ${showFiles opt.files} no longer has any effect; please remove it.
|
||||||
${replacementInstructions}
|
${replacementInstructions}
|
||||||
'';
|
'';
|
||||||
}];
|
};
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Return a module that causes a warning to be shown if the
|
/* Return a module that causes a warning to be shown if the
|
||||||
@ -992,14 +994,19 @@ rec {
|
|||||||
})) from);
|
})) from);
|
||||||
|
|
||||||
config = {
|
config = {
|
||||||
warnings = filter (x: x != "") (map (f:
|
_module.assertions =
|
||||||
let val = getAttrFromPath f config;
|
let warningMessages = map (f:
|
||||||
opt = getAttrFromPath f options;
|
let val = getAttrFromPath f config;
|
||||||
in
|
opt = getAttrFromPath f options;
|
||||||
optionalString
|
in {
|
||||||
(val != "_mkMergedOptionModule")
|
${showOption f} = {
|
||||||
"The option `${showOption f}' defined in ${showFiles opt.files} has been changed to `${showOption to}' that has a different type. Please read `${showOption to}' documentation and update your configuration accordingly."
|
enable = mkDefault (val != "_mkMergedOptionModule");
|
||||||
) from);
|
type = "warning";
|
||||||
|
message = "The option `${showOption f}' defined in ${showFiles opt.files} has been changed to `${showOption to}' that has a different type. Please read `${showOption to}' documentation and update your configuration accordingly.";
|
||||||
|
};
|
||||||
|
}
|
||||||
|
) from;
|
||||||
|
in mkMerge warningMessages;
|
||||||
} // setAttrByPath to (mkMerge
|
} // setAttrByPath to (mkMerge
|
||||||
(optional
|
(optional
|
||||||
(any (f: (getAttrFromPath f config) != "_mkMergedOptionModule") from)
|
(any (f: (getAttrFromPath f config) != "_mkMergedOptionModule") from)
|
||||||
@ -1058,8 +1065,11 @@ rec {
|
|||||||
});
|
});
|
||||||
config = mkMerge [
|
config = mkMerge [
|
||||||
{
|
{
|
||||||
warnings = optional (warn && fromOpt.isDefined)
|
_module.assertions.${showOption from} = {
|
||||||
"The option `${showOption from}' defined in ${showFiles fromOpt.files} has been renamed to `${showOption to}'.";
|
enable = mkDefault (warn && fromOpt.isDefined);
|
||||||
|
type = "warning";
|
||||||
|
message = "The option `${showOption from}' defined in ${showFiles fromOpt.files} has been renamed to `${showOption to}'.";
|
||||||
|
};
|
||||||
}
|
}
|
||||||
(if withPriority
|
(if withPriority
|
||||||
then mkAliasAndWrapDefsWithPriority (setAttrByPath to) fromOpt
|
then mkAliasAndWrapDefsWithPriority (setAttrByPath to) fromOpt
|
||||||
|
Loading…
x
Reference in New Issue
Block a user