2024-07-07 15:19:35 -04:00
|
|
|
{ lib, inputs, ... }:
|
2024-03-01 22:43:05 +01:00
|
|
|
{
|
2024-07-07 15:19:35 -04:00
|
|
|
imports = lib.optional (inputs.devshell ? flakeModule) inputs.devshell.flakeModule;
|
2024-03-01 22:43:05 +01:00
|
|
|
|
|
|
|
perSystem =
|
|
|
|
{
|
2024-07-07 15:19:35 -04:00
|
|
|
lib,
|
2024-03-01 22:43:05 +01:00
|
|
|
pkgs,
|
|
|
|
config,
|
|
|
|
system,
|
|
|
|
...
|
|
|
|
}:
|
2024-07-07 15:19:35 -04:00
|
|
|
lib.optionalAttrs (inputs.devshell ? flakeModule) {
|
2024-03-01 22:43:05 +01:00
|
|
|
devshells.default = {
|
|
|
|
devshell.startup.pre-commit.text = config.pre-commit.installationScript;
|
|
|
|
|
|
|
|
commands =
|
|
|
|
let
|
|
|
|
# Thanks to this, the user can choose to use `nix-output-monitor` (`nom`) instead of plain `nix`
|
2024-06-27 17:30:05 +02:00
|
|
|
nix = ''$([ "$\{NIXVIM_NOM:-0}" = '1' ] && echo ${pkgs.lib.getExe pkgs.nix-output-monitor} || echo nix)'';
|
2024-03-01 22:43:05 +01:00
|
|
|
in
|
|
|
|
[
|
|
|
|
{
|
|
|
|
name = "checks";
|
|
|
|
help = "Run all nixvim checks";
|
2024-06-30 17:53:35 +01:00
|
|
|
command = ''
|
|
|
|
echo "=> Running all nixvim checks..."
|
|
|
|
|
|
|
|
${nix} flake check "$@"
|
|
|
|
'';
|
2024-03-01 22:43:05 +01:00
|
|
|
}
|
|
|
|
{
|
|
|
|
name = "tests";
|
|
|
|
help = "Run nixvim tests";
|
2024-07-20 00:18:36 +02:00
|
|
|
command =
|
|
|
|
let
|
|
|
|
launchTest = pkgs.writeShellApplication {
|
|
|
|
name = "launch-tests";
|
|
|
|
runtimeInputs = with pkgs; [
|
2024-08-15 08:02:57 -05:00
|
|
|
getopt
|
2024-07-20 00:18:36 +02:00
|
|
|
jq
|
|
|
|
fzf
|
|
|
|
];
|
2024-03-01 22:43:05 +01:00
|
|
|
|
2024-07-20 00:18:36 +02:00
|
|
|
text = builtins.readFile ./launch-test.sh;
|
|
|
|
};
|
|
|
|
in
|
|
|
|
''
|
|
|
|
NIXVIM_SYSTEM=${system} NIXVIM_NIX_COMMAND=${nix} ${lib.getExe launchTest} "$@"
|
|
|
|
'';
|
2024-03-01 22:43:05 +01:00
|
|
|
}
|
2024-06-30 17:53:35 +01:00
|
|
|
{
|
|
|
|
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-03-01 22:43:05 +01:00
|
|
|
{
|
|
|
|
name = "format";
|
|
|
|
help = "Format the entire codebase";
|
|
|
|
command = "nix fmt";
|
|
|
|
}
|
|
|
|
{
|
|
|
|
name = "docs";
|
|
|
|
help = "Build nixvim documentation";
|
|
|
|
command = ''
|
|
|
|
echo "=> Building nixvim documentation..."
|
|
|
|
|
2024-03-04 09:24:24 +01:00
|
|
|
${nix} build .#docs "$@"
|
2024-03-01 22:43:05 +01:00
|
|
|
'';
|
|
|
|
}
|
|
|
|
{
|
|
|
|
name = "serve-docs";
|
|
|
|
help = "Build and serve documentation locally";
|
|
|
|
command = ''
|
|
|
|
echo -e "=> Building nixvim documentation...\n"
|
|
|
|
|
|
|
|
doc_derivation=$(${nix} build .#docs --no-link --print-out-paths)
|
|
|
|
|
2024-03-07 19:44:13 +01:00
|
|
|
echo -e "\n=> Documentation successfully built ('$doc_derivation')"
|
2024-03-01 22:43:05 +01:00
|
|
|
|
2024-07-24 22:31:16 +02:00
|
|
|
echo -e "\n=> You can then open your browser to view the doc\n"
|
2024-03-01 22:43:05 +01:00
|
|
|
|
2024-07-24 22:31:16 +02:00
|
|
|
(cd "$doc_derivation"/share/doc && ${pkgs.lib.getExe pkgs.python3} ${./server.py})
|
2024-03-01 22:43:05 +01:00
|
|
|
'';
|
|
|
|
}
|
2024-06-20 09:32:37 +02:00
|
|
|
{
|
|
|
|
name = "list-plugins";
|
|
|
|
command = "${pkgs.python3.interpreter} ${./list-plugins.py}";
|
|
|
|
help = "List plugins and get implementation infos";
|
|
|
|
}
|
2024-03-01 22:43:05 +01:00
|
|
|
];
|
2024-05-05 19:39:35 +02:00
|
|
|
};
|
2024-03-01 22:43:05 +01:00
|
|
|
};
|
|
|
|
}
|