nix-community.nixvim/flake-modules/dev/devshell.nix

88 lines
2.6 KiB
Nix
Raw Normal View History

2024-05-05 19:39:35 +02:00
{ inputs, ... }:
{
imports = [ inputs.devshell.flakeModule ];
2024-03-01 22:43:05 +01:00
2024-05-05 19:39:35 +02:00
perSystem =
{
pkgs,
config,
system,
...
}:
{
devshells.default = {
devshell.startup.pre-commit.text = config.pre-commit.installationScript;
2024-03-01 22:43:05 +01:00
2024-05-05 19:39:35 +02:00
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)'';
2024-05-05 19:39:35 +02:00
in
[
{
name = "checks";
help = "Run all nixvim checks";
command = ''
echo "=> Running all nixvim checks..."
${nix} flake check "$@"
'';
2024-05-05 19:39:35 +02:00
}
{
name = "tests";
help = "Run nixvim tests";
command = ''
echo "=> Running nixvim tests for the '${system}' architecture..."
2024-03-01 22:43:05 +01:00
2024-05-05 19:39:35 +02:00
${nix} build .#checks.${system}.tests "$@"
'';
}
{
name = "test-lib";
help = "Run nixvim library tests";
command = ''
echo "=> Running nixvim library tests for the '${system}' architecture..."
${nix} build .#checks.${system}.lib-tests "$@"
'';
}
2024-05-05 19:39:35 +02:00
{
name = "format";
help = "Format the entire codebase";
command = "nix fmt";
}
{
name = "docs";
help = "Build nixvim documentation";
command = ''
echo "=> Building nixvim documentation..."
2024-03-01 22:43:05 +01:00
2024-05-05 19:39:35 +02:00
${nix} build .#docs "$@"
'';
}
{
name = "serve-docs";
help = "Build and serve documentation locally";
command = ''
echo -e "=> Building nixvim documentation...\n"
2024-03-01 22:43:05 +01:00
2024-05-05 19:39:35 +02:00
doc_derivation=$(${nix} build .#docs --no-link --print-out-paths)
2024-03-01 22:43:05 +01:00
2024-05-05 19:39:35 +02:00
echo -e "\n=> Documentation successfully built ('$doc_derivation')"
2024-03-01 22:43:05 +01:00
2024-05-05 19:39:35 +02:00
port=8000
echo -e "\n=> Now open your browser and navigate to 'localhost:$port'\n"
2024-03-01 22:43:05 +01:00
2024-05-05 19:39:35 +02:00
${pkgs.lib.getExe pkgs.python3} -m http.server -d "$doc_derivation"/share/doc
'';
}
{
name = "list-plugins";
command = "${pkgs.python3.interpreter} ${./list-plugins.py}";
help = "List plugins and get implementation infos";
}
2024-05-05 19:39:35 +02:00
];
};
2024-03-01 22:43:05 +01:00
};
}