mirror of
https://github.com/nix-community/nixvim.git
synced 2025-08-08 03:45:22 +02:00
32 lines
797 B
Nix
32 lines
797 B
Nix
|
{ 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}")
|
||
|
];
|
||
|
};
|
||
|
};
|
||
|
}
|