nix-community.nixvim/lib/option-warnings.nix

32 lines
797 B
Nix
Raw Normal View History

2023-01-20 00:15:58 +01:00
{ lib, ... }:
with lib;
rec {
mkDeprecatedOption =
{ option # an array of the path to the option
, alternative ? null
, message ? null
, visible ? false
, ...
}:
{ options, ... }:
let
fromOpt = getAttrFromPath option options;
fullMessage = "The option `${showOption option}` has been deprecated." +
(optionalString (alternative != null) " You may want to use `${showOption alternative}` instead.") +
(optionalString (message != null) " Message: ${message}");
in
{
options = setAttrByPath option
(mkOption {
inherit visible;
description = fullMessage;
});
config = mkIf (fromOpt.isDefined) {
warnings = [
("Nixvim: ${fullMessage}")
];
};
};
}