mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-20 16:15:43 +02:00
66 lines
1.6 KiB
Nix
66 lines
1.6 KiB
Nix
{
|
|
self,
|
|
system,
|
|
lib,
|
|
}:
|
|
let
|
|
defaultSystem = system;
|
|
|
|
# Create a nix derivation from a nixvim executable.
|
|
# The build phase simply consists in running the provided nvim binary.
|
|
mkTestDerivationFromNvim =
|
|
{
|
|
name,
|
|
nvim,
|
|
...
|
|
}:
|
|
let
|
|
# FIXME: this doesn't support helpers.enableExceptInTests, a context option would be better
|
|
result = nvim.extend {
|
|
config.test = {
|
|
inherit name;
|
|
};
|
|
};
|
|
in
|
|
result.config.build.test;
|
|
|
|
# Create a nix derivation from a nixvim configuration.
|
|
# The build phase simply consists in running neovim with the given configuration.
|
|
mkTestDerivationFromNixvimModule =
|
|
{
|
|
name ? null,
|
|
pkgs ? null,
|
|
system ? defaultSystem,
|
|
module,
|
|
extraSpecialArgs ? { },
|
|
}:
|
|
let
|
|
# NOTE: we are importing this just for evalNixvim
|
|
helpers = self.lib.nixvim.override {
|
|
# TODO: deprecate helpers.enableExceptInTests,
|
|
# add a context option e.g. `config.isTest`?
|
|
_nixvimTests = true;
|
|
};
|
|
|
|
systemMod =
|
|
if pkgs == null then
|
|
{ nixpkgs.hostPlatform = lib.mkDefault { inherit system; }; }
|
|
else
|
|
{ nixpkgs.pkgs = lib.mkDefault pkgs; };
|
|
|
|
result = helpers.modules.evalNixvim {
|
|
modules = [
|
|
module
|
|
(lib.optionalAttrs (name != null) { test.name = name; })
|
|
{ wrapRc = true; }
|
|
systemMod
|
|
];
|
|
inherit extraSpecialArgs;
|
|
};
|
|
in
|
|
result.config.build.test;
|
|
in
|
|
# NOTE: this is exported publicly in the flake outputs as `lib.<system>.check`
|
|
{
|
|
inherit mkTestDerivationFromNvim mkTestDerivationFromNixvimModule;
|
|
}
|