neovim: enable use of external package manager (#5225)

* neovim: add extraWrapperArgs option

pass external arguments to neovim-unwrapper
this gives users more flexibility in managing neovim configuration

* neovim: add test for `extraWrapperArgs`
This commit is contained in:
MiSumiSumi 2024-04-13 23:50:15 +09:00 committed by GitHub
parent 40ab43ae98
commit 8fdf329526
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 38 additions and 1 deletions

View file

@ -198,6 +198,28 @@ in {
''; '';
}; };
extraWrapperArgs = mkOption {
type = with types; listOf str;
default = [ ];
example = literalExpression ''
[
"--suffix"
"LIBRARY_PATH"
":"
"''${lib.makeLibraryPath [ pkgs.stdenv.cc.cc pkgs.zlib ]}"
"--suffix"
"PKG_CONFIG_PATH"
":"
"''${lib.makeSearchPathOutput "dev" "lib/pkgconfig" [ pkgs.stdenv.cc.cc pkgs.zlib ]}"
]
'';
description = ''
Extra arguments to be passed to the neovim wrapper.
This option sets environment variables required for building and running binaries
with external package managers like mason.nvim.
'';
};
generatedConfigViml = mkOption { generatedConfigViml = mkOption {
type = types.lines; type = types.lines;
visible = true; visible = true;
@ -415,7 +437,8 @@ in {
programs.neovim.finalPackage = pkgs.wrapNeovimUnstable cfg.package programs.neovim.finalPackage = pkgs.wrapNeovimUnstable cfg.package
(neovimConfig // { (neovimConfig // {
wrapperArgs = (lib.escapeShellArgs neovimConfig.wrapperArgs) + " " wrapperArgs = (lib.escapeShellArgs
(neovimConfig.wrapperArgs ++ cfg.extraWrapperArgs)) + " "
+ extraMakeWrapperArgs + " " + extraMakeWrapperLuaCArgs + " " + extraMakeWrapperArgs + " " + extraMakeWrapperLuaCArgs + " "
+ extraMakeWrapperLuaArgs; + extraMakeWrapperLuaArgs;
wrapRc = false; wrapRc = false;

View file

@ -20,6 +20,17 @@ with lib;
}; };
} }
]; ];
extraWrapperArgs = let buildDeps = with pkgs; [ stdenv.cc.cc zlib ];
in [
"--suffix"
"LIBRARY_PATH"
":"
"${lib.makeLibraryPath buildDeps}"
"--suffix"
"PKG_CONFIG_PATH"
":"
"${lib.makeSearchPathOutput "dev" "lib/pkgconfig" buildDeps}"
];
} }
{ {
extraPython3Packages = ps: with ps; [ jedi pynvim ]; extraPython3Packages = ps: with ps; [ jedi pynvim ];
@ -33,7 +44,10 @@ with lib;
nmt.script = '' nmt.script = ''
ftplugin="home-files/.config/nvim/after/ftplugin/c.vim" ftplugin="home-files/.config/nvim/after/ftplugin/c.vim"
nvimbin="home-path/bin/nvim"
assertFileExists "$ftplugin" assertFileExists "$ftplugin"
assertFileRegex "$nvimbin" 'LIBRARY_PATH'
assertFileRegex "$nvimbin" 'PKG_CONFIG_PATH'
''; '';
}; };
} }