mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-20 16:15:43 +02:00
lib: rename helpers.nix
-> default.nix
The old `default.nix` is inlined into the "lib" flake-module, which is
the only place it was used.
This allows "helpers" to take its rightful place at the root of `./lib` 👑
This commit is contained in:
parent
0b665b200b
commit
7a147234f8
9 changed files with 116 additions and 122 deletions
|
@ -7,7 +7,7 @@ let
|
|||
# We overlay a few tweaks into pkgs, for use in the docs
|
||||
pkgs = import ./pkgs.nix { inherit system nixpkgs; };
|
||||
inherit (pkgs) lib;
|
||||
helpers = import ../lib/helpers.nix { inherit lib pkgs; };
|
||||
helpers = import ../lib { inherit lib pkgs; };
|
||||
|
||||
nixvimPath = toString ./..;
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
{
|
||||
imports = [
|
||||
./dev
|
||||
./helpers.nix
|
||||
./lib.nix
|
||||
./legacy-packages.nix
|
||||
./overlays.nix
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
{
|
||||
perSystem =
|
||||
{ pkgs, ... }:
|
||||
{
|
||||
_module.args.helpers = import ../lib/helpers.nix { inherit pkgs; };
|
||||
};
|
||||
}
|
|
@ -5,7 +5,21 @@
|
|||
...
|
||||
}:
|
||||
{
|
||||
perSystem =
|
||||
{ pkgs, ... }:
|
||||
{
|
||||
_module.args.helpers = import ../lib { inherit lib pkgs; };
|
||||
};
|
||||
|
||||
# TODO: output lib without pkgs at the top-level
|
||||
flake.lib = lib.genAttrs config.systems (
|
||||
lib.flip withSystem ({ pkgs, ... }: import ../lib { inherit pkgs lib; })
|
||||
lib.flip withSystem (
|
||||
{ pkgs, ... }:
|
||||
{
|
||||
# NOTE: this is the publicly documented flake output we've had for a while
|
||||
check = import ../lib/tests.nix { inherit lib pkgs; };
|
||||
helpers = import ../lib { inherit lib pkgs; };
|
||||
}
|
||||
)
|
||||
);
|
||||
}
|
||||
|
|
103
lib/default.nix
103
lib/default.nix
|
@ -1,12 +1,101 @@
|
|||
# Args probably only needs pkgs and lib
|
||||
{
|
||||
pkgs,
|
||||
lib ? pkgs.lib,
|
||||
_nixvimTests ? false,
|
||||
...
|
||||
}@args:
|
||||
{
|
||||
# Add all exported modules here
|
||||
check = import ./tests.nix { inherit lib pkgs; };
|
||||
helpers = import ./helpers.nix (args // { inherit _nixvimTests; });
|
||||
}
|
||||
}:
|
||||
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 = {
|
||||
autocmd = call ./autocmd-helpers.nix { };
|
||||
builders = call ./builders.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 { };
|
||||
|
||||
# Top-level helper aliases:
|
||||
# TODO: deprecate some aliases
|
||||
|
||||
inherit (helpers.builders)
|
||||
writeLua
|
||||
writeByteCompiledLua
|
||||
byteCompileLuaFile
|
||||
byteCompileLuaHook
|
||||
byteCompileLuaDrv
|
||||
;
|
||||
|
||||
inherit (helpers.deprecation)
|
||||
getOptionRecursive
|
||||
mkDeprecatedSubOptionModule
|
||||
mkSettingsRenamedOptionModules
|
||||
transitionType
|
||||
;
|
||||
|
||||
inherit (helpers.options)
|
||||
defaultNullOpts
|
||||
mkCompositeOption
|
||||
mkCompositeOption'
|
||||
mkNullOrLua
|
||||
mkNullOrLua'
|
||||
mkNullOrLuaFn
|
||||
mkNullOrLuaFn'
|
||||
mkNullOrOption
|
||||
mkNullOrOption'
|
||||
mkNullOrStr
|
||||
mkNullOrStr'
|
||||
mkNullOrStrLuaFnOr
|
||||
mkNullOrStrLuaFnOr'
|
||||
mkNullOrStrLuaOr
|
||||
mkNullOrStrLuaOr'
|
||||
mkPackageOption
|
||||
mkPluginPackageOption
|
||||
mkSettingsOption
|
||||
pluginDefaultText
|
||||
;
|
||||
|
||||
inherit (helpers.utils)
|
||||
concatNonEmptyLines
|
||||
emptyTable
|
||||
enableExceptInTests
|
||||
groupListBySize
|
||||
hasContent
|
||||
ifNonNull'
|
||||
listToUnkeyedAttrs
|
||||
mkIfNonNull
|
||||
mkIfNonNull'
|
||||
mkRaw
|
||||
mkRawKey
|
||||
override
|
||||
overrideDerivation
|
||||
toRawKeys
|
||||
toSnakeCase
|
||||
upperFirstChar
|
||||
wrapDo
|
||||
wrapLuaForVimscript
|
||||
wrapVimscriptForLua
|
||||
;
|
||||
|
||||
# TODO: Deprecate this `maintainers` alias
|
||||
inherit (helpers.extendedLib) maintainers;
|
||||
|
||||
# TODO: Deprecate the old `nixvimTypes` alias?
|
||||
nixvimTypes = helpers.extendedLib.types;
|
||||
|
||||
toLuaObject = helpers.lua.toLua;
|
||||
mkLuaInline = helpers.lua.mkInline;
|
||||
};
|
||||
in
|
||||
helpers
|
||||
|
|
101
lib/helpers.nix
101
lib/helpers.nix
|
@ -1,101 +0,0 @@
|
|||
{
|
||||
pkgs,
|
||||
lib ? pkgs.lib,
|
||||
_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 = {
|
||||
autocmd = call ./autocmd-helpers.nix { };
|
||||
builders = call ./builders.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 { };
|
||||
|
||||
# Top-level helper aliases:
|
||||
# TODO: deprecate some aliases
|
||||
|
||||
inherit (helpers.builders)
|
||||
writeLua
|
||||
writeByteCompiledLua
|
||||
byteCompileLuaFile
|
||||
byteCompileLuaHook
|
||||
byteCompileLuaDrv
|
||||
;
|
||||
|
||||
inherit (helpers.deprecation)
|
||||
getOptionRecursive
|
||||
mkDeprecatedSubOptionModule
|
||||
mkSettingsRenamedOptionModules
|
||||
transitionType
|
||||
;
|
||||
|
||||
inherit (helpers.options)
|
||||
defaultNullOpts
|
||||
mkCompositeOption
|
||||
mkCompositeOption'
|
||||
mkNullOrLua
|
||||
mkNullOrLua'
|
||||
mkNullOrLuaFn
|
||||
mkNullOrLuaFn'
|
||||
mkNullOrOption
|
||||
mkNullOrOption'
|
||||
mkNullOrStr
|
||||
mkNullOrStr'
|
||||
mkNullOrStrLuaFnOr
|
||||
mkNullOrStrLuaFnOr'
|
||||
mkNullOrStrLuaOr
|
||||
mkNullOrStrLuaOr'
|
||||
mkPackageOption
|
||||
mkPluginPackageOption
|
||||
mkSettingsOption
|
||||
pluginDefaultText
|
||||
;
|
||||
|
||||
inherit (helpers.utils)
|
||||
concatNonEmptyLines
|
||||
emptyTable
|
||||
enableExceptInTests
|
||||
groupListBySize
|
||||
hasContent
|
||||
ifNonNull'
|
||||
listToUnkeyedAttrs
|
||||
mkIfNonNull
|
||||
mkIfNonNull'
|
||||
mkRaw
|
||||
mkRawKey
|
||||
override
|
||||
overrideDerivation
|
||||
toRawKeys
|
||||
toSnakeCase
|
||||
upperFirstChar
|
||||
wrapDo
|
||||
wrapLuaForVimscript
|
||||
wrapVimscriptForLua
|
||||
;
|
||||
|
||||
# TODO: Deprecate this `maintainers` alias
|
||||
inherit (helpers.extendedLib) maintainers;
|
||||
|
||||
# TODO: Deprecate the old `nixvimTypes` alias?
|
||||
nixvimTypes = helpers.extendedLib.types;
|
||||
|
||||
toLuaObject = helpers.lua.toLua;
|
||||
mkLuaInline = helpers.lua.mkInline;
|
||||
};
|
||||
in
|
||||
helpers
|
|
@ -44,7 +44,7 @@ let
|
|||
dontRun ? false,
|
||||
}@args:
|
||||
let
|
||||
helpers = import ../lib/helpers.nix {
|
||||
helpers = import ../lib {
|
||||
inherit pkgs lib;
|
||||
# TODO: deprecate helpers.enableExceptInTests,
|
||||
# add a context option e.g. `config.isTest`?
|
||||
|
@ -72,6 +72,7 @@ let
|
|||
in
|
||||
result.config.test.derivation;
|
||||
in
|
||||
# NOTE: this is exported publicly in the flake outputs as `lib.<system>.check`
|
||||
{
|
||||
inherit mkTestDerivationFromNvim mkTestDerivationFromNixvimModule;
|
||||
}
|
||||
|
|
|
@ -46,8 +46,7 @@ in
|
|||
config = mkMerge [
|
||||
{
|
||||
# Make our lib available to the host modules
|
||||
# TODO: import top-level ../lib
|
||||
lib.nixvim = lib.mkDefault (import ../lib/helpers.nix { inherit pkgs lib; });
|
||||
lib.nixvim = lib.mkDefault (import ../lib { inherit pkgs lib; });
|
||||
|
||||
# Make nixvim's "extended" lib available to the host's module args
|
||||
_module.args.nixvimLib = lib.mkDefault config.lib.nixvim.extendedLib;
|
||||
|
|
|
@ -7,7 +7,7 @@ default_pkgs: self:
|
|||
module,
|
||||
}:
|
||||
let
|
||||
helpers = import ../lib/helpers.nix { inherit pkgs lib _nixvimTests; };
|
||||
helpers = import ../lib { inherit pkgs lib _nixvimTests; };
|
||||
|
||||
inherit (helpers.modules) evalNixvim;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue