Skip to content

Commit

Permalink
lib: use lib.fix and self internally
Browse files Browse the repository at this point in the history
  • Loading branch information
MattSturgeon committed Sep 13, 2024
1 parent 7a14723 commit f47e8f8
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 23 deletions.
43 changes: 22 additions & 21 deletions lib/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,18 @@
_nixvimTests ? false,
...
}:
let
# Used when importing parts of helpers
call = lib.callPackageWith {
# TODO: deprecate/remove using `helpers` in the subsections
inherit call pkgs helpers;
lib = helpers.extendedLib;
};

# Build helpers recursively
helpers = {
# Build helpers recursively
lib.fix (
self:
let
# Used when importing parts of helpers
call = lib.callPackageWith {
inherit call pkgs self;
helpers = self; # TODO: stop using `helpers` in the subsections
lib = self.extendedLib;
};
in
{
autocmd = call ./autocmd-helpers.nix { };
builders = call ./builders.nix { };
deprecation = call ./deprecation.nix { };
Expand All @@ -29,22 +31,22 @@ let
# Top-level helper aliases:
# TODO: deprecate some aliases

inherit (helpers.builders)
inherit (self.builders)
writeLua
writeByteCompiledLua
byteCompileLuaFile
byteCompileLuaHook
byteCompileLuaDrv
;

inherit (helpers.deprecation)
inherit (self.deprecation)
getOptionRecursive
mkDeprecatedSubOptionModule
mkSettingsRenamedOptionModules
transitionType
;

inherit (helpers.options)
inherit (self.options)
defaultNullOpts
mkCompositeOption
mkCompositeOption'
Expand All @@ -66,7 +68,7 @@ let
pluginDefaultText
;

inherit (helpers.utils)
inherit (self.utils)
concatNonEmptyLines
emptyTable
enableExceptInTests
Expand All @@ -89,13 +91,12 @@ let
;

# TODO: Deprecate this `maintainers` alias
inherit (helpers.extendedLib) maintainers;
inherit (self.extendedLib) maintainers;

# TODO: Deprecate the old `nixvimTypes` alias?
nixvimTypes = helpers.extendedLib.types;
nixvimTypes = self.extendedLib.types;

toLuaObject = helpers.lua.toLua;
mkLuaInline = helpers.lua.mkInline;
};
in
helpers
toLuaObject = self.lua.toLua;
mkLuaInline = self.lua.mkInline;
}
)
4 changes: 2 additions & 2 deletions lib/extend-lib.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
{
call,
lib,
helpers,
self,
}:
lib.extend (
final: prev: {
# Include our custom lib
nixvim = helpers;
nixvim = self;

# Merge in our maintainers
maintainers = prev.maintainers // import ./maintainers.nix;
Expand Down

0 comments on commit f47e8f8

Please sign in to comment.