Skip to content

Commit

Permalink
feat(nix): use test suite as base for devShell
Browse files Browse the repository at this point in the history
  • Loading branch information
mrcjkb committed Dec 14, 2023
1 parent 777091b commit 446a48f
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 64 deletions.
2 changes: 1 addition & 1 deletion .envrc
@@ -1 +1 @@
use flake -Lv
use flake . -Lv
48 changes: 26 additions & 22 deletions CONTRIBUTING.md
Expand Up @@ -13,18 +13,12 @@ This project uses
## Development

I use [`nix`](https://nixos.org/download.html#download-nix)
for development and testing.
(with flakes enabled) for development and testing.

Formatting is done with [`stylua`](https://github.com/JohnnyMorganz/StyLua).

To enter a development shell:

```console
nix-shell
```

or (with flakes enabled)

```console
nix develop
```
Expand All @@ -40,33 +34,43 @@ just run `direnv allow` and you will be dropped in this devShell.

## Tests

To run tests locally
### Running tests

```console
nix-build -A ci
```
I use [`busted`](https://lunarmodules.github.io/busted/) for testing,
but with Neovim as the Lua interpreter.

or (with flakes enabled)
The easiest way to run tests is with Nix (see below).

```console
nix build .#checks.<your-system>.ci --print-build-logs
```
If you do not use Nix, you can also run the test suite using `luarocks test`.
For more information on how to set up Neovim as a Lua interpreter, see

For formatting:
- The [neorocks tutorial](https://github.com/nvim-neorocks/neorocks#without-neolua).

Or

- [`nlua`](https://github.com/mfussenegger/nlua).

> [!NOTE]
>
> The Nix devShell sets up `luarocks test` to use Neovim as the interpreter.
### Running tests and checks with Nix

If you just want to run all checks that are available,
run:

```console
nix-build -A formatting
nix flake check --print-build-logs
```

or (with flakes enabled)
To run tests locally

```console
nix build .#checks.<your-system>.formatting --print-build-logs
nix build .#checks.<your-system>.ci --print-build-logs
```

If you have flakes enabled and just want to run all checks that are available,
run:
For formatting:

```console
nix flake check --print-build-logs
nix build .#checks.<your-system>.formatting --print-build-logs
```
72 changes: 36 additions & 36 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 12 additions & 5 deletions flake.nix
Expand Up @@ -104,13 +104,20 @@
};
};

devShell = pkgs.mkShell {
devShell = pkgs.nvim-nightly-tests.overrideAttrs (oa: {
name = "devShell"; # TODO: Choose a name
inherit (pre-commit-check) shellHook;
buildInputs = with pkgs; [
zlib
];
};
buildInputs = with pre-commit-hooks.packages.${system};
[
alejandra
lua-language-server
stylua
luacheck
editorconfig-checker
markdownlint-cli
]
++ oa.buildInputs;
});
in {
devShells = {
default = devShell;
Expand Down

0 comments on commit 446a48f

Please sign in to comment.