mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-23 17:28:39 +02:00
In our basic template we used to provide a check based on `mkTestDerivationFromNvim`. The issue with this check (that is handled correctly internally) is that some plugins _can't_ be used in the test environment, for example image.nvim like in #1085. This commit introduces a new function to generate such checks, `mkTestDerivationFromNixvimModule`, that wraps a nixvim configuration instead of a built nvim instance. Then a configuration can rely on the newly added `helpers.enableExceptInTests` attribute to disable parts of the configuration depending if it is evaluated in tests or in a real final configuration. Resolves #1085
51 lines
1.1 KiB
Nix
51 lines
1.1 KiB
Nix
default_pkgs: {
|
|
modules,
|
|
self,
|
|
getHelpers,
|
|
}: {
|
|
pkgs ? default_pkgs,
|
|
extraSpecialArgs ? {},
|
|
_nixvimTests ? false,
|
|
module,
|
|
}: let
|
|
inherit (pkgs) lib;
|
|
|
|
helpers = getHelpers pkgs _nixvimTests;
|
|
shared = import ./_shared.nix {inherit modules helpers;} {
|
|
inherit pkgs lib;
|
|
config = {};
|
|
};
|
|
|
|
eval = lib.evalModules {
|
|
modules =
|
|
[
|
|
module
|
|
{wrapRc = true;}
|
|
]
|
|
++ shared.topLevelModules;
|
|
specialArgs =
|
|
{
|
|
inherit helpers;
|
|
}
|
|
// extraSpecialArgs;
|
|
};
|
|
|
|
handleAssertions = config: let
|
|
failedAssertions = map (x: x.message) (lib.filter (x: !x.assertion) config.assertions);
|
|
in
|
|
if failedAssertions != []
|
|
then throw "\nFailed assertions:\n${builtins.concatStringsSep "\n" (map (x: "- ${x}") failedAssertions)}"
|
|
else lib.showWarnings config.warnings config;
|
|
|
|
config = handleAssertions eval.config;
|
|
in
|
|
pkgs.symlinkJoin {
|
|
name = "nixvim";
|
|
paths =
|
|
[
|
|
config.finalPackage
|
|
config.printInitPackage
|
|
]
|
|
++ pkgs.lib.optional config.enableMan self.packages.${pkgs.system}.man-docs;
|
|
meta.mainProgram = "nvim";
|
|
}
|