mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-21 08:35:43 +02:00
docs/user-guide: document nixvim's lib overlay
This commit is contained in:
parent
b28ebf2535
commit
c19daee453
2 changed files with 32 additions and 2 deletions
|
@ -39,6 +39,36 @@ This "extended" lib, includes everything normally in `lib`, along with some addi
|
||||||
|
|
||||||
**Note:** the `lib` argument passed to modules is entirely unrelated to the `lib` _option_ accessed as `config.lib`!
|
**Note:** the `lib` argument passed to modules is entirely unrelated to the `lib` _option_ accessed as `config.lib`!
|
||||||
|
|
||||||
|
## Using a custom `lib` with Nixvim
|
||||||
|
|
||||||
|
When Nixvim is built in standalone mode, it expects `lib` to have Nixvim's extensions.
|
||||||
|
If you'd like to use a `lib` with your own extensions, you must supply it via `specialArgs`,
|
||||||
|
however you must ensure Nixvim's extensions are also present.
|
||||||
|
|
||||||
|
This can be achieved using the lib overlay, available via the `<nixvim>.lib.overlay` flake output.
|
||||||
|
|
||||||
|
```nix
|
||||||
|
# Example flake
|
||||||
|
{
|
||||||
|
inputs = {
|
||||||
|
# ...
|
||||||
|
};
|
||||||
|
|
||||||
|
outputs =
|
||||||
|
{ nixpkgs, ... }@inputs:
|
||||||
|
let
|
||||||
|
lib = import (nixpkgs + "/lib");
|
||||||
|
myCustomLib = lib.extend (final: prev: {
|
||||||
|
# ...
|
||||||
|
});
|
||||||
|
myCustomLibForNixvim = myCustomLib.extend inputs.nixvim.lib.overlay;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
# ...
|
||||||
|
};
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
## Common helper functions
|
## Common helper functions
|
||||||
|
|
||||||
A certain number of helpers are defined that can be useful:
|
A certain number of helpers are defined that can be useful:
|
||||||
|
|
|
@ -23,10 +23,10 @@ in
|
||||||
extraSpecialArgs ? { },
|
extraSpecialArgs ? { },
|
||||||
}:
|
}:
|
||||||
# Ensure a suitable `lib` is used
|
# Ensure a suitable `lib` is used
|
||||||
# TODO: offer a lib overlay that end-users could use to apply nixvim's extensions to their own `lib`
|
|
||||||
assert lib.assertMsg (extraSpecialArgs ? lib -> extraSpecialArgs.lib ? nixvim) ''
|
assert lib.assertMsg (extraSpecialArgs ? lib -> extraSpecialArgs.lib ? nixvim) ''
|
||||||
Nixvim requires a lib that includes some custom extensions, however the `lib` from `specialArgs` does not have a `nixvim` attr.
|
Nixvim requires a lib that includes some custom extensions, however the `lib` from `specialArgs` does not have a `nixvim` attr.
|
||||||
Remove `lib` from nixvim's `specialArgs` or ensure you apply nixvim's extensions to your `lib`.'';
|
Remove `lib` from nixvim's `specialArgs` or ensure you apply nixvim's extensions to your `lib`.
|
||||||
|
See https://nix-community.github.io/nixvim/user-guide/helpers.html#using-a-custom-lib-with-nixvim'';
|
||||||
lib.evalModules {
|
lib.evalModules {
|
||||||
modules = modules ++ [
|
modules = modules ++ [
|
||||||
../modules/top-level
|
../modules/top-level
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue