mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-21 00:25:42 +02:00
wrappers: Extend and document the makeNixvim
function (#86)
* wrappers: Allow to customize the nixpkgs used for nixvim This allows to pass overlays and other such modifications of nixpkgs. * wrappers: Allow to pass a custom module to nixvim This is useful to be able to take full advantage of the Nix module system, with `imports` and `options`. * README: Update the documentation on the standalone usage The following information were out of date or incomplete: - The `build` function has be changed to the `makeNixvim` function. - `makeNixvimWithModule` has been introduced in order to allow more customization. - Added a full example using nixvim in a standalone flake
This commit is contained in:
parent
4dedb06ceb
commit
660c9319e1
3 changed files with 63 additions and 7 deletions
56
README.md
56
README.md
|
@ -80,23 +80,73 @@ you're not using it.
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
NixVim can be used in three ways: through the home-manager and NixOS modules,
|
NixVim can be used in three ways: through the home-manager and NixOS modules,
|
||||||
and through the `build` function. To use the modules, just import the
|
and through the `makeNixvim` function. To use the modules, just import the
|
||||||
`nixvim.homeManagerModules.${system}.nixvim` and
|
`nixvim.homeManagerModules.${system}.nixvim` and
|
||||||
`nixvim.nixosModules.${system}.nixvim` modules, depending on which system
|
`nixvim.nixosModules.${system}.nixvim` modules, depending on which system
|
||||||
you're using.
|
you're using.
|
||||||
|
|
||||||
If you want to use it standalone, you can use the `build` function:
|
If you want to use it standalone, you can use the `makeNixvim` function:
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
{ pkgs, nixvim, ... }: {
|
{ pkgs, nixvim, ... }: {
|
||||||
environment.systemModules = [
|
environment.systemModules = [
|
||||||
(nixvim.build pkgs {
|
(nixvim.legacyPackages."${system}".makeNixvim {
|
||||||
colorschemes.gruvbox.enable = true;
|
colorschemes.gruvbox.enable = true;
|
||||||
})
|
})
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Alternatively if you want a minimal flake to allow building a custom neovim you
|
||||||
|
can use the following:
|
||||||
|
|
||||||
|
```nix
|
||||||
|
{
|
||||||
|
description = "A very basic flake";
|
||||||
|
|
||||||
|
inputs.nixvim.url = "github:pta2002/nixvim";
|
||||||
|
inputs.flake-utils.url = "github:numtide/flake-utils";
|
||||||
|
|
||||||
|
outputs = {
|
||||||
|
self,
|
||||||
|
nixpkgs,
|
||||||
|
nixvim,
|
||||||
|
flake-utils,
|
||||||
|
}: let
|
||||||
|
config = {
|
||||||
|
colorschemes.gruvbox.enable = true;
|
||||||
|
};
|
||||||
|
in
|
||||||
|
flake-utils.lib.eachDefaultSystem (system: let
|
||||||
|
nixvim' = nixvim.legacyPackages."${system}";
|
||||||
|
nvim = nixvim'.makeNixvim config;
|
||||||
|
in {
|
||||||
|
packages = {
|
||||||
|
inherit nvim;
|
||||||
|
default = nvim;
|
||||||
|
};
|
||||||
|
});
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
You can then run neovim using `nix run .# -- <file>`. This can be useful to test
|
||||||
|
config changes easily.
|
||||||
|
|
||||||
|
### Advanced Usage
|
||||||
|
|
||||||
|
You may want more control over the nixvim modules like:
|
||||||
|
|
||||||
|
- Splitting your configuration in multiple files
|
||||||
|
- Adding custom nix modules to enhance nixvim
|
||||||
|
- Change the nixpkgs used by nixvim
|
||||||
|
|
||||||
|
In this case you can use the `makeNixvimWithModule` function.
|
||||||
|
|
||||||
|
It takes a set with the following keys:
|
||||||
|
- `pkgs`: The nixpkgs to use (defaults to the nixpkgs pointed at by the nixvim flake)
|
||||||
|
- `module`: The nix module definition used to extend nixvim.
|
||||||
|
This is useful to pass additional module machinery like `options` or `imports`.
|
||||||
|
|
||||||
## How does it work?
|
## How does it work?
|
||||||
When you build the module (probably using home-manager), it will install all
|
When you build the module (probably using home-manager), it will install all
|
||||||
your plugins and generate a lua config for NeoVim with all the options
|
your plugins and generate a lua config for NeoVim with all the options
|
||||||
|
|
10
flake.nix
10
flake.nix
|
@ -40,8 +40,14 @@
|
||||||
packages.docs = pkgs.callPackage (import ./docs.nix) {
|
packages.docs = pkgs.callPackage (import ./docs.nix) {
|
||||||
modules = nixvimModules;
|
modules = nixvimModules;
|
||||||
};
|
};
|
||||||
|
legacyPackages = rec {
|
||||||
legacyPackages.makeNixvim = import ./wrappers/standalone.nix pkgs (modules pkgs);
|
makeNixvimWithModule = import ./wrappers/standalone.nix pkgs modules;
|
||||||
|
makeNixvim = configuration: makeNixvimWithModule {
|
||||||
|
module = {
|
||||||
|
config = configuration;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
});
|
});
|
||||||
in
|
in
|
||||||
flakeOutput // {
|
flakeOutput // {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
pkgs: modules: configuration:
|
default_pkgs: modules: {pkgs ? default_pkgs, module}:
|
||||||
|
|
||||||
let
|
let
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ let
|
||||||
wrap = { wrapRc = true; };
|
wrap = { wrapRc = true; };
|
||||||
|
|
||||||
eval = lib.evalModules {
|
eval = lib.evalModules {
|
||||||
modules = modules ++ [ { config = configuration; } wrap ];
|
modules = (modules pkgs) ++ [ module wrap ];
|
||||||
};
|
};
|
||||||
|
|
||||||
in eval.config.finalPackage
|
in eval.config.finalPackage
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue