Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for nix checks #8

Closed
bew opened this issue Jul 5, 2023 · 3 comments · Fixed by #50
Closed

Support for nix checks #8

bew opened this issue Jul 5, 2023 · 3 comments · Fixed by #50
Assignees
Labels
enhancement New feature or request

Comments

@bew
Copy link

bew commented Jul 5, 2023

Hello!

I'd like to use neorocks to run tests locally, but without having to play with luarocks.

The goal is to use a flake check derivation and run the tests using nix flake check which will try to build theflake.checks.${system}.default and if that builds successfully it means the test is green.

It would eb nice to show in the README or have example projects that shows how to test a neovim plugin like this

@mrcjkb
Copy link
Member

mrcjkb commented Jul 5, 2023

Hi. Thanks for your request. I haven't implemented support for tests in a nix derivation yet.

I have something in mind, like a pkgs.neorocksTest function (which will be a wrapper around pkgs.stdenv.mkDerivation) 😄.

There are some issues I need to work out though:

  • With the current design (which I originally intended for use with GitHub Actions) luarocks will try to fetch dependencies defined in the rockspec from luarocks.org. This doesn't work in a mkDerivation's checkPhase, because it's impure. It might work with sandboxing disabled, but I would prefer a sandboxed approach.

  • Also, on NixOS, and in a derivation's checkPhase, luarocks won't be able to install packages that depend on dynamic libraries (e.g. busted depends on librt), because it can't find them in the nix store.

So the API for a nix flake check might have to look something like this:

checks.${system}.default = neorocksTest {
  src = self;
  luaPackages = p: with p; [ ... ]; # The plugins listed in the rockspec dependencies
  vimPlugins = p: with p; [ ... ]; # Additional vim plugins not available on luarocks
}

@mrcjkb mrcjkb added the enhancement New feature or request label Jul 5, 2023
@mrcjkb mrcjkb changed the title Show how to use in a flake check ? Support for nix checks Jul 5, 2023
@mrcjkb mrcjkb self-assigned this Jul 5, 2023
@bew
Copy link
Author

bew commented Jul 5, 2023

That interface looks good, maybe also with a name for the derivation name, this can be useful if making multiple kinds of tests or testing multiple plugins.

Could we also choose which neovim derivation to use?

@mrcjkb
Copy link
Member

mrcjkb commented Jul 5, 2023

That's a good idea.
By being able to pass in neovim, there's no need for the vimPlugins argument (since you can just pass in a neovim derivation with all the non-luarocks plugins installed).

@mrcjkb mrcjkb linked a pull request Aug 25, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants