nix-community.nixvim/flake/dev/devshell.nix
Matt Sturgeon db7c5364a5 tests: use a nested attrset for buildbot
We need to optimise the buildbot attrs for nix-eval-jobs, however this
doesn't make sense for `nix flake check` or `nix flake show`.

Now that we aren't using the `checks` output, we don't _need_ to
restrict ourselves to a flat set of test derivations anymore.

This also simplifies our `tests` command, and means we no longer need to
pre-compute the test attr names.
2025-07-10 10:56:41 +00:00

118 lines
3.4 KiB
Nix

{ lib, inputs, ... }:
{
imports = [
inputs.devshell.flakeModule
];
perSystem =
{
pkgs,
config,
self',
system,
...
}:
{
devshells.default = {
devshell.startup.pre-commit.text = config.pre-commit.installationScript;
devshell.packages = [
config.formatter
];
env = [
{
# Prefix NIX_PATH with nixvim's nixpkgs while in the devshell
name = "NIX_PATH";
eval = "nixpkgs=$NIXPKGS_PATH:\${NIX_PATH:-}";
}
];
commands =
let
# Thanks to this, the user can choose to use `nix-output-monitor` (`nom`) instead of plain `nix`
nix = ''$([ "$\{NIXVIM_NOM:-0}" = '1' ] && echo ${pkgs.lib.getExe pkgs.nix-output-monitor} || echo nix)'';
in
[
{
name = "checks";
help = "Run all nixvim checks";
# TODO: run tests from the `ci` flake output too?
command = ''
echo "=> Running all nixvim checks..."
${nix} flake check "$@"
'';
}
{
name = "tests";
help = "Run nixvim tests";
command =
let
launchTest = pkgs.writeShellApplication {
name = "launch-tests";
runtimeInputs = with pkgs; [
getopt
jq
fzf
];
text = builtins.readFile ./launch-test.sh;
};
in
''
export NIXVIM_SYSTEM=${system}
export NIXVIM_NIX_COMMAND=${nix}
${lib.getExe launchTest} "$@"
'';
}
{
name = "test-lib";
help = "Run nixvim library tests";
command = ''
echo "=> Running nixvim library tests for the '${system}' architecture..."
${nix} build .#checks.${system}.lib-tests "$@"
'';
}
{
name = "format";
help = "Format the entire codebase";
command = lib.getExe config.formatter;
}
{
name = "docs";
help = "Build nixvim documentation";
command = ''
echo "=> Building nixvim documentation..."
${nix} build .#docs "$@"
'';
}
{
name = "serve-docs";
help = "Build and serve documentation locally";
command = ''
echo -e "=> Building nixvim documentation...\n"
nix run .#docs
'';
}
{
name = "locate-lsp-packages";
command = ''${./locate-lsp-packages.py}'';
help = "Locate (with nix-index) LSP servers in nixpkgs";
}
{
name = "new-plugin";
command = ''${./new-plugin.py} "$@"'';
help = "Create a new plugin";
}
{
name = "diff-plugins";
command = ''${./diff-plugins.py} "$@"'';
help = "Compare available plugins with another nixvim commit";
}
];
};
};
}