Checks are really just derivations. You could do something like this:
{
inputs = {
nixpkgs.url = "nixpkgs";
nix-filter.url = "github:numtide/nix-filter";
};
outputs = let
system = "x86_64-linux"; # Use flake-utils if this is too restrictive
pkgs = nixpkgs.legacyPackages.${system}; # I think, been a while since I last used this without import
in
{
self,
nixpkgs,
nix-filter,
}: {
checks."${system}" = {
vim = pkgs.stdenv.mkDerivation {
# Using `nix-filter` to prevent issues with the directory
# name of `self` not being reproducible, and so the check
# doesn't want to re-run every time any file is changed.
src = nix-filter {
root = self;
include = [
./config/nvimrc # I presume
];
};
};
buildInputs = [
self.packages."${system}".vim # If you have a custom vim package
];
doCheck = true;
dontConfigure = true;
dontBuild = true;
dontInstall = true;
checkPhase = ''
# We *must* create some output, usually contains test logs for checks
mkdir -p "$out"
# Probably want to do something to ensure your config file is read, too
nvim --headless -c q > "$out/nvim.log"
if [ -z "$(cat "$out/nvim.log")" ]; then
exit 1
fi
'';
};
};
}
checks = {
neovim-check-config = pkgs.runCommand "neovim-check-config" {
buildInputs = [pkgs.git];
} ''
# We *must* create some output, usually contains test logs for checks
mkdir -p "$out"
# Probably want to do something to ensure your config file is read, too
export HOME=$TMPDIR
${self.packages."${system}".default}/bin/nvim --headless -c "q" 2> "$out/nvim.log"
if [ -n "$(cat "$out/nvim.log")" ]; then
echo "output: "$(cat "$out/nvim.log")""
exit 1
fi
'';
};