nix-community.nixvim/lib/check.nix
traxys f5f33b5390
tests: Allow to skip running neovim (#260)
Some plugins don't really play nicely with being launched in a headless
sandboxed environment. This adds the pseudo option 'tests.dontRun' to
avoid running those tests
2023-03-16 09:13:43 +01:00

35 lines
772 B
Nix

{pkgs, ...}: {
checkNvim = {
name,
nvim,
dontRun,
...
}:
pkgs.stdenv.mkDerivation {
name = name;
nativeBuildInputs = [nvim];
dontUnpack = true;
# We need to set HOME because neovim will try to create some files
#
# Because neovim does not return an exitcode when quitting we need to check if there are
# errors on stderr
buildPhase =
if !dontRun
then ''
output=$(HOME=$(realpath .) nvim -mn --headless "+q" 2>&1 >/dev/null)
if [[ -n $output ]]; then
echo "ERROR: $output"
exit 1
fi
''
else ''
'';
# If we don't do this nix is not happy
installPhase = ''
mkdir $out
'';
};
}