Skip to content

Commit

Permalink
neovim: enable use of external package manager (#5225)
Browse files Browse the repository at this point in the history
* neovim: add extraWrapperArgs option

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

* neovim: add test for `extraWrapperArgs`
  • Loading branch information
misumisumi authored Apr 13, 2024
1 parent 40ab43a commit 8fdf329
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
25 changes: 24 additions & 1 deletion modules/programs/neovim.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
type = types.lines;
visible = true;
Expand Down Expand Up @@ -415,7 +437,8 @@ in {

programs.neovim.finalPackage = pkgs.wrapNeovimUnstable cfg.package
(neovimConfig // {
wrapperArgs = (lib.escapeShellArgs neovimConfig.wrapperArgs) + " "
wrapperArgs = (lib.escapeShellArgs
(neovimConfig.wrapperArgs ++ cfg.extraWrapperArgs)) + " "
+ extraMakeWrapperArgs + " " + extraMakeWrapperLuaCArgs + " "
+ extraMakeWrapperLuaArgs;
wrapRc = false;
Expand Down
14 changes: 14 additions & 0 deletions tests/modules/programs/neovim/runtime.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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 ];
Expand All @@ -33,7 +44,10 @@ with lib;

nmt.script = ''
ftplugin="home-files/.config/nvim/after/ftplugin/c.vim"
nvimbin="home-path/bin/nvim"
assertFileExists "$ftplugin"
assertFileRegex "$nvimbin" 'LIBRARY_PATH'
assertFileRegex "$nvimbin" 'PKG_CONFIG_PATH'
'';
};
}

0 comments on commit 8fdf329

Please sign in to comment.