Skip to content

Example

The following is an example of using the library to document the programs.neovim options from NixOS.

Base files

This document is created simply by loading the Vue component with the data from the loader. Please read the documentation.

vue
<!-- index.md -->
## Title

Some text

<script setup>
import { data } from "./nixos.data.js";
import { RenderDocs } from "easy-nix-documentation";
</script>

## Options

<RenderDocs :options="data" />
ts
// nixos.data.ts
import { dirname } from 'node:path'
import { fileURLToPath } from 'node:url'
import { loadOptions, stripNixStore } from "easy-nix-documentation/loader"


export default {
    async load() {
        const __dirname = dirname(fileURLToPath(import.meta.url));

        return await loadOptions(`-f ${__dirname}/example.nix optionsJSON`, {
            include: [/programs\.neovim\.*/],
            mapDeclarations: declaration => {
                const relDecl = stripNixStore(declaration);
                return `<a href="http://github.com/NixOS/nixpkgs/tree/nixos-unstable/${relDecl}">&lt;${relDecl}&gt;</a>`
            },
        })
    }
}
nix
# example.nix
let
  pkgs = import <nixpkgs> { };
  nixos = import <nixpkgs/nixos> {
    configuration = { };
  };
in
pkgs.nixosOptionsDoc {
  inherit (nixos) options;
}

Options

programs.neovim.configure

Generate your init file from your list of plugins and custom commands. Neovim will then be wrapped to load nvim -u /nix/store/«hash»-vimrc

Type:
attribute set
Default:
{ }
Example:
{
  customRC = ''
    " here your custom configuration goes!
  '';
  packages.myVimPackage = with pkgs.vimPlugins; {
    # loaded on launch
    start = [ fugitive ];
    # manually loadable by calling `:packadd $plugin-name`
    opt = [ ];
  };
}
Declaration

programs.neovim.defaultEditor

When enabled, installs neovim and configures neovim to be the default editor using the EDITOR environment variable.

Type:
boolean
Default:
false
Declaration

programs.neovim.enable

Whether to enable Neovim.

When enabled through this option, Neovim is wrapped to use a configuration managed by this module. The configuration file in the user's home directory at ~/.config/nvim/init.vim is no longer loaded by default.

Type:
boolean
Default:
false
Example:
true
Declaration

programs.neovim.package

The neovim-unwrapped package to use.

Type:
package
Default:
pkgs.neovim-unwrapped
Declaration

programs.neovim.runtime

Set of files that have to be linked in runtime.

Type:
attribute set of (submodule)
Default:
{ }
Example:
{ "ftplugin/c.vim".text = "setlocal omnifunc=v:lua.vim.lsp.omnifunc"; }
Declaration

programs.neovim.runtime.<name>.enable

Whether this runtime directory should be generated. This option allows specific runtime files to be disabled.

Type:
boolean
Default:
true
Declaration

programs.neovim.runtime.<name>.source

Path of the source file.

Type:
null or absolute path
Default:
null
Declaration

programs.neovim.runtime.<name>.target

Name of symlink. Defaults to the attribute name.

programs.neovim.runtime.<name>.text

Text of the file.

Type:
null or strings concatenated with "\n"
Default:
null
Declaration

programs.neovim.viAlias

Symlink vi to {command}nvim binary.

Type:
boolean
Default:
false
Declaration

programs.neovim.vimAlias

Symlink vim to {command}nvim binary.

Type:
boolean
Default:
false
Declaration

programs.neovim.withNodeJs

Enable Node provider.

Type:
boolean
Default:
false
Declaration

programs.neovim.withPython3

Enable Python 3 provider.

Type:
boolean
Default:
true
Declaration

programs.neovim.withRuby

Enable Ruby provider.

Type:
boolean
Default:
true
Declaration

services.rsnapshot.cronIntervals

Periodicity at which intervals should be run by cron. Note that the intervals also have to exist in configuration as retain options.

Type:
attribute set of string
Default:
{ }
Example:
{
  daily = "50 21 * * *";
  hourly = "0 * * * *";
}
Declaration

services.rsnapshot.enable

Whether to enable rsnapshot backups.

Type:
boolean
Default:
false
Example:
true
Declaration

services.rsnapshot.enableManualRsnapshot

Whether to enable manual usage of the rsnapshot command with this module.

Type:
boolean
Default:
true
Declaration

services.rsnapshot.extraConfig

rsnapshot configuration option in addition to the defaults from rsnapshot and this module.

Note that tabs are required to separate option arguments, and directory names require trailing slashes.

The "extra" in the option name might be a little misleading right now, as it is required to get a functional configuration.

Type:
strings concatenated with "\n"
Default:
""
Example:
''
  retains	hourly	24
  retain	daily	365
  backup	/home/	localhost/
''
Declaration