2025-01-17 00:04:06 +00:00
|
|
|
## Accessing Nixvim's functions
|
|
|
|
|
2024-08-20 23:38:01 +01:00
|
|
|
If Nixvim is built using the standalone method, you can access our "helpers" as part of the `lib` module arg:
|
2024-02-14 23:38:26 +01:00
|
|
|
|
2024-07-08 08:37:46 +01:00
|
|
|
```nix
|
2024-08-20 23:38:01 +01:00
|
|
|
{ lib, ... }:
|
2024-07-08 08:37:46 +01:00
|
|
|
{
|
2024-08-20 23:38:01 +01:00
|
|
|
# You can use lib.nixvim in your config
|
|
|
|
fooOption = lib.nixvim.mkRaw "print('hello')";
|
2024-07-08 08:37:46 +01:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
If Nixvim is being used as as a home-manager module, a nixos module, or as a dawwin module,
|
2024-08-20 23:38:01 +01:00
|
|
|
our "helpers" can be accessed via the `config.lib` option:
|
2024-02-14 23:38:26 +01:00
|
|
|
|
|
|
|
```nix
|
2024-07-08 08:37:46 +01:00
|
|
|
{ config, ... }:
|
|
|
|
let
|
2024-07-08 05:12:24 +01:00
|
|
|
helpers = config.lib.nixvim;
|
2024-07-08 08:37:46 +01:00
|
|
|
in
|
2024-02-14 23:38:26 +01:00
|
|
|
{
|
2024-07-08 08:37:46 +01:00
|
|
|
# Your config
|
2024-02-14 23:38:26 +01:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2024-08-02 02:03:07 +01:00
|
|
|
Or you can access the extended `lib` used in standalone builds via the `nixvimLib` module arg:
|
|
|
|
|
|
|
|
```nix
|
|
|
|
{ nixvimLib, ... }:
|
|
|
|
{
|
|
|
|
# You can use nixvimLib.nixvim in your config
|
|
|
|
fooOption = nixvimLib.nixvim.mkRaw "print('hello')";
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
This "extended" lib, includes everything normally in `lib`, along with some additions from nixvim.
|
|
|
|
|
2024-08-20 23:38:01 +01:00
|
|
|
**Note:** the `lib` argument passed to modules is entirely unrelated to the `lib` _option_ accessed as `config.lib`!
|
|
|
|
|
2025-01-17 00:13:26 +00:00
|
|
|
## 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
|
2025-01-17 10:06:39 +00:00
|
|
|
myCustomLib = nixpkgs.lib.extend (final: prev: {
|
2025-01-17 00:13:26 +00:00
|
|
|
# ...
|
|
|
|
});
|
|
|
|
myCustomLibForNixvim = myCustomLib.extend inputs.nixvim.lib.overlay;
|
|
|
|
in
|
|
|
|
{
|
|
|
|
# ...
|
|
|
|
};
|
|
|
|
}
|
|
|
|
```
|