NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
18.37k stars 14.32k forks source link

use the module system to eval neovim configuration #358552

Open teto opened 6 days ago

teto commented 6 days ago

Issue description

the neovim wrapper has "many" knobs and configuring neovim is a source of frustration for many, sometimes because configuring neovim itself is hard (cough treesitter cough). It could be nice to check the arguments with an internal module via evalModule like the kernel does (https://github.com/NixOS/nixpkgs/blob/975e7e7c20bee89f9cf14a0b26401cb93fe36381/pkgs/os-specific/linux/kernel/generic.nix#L205):

cc @NixOS/neovim

NB: this is different from programs.neovim which can generate only one config for the whole system.

Technical details

PerchunPak commented 6 days ago

Could you please provide an example how it would look like? I cannot really imagine how transforming nix to lua would work

teto commented 6 days ago

so basically you write nixos module options (some could be copy/pasted from https://github.com/nix-community/home-manager/blob/92fef254a9071fa41a13908281284e6a62b9c92e/modules/programs/neovim.nix#L16) and you check the wrapper values against these options via evalModules. The options dont appear in man configuration.nix but nix is going to check the wrapper values and can give better messages when a value is of the wrong type for instance.

Maybe it's overengineering that only increases eval time. I am not a 100% sure my suggestion is a good idea (like the other ones xD). My concern is mostly about the "plugins" argument of the wrapper. It's a list of plugins with each plugin having optional settings like "optional" and "config". I am afraid this can be hard to use for users of the wrapper, especially as I would like the new wrapper to become the standard one (ie, be the one we advise in the nixpkgs documentation) for neovim.