This minimal implementation allows `nixpkgs.pkgs` to be defined, but
does not implement evaluating an instance from a pkgsPath when _not_
defined.
The `defaultPkgs` specialArg is dropped in favour of `nixpkgs.pkgs`
being defined. If it's not defined, an assertion is thrown.
In the future, a nixpkgs source path can be supplied, defaulting to the
flake's `inputs.nixpkgs`. Along with other `nixpkgs.*` options, this
will allow a `pkgs` instance to be evaluated within the module eval.
By default `lib.evalModules` will check all config definitions match
a declared option (or a freeform type), leading to errors like:
error: The option `wrapRc' does not exist.
Setting `_module.freeformType` or `_module.check` will disable this,
allowing us to evaluate the option declaration without checking the
config definitions.
In the two places where our "helpers" lib is exclusively internal
(flake module args and building the docs), we no longer supply `pkgs`.
In the other 4 locations, we now note why we still do in a comment.
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` 👑
Since starting to use `lib.mkPackageOption` throughout nixvim, users
will see a slightly different error message when encountering mismatched
nixpkgs channel errors.
Also fleshed out some recommendations.
Instead of maintainers providing an actual `defaultPackage`, they should
specify the pkg name which we'll use when calling `lib.mkPackageOption`.
This makes `mkVimPlugin` and `mkNeovimPlugin` compliant with #1950.
Long descriptions for plugins will shove the plugin's source link and
maintainer information far down the page. Since those are fairly short
and the description is a variable size. Moving below to maintain
consistent placement.
Make our "extended" lib available to host modules as `_module.args.nixvimLib`.
We didn't do this before because `helpers` was too generic of a name,
but `nixvimLib` should be ok.
{ nixvimLib, ... }: {
programs.nixvim.someOption = nixvimLib.nixvim.mkRaw "print('Hi')";
}
NixOS, HM, & Darwin provide a `lib` option, not to be confused with the
`lib` module arg.
This option is intended for modules to define custom functions without
having to extend nixpkgs lib.
The old option is renamed, if it is accessed it will print:
trace: Obsolete option `nixvim.helpers' is used. It was renamed to `lib.nixvim'.
Replaced the `isDocs` specialArg added in #1807 with an internal module
option.
We should only use `specialArgs` when absolutely necessary, a module or
`_module.args` is preferred, but those aren't available until `config`
is evaluated so they can't be used for `imports`.
The main problem with `specialArgs` is it makes our modules less
portable.
Luckily that shouldn't be an issue for these context flags.
Let's simplify things by defining all modules in `./plugins`, `./modules`
and `./wrappers/modules`.
Instead of currying `pkgs` into a bootstrapping module, we can require
`defaultPkgs` be provided as a special arg.
This refactor allows us to completely remove `flake-modules/modules.nix`!
Rather than nesting it as `config`, pass `makeNixvim`'s argument through
directly as a module.
This not only simplifies the implementation, but allows users to use
`makeNixvim` for any scenario where `makeNixvimWithModule` would normally
be required.