2024-04-01 12:05:46 +01:00
# Standalone Usage
## Options
When used standalone, nixvim's options are available directly, without any prefix/namespace.
This is unlike the other modules which typically use a `programs.nixvim.*` prefix.
There are **no** standalone-specific options available.
2024-04-01 13:19:21 +01:00
## Using in another configuration
Here is an example on how to integrate into a NixOS or Home-manager configuration when using flakes.
The example assumes your standalone config is the `default` package of a flake, and you've named the input "`nixvim-config` ".
```nix
{ inputs, system, ... }:
{
# NixOS
environment.systemPackages = [ inputs.nixvim-config.packages.${system}.default ];
# home-manager
home.packages = [ inputs.nixvim-config.packages.${system}.default ];
}
```
2024-04-01 12:05:46 +01:00
## Extending an existing configuration
2024-02-22 08:22:21 +01:00
2024-10-06 18:00:13 +00:00
Given a `<nixvim>` derivation obtained from `makeNixvim` or `makeNixvimWithModule` it is possible to create a new derivation with additional options.
2024-02-22 08:22:21 +01:00
2024-07-01 14:20:12 +01:00
This is done through the `<nixvim>.extend` function. This function takes a Nixvim module that is merged with the options used to build `<nixvim>` .
2024-02-22 08:22:21 +01:00
2024-07-01 14:20:12 +01:00
This function is recursive, meaning that it can be applied an arbitrary number of times.
2024-02-22 08:22:21 +01:00
2024-04-01 12:05:46 +01:00
### Example
2024-02-22 08:22:21 +01:00
```nix
2024-07-01 14:20:12 +01:00
{makeNixvim}: let
first = makeNixvim { extraConfigLua = "-- first stage"; };
second = first.extend {extraConfigLua = "-- second stage";};
third = second.extend {extraConfigLua = "-- third stage";};
2024-02-22 08:22:21 +01:00
in
third
```
2024-07-01 14:20:12 +01:00
This will generate a `init.lua` that will contain the comments from each stages:
```lua
-- first stage
-- second stage
-- third stage
```
2024-04-01 12:05:46 +01:00
2024-04-01 15:12:25 +00:00
## Accessing options used in an existing configuration
2024-07-01 14:20:12 +01:00
The `config` used to produce a standalone nixvim derivation can be accessed as an attribute on the derivation, similar to `<nixvim>.extend` .
2024-04-01 15:12:25 +00:00
This may be useful if you want unrelated parts of your NixOS or home-manager configuration to use the same value as something in your nixvim configuration.
2024-05-14 20:04:36 +02:00
## Accessing nixvim options
Given a nixvim derivation it is possible to access the module options using `<derivation>.options` .
This can be useful to configure `nixd` for example:
```nix
plugins.lsp.servers.nixd = {
enable = true;
settings = {
options.nixvim.expr = ''(builtins.getFlake "/path/to/flake").packages.${system}.neovimNixvim.options'';
};
};
```