Skip to content

Commit

Permalink
neovim: add a checkPhase in the wrapper
Browse files Browse the repository at this point in the history
add a checkPhase (if doCheck == true, disabled by default) that tries to
start neovim and fails in case of errors. It allows to catch small
misconfiugurations before switching to a new config.
  • Loading branch information
teto committed Nov 14, 2024
1 parent f49e820 commit 564a284
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
11 changes: 10 additions & 1 deletion pkgs/applications/editors/neovim/tests/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,17 @@ let
nvim-with-luasnip = wrapNeovim2 "-with-luasnip" (makeNeovimConfig {
plugins = [ {
plugin = vimPlugins.luasnip;

}
];
});

# build should fail with a wrong
nvim-run-failing-check = (wrapNeovimUnstable neovim-unwrapped {
luaRcContent = "this is an invalid lua statement to break the build";
}).overrideAttrs({
doCheck = true;
});

nvimAutoDisableWrap = makeNeovimConfig { };

wrapNeovim2 = suffix: config:
Expand Down Expand Up @@ -96,6 +102,9 @@ in

inherit nmt;

# Disabled because of https://github.com/NixOS/nixpkgs/pull/352727
# failed_check = pkgs.testers.testBuildFailure nvim-run-failing-check;

vim_empty_config = vimUtils.vimrcFile { beforePlugins = ""; customRC = ""; };

### neovim tests
Expand Down
9 changes: 8 additions & 1 deletion pkgs/applications/editors/neovim/wrapper.nix
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ let

stdenv.mkDerivation (finalAttrs:
let
pluginsNormalized = neovimUtils.normalizePlugins plugins;
pluginsNormalized = neovimUtils.normalizePlugins finalAttrs.plugins;

myVimPackage = neovimUtils.normalizedPluginsToVimPackage pluginsNormalized;

Expand Down Expand Up @@ -250,6 +250,13 @@ let
# A Vim "package", see ':h packages'
vimPackage = myVimPackage;

checkPhase = ''
runHook preCheck
$out/bin/nvim -i NONE -e +quitall!
runHook postCheck
'';

passthru = {
inherit providerLuaRc packpathDirs;
unwrapped = neovim-unwrapped;
Expand Down

0 comments on commit 564a284

Please sign in to comment.