mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-21 00:25:42 +02:00
Add a non-system specific `<flake>.lib.nixvim` output, which is equivalent to the existing `<flake>.lib.<system>.helpers` output. This is now also wrapped with `lib.makeOverridable` to allow overriding the function args used to construct the nixvim-lib. Consistently access nixvim-lib via the new flake output, overriding where necessary.
77 lines
2.3 KiB
Nix
77 lines
2.3 KiB
Nix
{
|
|
self,
|
|
pkgs,
|
|
lib ? pkgs.lib,
|
|
...
|
|
}:
|
|
let
|
|
defaultPkgs = pkgs;
|
|
|
|
# Create a nix derivation from a nixvim executable.
|
|
# The build phase simply consists in running the provided nvim binary.
|
|
mkTestDerivationFromNvim =
|
|
{
|
|
name,
|
|
nvim,
|
|
# TODO: Deprecated 2024-08-20, remove after 24.11
|
|
dontRun ? false,
|
|
...
|
|
}@args:
|
|
let
|
|
# FIXME: this doesn't support helpers.enableExceptInTests, a context option would be better
|
|
result = nvim.extend {
|
|
config.test =
|
|
{
|
|
inherit name;
|
|
}
|
|
// lib.optionalAttrs (args ? dontRun) (
|
|
lib.warn
|
|
"mkTestDerivationFromNvim: the `dontRun` argument is deprecated. You should use the `test.runNvim` module option instead."
|
|
{ runNvim = !dontRun; }
|
|
);
|
|
};
|
|
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 ? defaultPkgs,
|
|
module,
|
|
extraSpecialArgs ? { },
|
|
# TODO: Deprecated 2024-08-20, remove after 24.11
|
|
dontRun ? false,
|
|
}@args:
|
|
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;
|
|
};
|
|
|
|
result = helpers.modules.evalNixvim {
|
|
modules = [
|
|
module
|
|
(lib.optionalAttrs (name != null) { test.name = name; })
|
|
(lib.optionalAttrs (args ? dontRun) (
|
|
lib.warn
|
|
"mkTestDerivationFromNixvimModule: the `dontRun` argument is deprecated. You should use the `test.runNvim` module option instead."
|
|
{ config.test.runNvim = !dontRun; }
|
|
))
|
|
{ wrapRc = true; }
|
|
# TODO: Only do this when `args?pkgs`
|
|
# Consider deprecating the `pkgs` arg too...
|
|
{ nixpkgs.pkgs = lib.mkDefault pkgs; }
|
|
];
|
|
inherit extraSpecialArgs;
|
|
};
|
|
in
|
|
result.config.build.test;
|
|
in
|
|
# NOTE: this is exported publicly in the flake outputs as `lib.<system>.check`
|
|
{
|
|
inherit mkTestDerivationFromNvim mkTestDerivationFromNixvimModule;
|
|
}
|