mirror of
https://github.com/nix-community/nixvim.git
synced 2025-11-21 17:59:41 +01:00
lib: move enableExceptInTests impl to build.test option
Simplify the `enableExceptInTests` attribute, removing the `_nixvimTests` argument. We now do a full re-eval of the nixvim configuration before building the test, giving us a central place to implement `enableExceptInTests` and its eventual replacement(s). This extends support for `enableExceptInTests` to all methods of getting a nixvim test derivation. Previously, it only worked when using `mkTestDerivationFromNixvimModule`. In `tests/main.nix`, we avoid the re-eval by doing the initial eval with a "test mode" lib from the start.
This commit is contained in:
parent
7754b4eb1b
commit
8d0ca9abc4
7 changed files with 57 additions and 31 deletions
|
|
@ -2,7 +2,6 @@
|
|||
lib,
|
||||
flake,
|
||||
_isExtended ? false,
|
||||
_nixvimTests ? false,
|
||||
}:
|
||||
lib.makeExtensible (
|
||||
self:
|
||||
|
|
@ -25,7 +24,7 @@ lib.makeExtensible (
|
|||
modules = call ./modules.nix { inherit flake; };
|
||||
options = call ./options.nix { };
|
||||
plugins = call ./plugins { };
|
||||
utils = call ./utils.nix { inherit _nixvimTests; } // call ./utils.internal.nix { };
|
||||
utils = call ./utils.nix { } // call ./utils.internal.nix { };
|
||||
|
||||
# Top-level helper aliases:
|
||||
# TODO: deprecate some aliases
|
||||
|
|
|
|||
|
|
@ -15,7 +15,6 @@ let
|
|||
...
|
||||
}:
|
||||
let
|
||||
# FIXME: this doesn't support helpers.enableExceptInTests, a context option would be better
|
||||
result = nvim.extend {
|
||||
config.test = {
|
||||
inherit name;
|
||||
|
|
@ -35,20 +34,13 @@ let
|
|||
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 {
|
||||
result = self.lib.evalNixvim {
|
||||
modules = [
|
||||
module
|
||||
(lib.optionalAttrs (name != null) { test.name = name; })
|
||||
|
|
|
|||
|
|
@ -1,7 +1,4 @@
|
|||
{
|
||||
lib,
|
||||
_nixvimTests,
|
||||
}:
|
||||
{ lib }:
|
||||
rec {
|
||||
/**
|
||||
Transforms a list to an _"unkeyed"_ attribute set.
|
||||
|
|
@ -23,15 +20,14 @@ rec {
|
|||
builtins.listToAttrs (lib.lists.imap0 (idx: lib.nameValuePair "__unkeyed-${toString idx}") list);
|
||||
|
||||
/**
|
||||
Usually `true`, except when nixvim is being evaluated by
|
||||
`mkTestDerivationFromNixvimModule`, where it is `false`.
|
||||
Usually `true`, except within the `build.test` option, where it is `false`.
|
||||
|
||||
This can be used to dynamically enable plugins that can't be run in the
|
||||
test environment.
|
||||
*/
|
||||
# TODO: replace and deprecate
|
||||
# We shouldn't need to use another instance of `lib` when building a test drv
|
||||
enableExceptInTests = !_nixvimTests;
|
||||
enableExceptInTests = true;
|
||||
|
||||
/**
|
||||
An empty lua table `{ }` that will be included in the final lua configuration.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue