mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-21 08:35:43 +02:00
lib: throw when deprecated builders are used on a lib without pkgs
Previously the deprecated builders would warn when used on a lib _with_ `pkgs`, but were simply not present on a lib _without_ `pkgs`. Now, they are always present, but will throw when evaluated on a lib _without_ `pkgs`.
This commit is contained in:
parent
1116ae6332
commit
81ae3febd2
1 changed files with 36 additions and 37 deletions
|
@ -19,32 +19,45 @@ lib.fix (
|
||||||
# since the final value will have been merged from two places
|
# since the final value will have been merged from two places
|
||||||
builders = call ./builders.nix { };
|
builders = call ./builders.nix { };
|
||||||
|
|
||||||
# Merge in deprecated functions that require a nixpkgs instance
|
# We used to provide top-level access to the "builder" functions, with `pkgs` already baked in
|
||||||
# Does shallow recursion, only one level deeper than normal
|
# TODO: deprecated 2024-09-13; after 24.11 this can be simplified to always throw
|
||||||
# Does nothing when `pkgs` is null
|
deprecatedBuilders = lib.mapAttrs (
|
||||||
withOptionalFns =
|
name: value:
|
||||||
if pkgs == null then
|
let
|
||||||
lib.id
|
notice = "`${name}` is deprecated";
|
||||||
else
|
opt = lib.optionalString (pkgs == null) " and not available in this instance of nixvim's lib";
|
||||||
lib.recursiveUpdateUntil
|
advice = "You should either use `${name}With` or access `${name}` via `builders.withPkgs`";
|
||||||
(
|
msg = "${notice}${opt}. ${advice}.";
|
||||||
path: lhs: rhs:
|
in
|
||||||
builtins.length path > 1
|
if pkgs == null then throw msg else lib.warn msg value
|
||||||
)
|
) (builders.withPkgs pkgs);
|
||||||
|
in
|
||||||
{
|
{
|
||||||
# Minimal specialArgs required to evaluate nixvim modules
|
autocmd = call ./autocmd-helpers.nix { };
|
||||||
|
deprecation = call ./deprecation.nix { };
|
||||||
|
extendedLib = call ./extend-lib.nix { inherit lib; };
|
||||||
|
keymaps = call ./keymap-helpers.nix { };
|
||||||
|
lua = call ./to-lua.nix { };
|
||||||
|
neovim-plugin = call ./neovim-plugin.nix { };
|
||||||
|
options = call ./options.nix { };
|
||||||
|
utils = call ./utils.nix { inherit _nixvimTests; };
|
||||||
|
vim-plugin = call ./vim-plugin.nix { };
|
||||||
|
|
||||||
|
# Handle modules, which currently requires a `defaultPkgs` specialArg
|
||||||
# FIXME: our minimal specialArgs should not need `pkgs`
|
# FIXME: our minimal specialArgs should not need `pkgs`
|
||||||
modules.specialArgs = self.modules.specialArgsWith {
|
modules = call ./modules.nix { } // {
|
||||||
defaultPkgs = pkgs;
|
# Minimal specialArgs required to evaluate nixvim modules
|
||||||
|
specialArgs = self.modules.specialArgsWith {
|
||||||
|
defaultPkgs =
|
||||||
|
if pkgs == null then
|
||||||
|
throw "`modules.specialArgs` cannot currently be used when nixvim's lib is built without a `pkgs` instance. This will be resolved in the future."
|
||||||
|
else
|
||||||
|
pkgs;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
# We used to provide top-level access to the "builder" functions, with `pkgs` already baked in
|
# Handle builders, which has some deprecated stuff that depends on `pkgs`
|
||||||
# TODO: deprecated 2024-09-13; remove after 24.11
|
builders = builders // deprecatedBuilders;
|
||||||
builders = lib.mapAttrs (
|
|
||||||
name:
|
|
||||||
lib.warn "`${name}` is deprecated. You should either use `${name}With` or access `${name}` via `builders.withPkgs`."
|
|
||||||
) (builders.withPkgs pkgs);
|
|
||||||
|
|
||||||
inherit (self.builders)
|
inherit (self.builders)
|
||||||
writeLua
|
writeLua
|
||||||
writeByteCompiledLua
|
writeByteCompiledLua
|
||||||
|
@ -52,20 +65,6 @@ lib.fix (
|
||||||
byteCompileLuaHook
|
byteCompileLuaHook
|
||||||
byteCompileLuaDrv
|
byteCompileLuaDrv
|
||||||
;
|
;
|
||||||
};
|
|
||||||
in
|
|
||||||
withOptionalFns {
|
|
||||||
autocmd = call ./autocmd-helpers.nix { };
|
|
||||||
deprecation = call ./deprecation.nix { };
|
|
||||||
extendedLib = call ./extend-lib.nix { inherit lib; };
|
|
||||||
keymaps = call ./keymap-helpers.nix { };
|
|
||||||
lua = call ./to-lua.nix { };
|
|
||||||
modules = call ./modules.nix { };
|
|
||||||
neovim-plugin = call ./neovim-plugin.nix { };
|
|
||||||
options = call ./options.nix { };
|
|
||||||
utils = call ./utils.nix { inherit _nixvimTests; };
|
|
||||||
vim-plugin = call ./vim-plugin.nix { };
|
|
||||||
inherit builders;
|
|
||||||
|
|
||||||
# Top-level helper aliases:
|
# Top-level helper aliases:
|
||||||
# TODO: deprecate some aliases
|
# TODO: deprecate some aliases
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue