From 31dc3e56e07583d0ad1e32b4098f9b5a7685cbfb Mon Sep 17 00:00:00 2001 From: "Matthieu C." <886074+teto@users.noreply.github.com> Date: Thu, 31 Oct 2024 23:36:04 +0100 Subject: [PATCH] neovim: add a checkPhase in the wrapper 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. --- pkgs/applications/editors/neovim/tests/default.nix | 11 ++++++++++- pkgs/applications/editors/neovim/wrapper.nix | 9 ++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/pkgs/applications/editors/neovim/tests/default.nix b/pkgs/applications/editors/neovim/tests/default.nix index a5443ab4896c..1c468282d106 100644 --- a/pkgs/applications/editors/neovim/tests/default.nix +++ b/pkgs/applications/editors/neovim/tests/default.nix @@ -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: @@ -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 diff --git a/pkgs/applications/editors/neovim/wrapper.nix b/pkgs/applications/editors/neovim/wrapper.nix index 270fdf3ce878..b51e7f08a0bf 100644 --- a/pkgs/applications/editors/neovim/wrapper.nix +++ b/pkgs/applications/editors/neovim/wrapper.nix @@ -61,7 +61,7 @@ let stdenv.mkDerivation (finalAttrs: let - pluginsNormalized = neovimUtils.normalizePlugins plugins; + pluginsNormalized = neovimUtils.normalizePlugins finalAttrs.plugins; myVimPackage = neovimUtils.normalizedPluginsToVimPackage pluginsNormalized; @@ -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;