Make the `finalPackage` option public, but still read-only. The final
package option is quite useful for users.
For example, to integrate `lazy.nvim` with Nix there are three things
that must be done:
1. `lazy.nvim` resets packpath, which should be managed by Nix; it has
to be turned off with `performance.reset_packpath = false` option in
`lazy.nvim`
2. Same thing applies to rtp, the relevant option is
`performance.rtp.reset = false`
3. `dev.path` must be specified as the folder that contains the plugins.
This folder is the path to Nix store path with Neovim plugins, and
the plugins that are managed by Nix must be marked as `dev = true`
The third condition can not be fulfilled without this PR, as the final
package that Home Manager produces is not exposed, therefore it is
impossible to extract the Nix store path. This PR makes it more
accessible via
${
pkgs.vimUtils.packDir config.programs.neovim.finalPackage.passthru.packpathDirs
}/pack/myNeovimPackages/start
These (and the `*MD` functions apart from `literalMD`) are now no-ops
in nixpkgs and serve no purpose other than to add additional noise and
potentially mislead people into thinking unmarked DocBook documentation
will still be accepted.
Note that if backporting changes including documentation to 23.05,
the `mdDoc` calls will need to be re-added.
To reproduce this commit, run:
$ NIX_PATH=nixpkgs=flake:nixpkgs/e7e69199f0372364a6106a1e735f68604f4c5a25 \
nix shell nixpkgs#coreutils \
-c find . -name '*.nix' \
-exec nix run -- github:emilazy/nix-doc-munge/98dadf1f77351c2ba5dcb709a2a171d655f15099 \
--strip {} +
$ ./format
This process was automated by [my fork of `nix-doc-munge`]. All
conversions were automatically checked to produce the same DocBook
result when converted back, modulo minor typographical/formatting
differences on the acceptable-to-desirable spectrum.
To reproduce this commit, run:
$ NIX_PATH=nixpkgs=flake:nixpkgs/e7e69199f0372364a6106a1e735f68604f4c5a25 \
nix shell nixpkgs#coreutils \
-c find . -name '*.nix' \
-exec nix run -- github:emilazy/nix-doc-munge/98dadf1f77351c2ba5dcb709a2a171d655f15099 \
{} +
$ ./format
[my fork of `nix-doc-munge`]: https://github.com/emilazy/nix-doc-munge/tree/home-manager
link the packpath in expected folder so that even unwrapped neovim can pick home-manager's plugins.
I sometimes need to run neovim not wrapped/configured by nix (when
developing neovim or when other projects bring their own neovim in
PATH). Currently they dont find plugins installed by home-manager in the
cases where packpath is not set to the generated nix packpath directory.
With this change, neovim can discover HM-installed plugins by itself.
Assigning to `programs.neovim.extraLuaPackages` a function taking a lua package set as input
and returning a list of packages, as described in the documentation,
threw an error because the rest of the code assumed that the value was always a plain list.
Using `lib.types.coercedTo`, we can accept such functions, as per the documentation,
as well as plain lists, which we then convert to a function ignoring its input argument.
We print a warning when a plain list is assigned, since the function
form is preferred, as it ensures that the right lua package set is used.
For the lua packages, we also get the lua package set from the
finalPackage, to make sure that we are always using the same package set
as the actual unwrapped neovim package being built.
For `programs.neovim.extraPythonPackages` I did the same.
I updated the test case so that we test both ways of setting these options.
The previous version linked the file into home, then sourced that. Since
nothing else expects that file to be there, this is unnecessary.
Additionally, doing so made it impossible to test a built config without
switching, e.g. using `XDG_CONFIG_HOME=… nvim` or `nvim -u`. This
remedies that, at least for this particular reference.
To test this, change from asserting contents of the config file to
actually starting nvim, outputting sentinel values, and then asserting
their values are present. This way it’s tested that nvim loaded the
config, rather than that some config is in a specific place.
This is all in one commit as the test, as written now, would not have
worked before since the previously hard-coded home path was not an
actual file in the test environment.
We change the current logic: instead of writing an init.vim which loads
lua/init-home-manager.lua, we write an init.lua that sources init.vim
This commit also avoids writing any of these files if the plugins have
no config.
everything is now covered by other settings that are more user friendly
than this big opaque attrset.
Also 'configure' wont do anything with nixpkgs-unstable the way HM
configures neovim. so no need to keep it, the deprecation warning is > 1
year old.
Plugins now accept a "type" element describing the language (viml, lua
, teal, fennel, ...) in which
they are configured.
The configuration of the different plugins is aggregated per language
and made available as a key in the attribute set `programs.neovim.generatedConfigs`
For instance if you want to configure a lua package:
```
programs.neovim.plugins = [
{
plugin = packer-nvim;
type = "lua";
config = ''
require('packer').init({
luarocks = {
python_cmd = 'python' -- Set the python command to use for running hererocks
},
})
'';
}
]
```
and you can save the generated lua config to a file via
```
xdg.configFile = {
"nvim/init.generated.lua".text = config.programs.neovim.generatedConfigs.lua;
};
```
Expose the generated viml config, this has 2 advantages:
1/ user can choose to write the generated config to a file of its choice
2/ the user can prepend/append to the config before writing it
xdg.configFile."nvim/init.vim".text = ''
" prepend some config
${programs.neovim.generatedConfigViml}
" append some config
'';
NOTE: this was already possible with
xdg.configFile."nvim/init.vim" = mkMerge [
(mkBefore {
text = ''
" prepend some config
'';
})
(mkAfter {
text = ''
" append some config
'';
})
]
This adds two new options: 'programs.neovim.coc.{enable,settings}`.
These settings offer a simple interface over `xdg.configFile."nvim/coc-settings.json`,
using the standard Nix' syntax instead of a multiline string.
When installing plugins, Home Manager expects plugins (packages) to have
a `pname` attribute.
This is not always the case, so fallback to `name` if `pname` is unset.
The `configure` option is not type checked and an artifact of how
nixpkgs is implemented.
We now have the equivalent options in home-manager and managing
interactions between the 2 systems complexifies maintainance of the
module.
Please use the other options at your disposal:
configure.packages.*.opt -> programs.neovim.plugins = [ { plugin = ...; optional = true; }]
configure.packages.*.start -> programs.neovim.plugins = [ { plugin = ...; }]
configure.customRC -> programs.neovim.extraConfig
* neovim: write config in $XDG_CONFIG_HOME/init.vim
instead of wrapping the configuration, which has sideeffects
https://github.com/NixOS/nixpkgs/issues/55376
* fix: update test accordingly
* neovim: allow setting init.vim config alongside plugins
* neovim: add test for neovim plugins
* neovim: make pluginWithConfigType a have type submodule
The `programs.neovim.configure` option is consistent with NixOS's
`wrapNeovim` and offers features not supported by the `extraConfig`
and `plugins` option pair.
Closes#971