mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-21 00:25:42 +02:00
modules/output: check warnings+assertions on build.package
Add a `build.packageUnchecked` option for use instead of the old `check` evalNixvim argument.
This commit is contained in:
parent
2ea7009e61
commit
6a1bf6bdc3
9 changed files with 50 additions and 48 deletions
|
@ -15,7 +15,6 @@
|
||||||
extraSpecialArgs = {
|
extraSpecialArgs = {
|
||||||
defaultPkgs = pkgs;
|
defaultPkgs = pkgs;
|
||||||
};
|
};
|
||||||
check = false;
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -20,32 +20,17 @@ rec {
|
||||||
{
|
{
|
||||||
modules ? [ ],
|
modules ? [ ],
|
||||||
extraSpecialArgs ? { },
|
extraSpecialArgs ? { },
|
||||||
# Set to false to disable warnings and assertions
|
check ? null, # TODO: Remove stub
|
||||||
# Intended to aid accessing config.test.derivation
|
}@args:
|
||||||
# WARNING: This argument may be removed without notice:
|
# TODO: `check` argument removed 2024-09-24
|
||||||
check ? true,
|
# NOTE: this argument was always marked as experimental
|
||||||
}:
|
assert lib.assertMsg (!args ? "check")
|
||||||
let
|
"`evalNixvim`: passing `check` is no longer supported. Checks are now done when evaluating `config.build.package` and can be avoided by using `config.build.packageUnchecked` instead.";
|
||||||
result = lib.evalModules {
|
lib.evalModules {
|
||||||
modules = [ ../modules/top-level ] ++ modules;
|
modules = [ ../modules/top-level ] ++ modules;
|
||||||
specialArgs = specialArgsWith extraSpecialArgs;
|
specialArgs = specialArgsWith extraSpecialArgs;
|
||||||
};
|
};
|
||||||
|
|
||||||
failedAssertions = getAssertionMessages result.config.assertions;
|
# TODO: Removed 2024-09-24
|
||||||
|
getAssertionMessages = throw "`modules.getAssertionMessages` has been removed.";
|
||||||
checked =
|
|
||||||
if failedAssertions != [ ] then
|
|
||||||
throw "\nFailed assertions:\n${lib.concatStringsSep "\n" (map (x: "- ${x}") failedAssertions)}"
|
|
||||||
else
|
|
||||||
lib.showWarnings result.config.warnings result;
|
|
||||||
in
|
|
||||||
if check then checked else result;
|
|
||||||
|
|
||||||
# Return the messages for all assertions that failed
|
|
||||||
getAssertionMessages =
|
|
||||||
assertions:
|
|
||||||
lib.pipe assertions [
|
|
||||||
(lib.filter (x: !x.assertion))
|
|
||||||
(lib.map (x: x.message))
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,9 +66,6 @@ let
|
||||||
extraSpecialArgs = {
|
extraSpecialArgs = {
|
||||||
defaultPkgs = pkgs;
|
defaultPkgs = pkgs;
|
||||||
} // extraSpecialArgs;
|
} // extraSpecialArgs;
|
||||||
# Don't check assertions/warnings while evaluating nixvim config
|
|
||||||
# We'll let the test derivation handle that
|
|
||||||
check = false;
|
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
result.config.build.test;
|
result.config.build.test;
|
||||||
|
|
|
@ -73,7 +73,30 @@ in
|
||||||
|
|
||||||
package = mkOption {
|
package = mkOption {
|
||||||
type = types.package;
|
type = types.package;
|
||||||
description = "Wrapped Neovim.";
|
description = ''
|
||||||
|
Wrapped Neovim.
|
||||||
|
|
||||||
|
> [!NOTE]
|
||||||
|
> Evaluating this option will also check `assertions` and print any `warnings`.
|
||||||
|
> If this is not desired, you can use `build.packageUnchecked` instead.
|
||||||
|
'';
|
||||||
|
readOnly = true;
|
||||||
|
defaultText = lib.literalExpression "config.build.packageUnchecked";
|
||||||
|
apply =
|
||||||
|
let
|
||||||
|
assertions = builtins.concatMap (x: lib.optional (!x.assertion) x.message) config.assertions;
|
||||||
|
in
|
||||||
|
if assertions != [ ] then
|
||||||
|
throw "\nFailed assertions:\n${lib.concatMapStringsSep "\n" (msg: "- ${msg}") assertions}"
|
||||||
|
else
|
||||||
|
lib.showWarnings config.warnings;
|
||||||
|
};
|
||||||
|
|
||||||
|
packageUnchecked = mkOption {
|
||||||
|
type = types.package;
|
||||||
|
description = ''
|
||||||
|
Wrapped Neovim (without checking warnings or assertions).
|
||||||
|
'';
|
||||||
readOnly = true;
|
readOnly = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -317,7 +340,8 @@ in
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
build = {
|
build = {
|
||||||
package = wrappedNeovim;
|
package = config.build.packageUnchecked;
|
||||||
|
packageUnchecked = wrappedNeovim;
|
||||||
inherit initFile initSource;
|
inherit initFile initSource;
|
||||||
|
|
||||||
printInitPackage = pkgs.writeShellApplication {
|
printInitPackage = pkgs.writeShellApplication {
|
||||||
|
|
|
@ -9,7 +9,7 @@ let
|
||||||
cfg = config.test;
|
cfg = config.test;
|
||||||
|
|
||||||
inherit (config) warnings;
|
inherit (config) warnings;
|
||||||
assertions = lib.nixvim.modules.getAssertionMessages config.assertions;
|
assertions = builtins.concatMap (x: lib.optional (!x.assertion) x.message) config.assertions;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
options.test = {
|
options.test = {
|
||||||
|
@ -70,7 +70,7 @@ in
|
||||||
build.test =
|
build.test =
|
||||||
pkgs.runCommandNoCCLocal cfg.name
|
pkgs.runCommandNoCCLocal cfg.name
|
||||||
{
|
{
|
||||||
nativeBuildInputs = [ config.build.package ];
|
nativeBuildInputs = [ config.build.packageUnchecked ];
|
||||||
|
|
||||||
# Allow inspecting the test's module a little from the repl
|
# Allow inspecting the test's module a little from the repl
|
||||||
# e.g.
|
# e.g.
|
||||||
|
|
|
@ -33,7 +33,7 @@ in
|
||||||
'';
|
'';
|
||||||
assertions = [
|
assertions = [
|
||||||
{
|
{
|
||||||
assertion = pluginCount config.build.package config.build.extraFiles "start" == 1;
|
assertion = pluginCount config.build.packageUnchecked config.build.extraFiles "start" == 1;
|
||||||
message = "More than one plugin is defined in packpathDirs, expected one plugin pack.";
|
message = "More than one plugin is defined in packpathDirs, expected one plugin pack.";
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
@ -50,7 +50,7 @@ in
|
||||||
];
|
];
|
||||||
assertions = [
|
assertions = [
|
||||||
{
|
{
|
||||||
assertion = pluginCount config.build.package config.build.extraFiles "start" >= 2;
|
assertion = pluginCount config.build.packageUnchecked config.build.extraFiles "start" >= 2;
|
||||||
message = "Only one plugin is defined in packpathDirs, expected at least two.";
|
message = "Only one plugin is defined in packpathDirs, expected at least two.";
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
@ -77,7 +77,7 @@ in
|
||||||
'';
|
'';
|
||||||
assertions = [
|
assertions = [
|
||||||
{
|
{
|
||||||
assertion = pluginCount config.build.package config.build.extraFiles "start" == 1;
|
assertion = pluginCount config.build.packageUnchecked config.build.extraFiles "start" == 1;
|
||||||
message = "More than one plugin is defined in packpathDirs.";
|
message = "More than one plugin is defined in packpathDirs.";
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
@ -105,7 +105,7 @@ in
|
||||||
'';
|
'';
|
||||||
assertions = [
|
assertions = [
|
||||||
{
|
{
|
||||||
assertion = pluginCount config.build.package config.build.extraFiles "start" == 1;
|
assertion = pluginCount config.build.packageUnchecked config.build.extraFiles "start" == 1;
|
||||||
message = "More than one plugin is defined in packpathDirs.";
|
message = "More than one plugin is defined in packpathDirs.";
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
@ -132,7 +132,7 @@ in
|
||||||
'';
|
'';
|
||||||
assertions = [
|
assertions = [
|
||||||
{
|
{
|
||||||
assertion = pluginCount config.build.package config.build.extraFiles "start" == 1;
|
assertion = pluginCount config.build.packageUnchecked config.build.extraFiles "start" == 1;
|
||||||
message = "More than one plugin is defined in packpathDirs.";
|
message = "More than one plugin is defined in packpathDirs.";
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
@ -186,11 +186,11 @@ in
|
||||||
'';
|
'';
|
||||||
assertions = [
|
assertions = [
|
||||||
{
|
{
|
||||||
assertion = pluginCount config.build.package config.build.extraFiles "start" == 1;
|
assertion = pluginCount config.build.packageUnchecked config.build.extraFiles "start" == 1;
|
||||||
message = "More than one start plugin is defined in packpathDirs";
|
message = "More than one start plugin is defined in packpathDirs";
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
assertion = pluginCount config.build.package config.build.extraFiles "opt" == 2;
|
assertion = pluginCount config.build.packageUnchecked config.build.extraFiles "opt" == 2;
|
||||||
message = "Less than two opt plugins are defined in packpathDirs";
|
message = "Less than two opt plugins are defined in packpathDirs";
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
@ -233,7 +233,7 @@ in
|
||||||
'';
|
'';
|
||||||
assertions = [
|
assertions = [
|
||||||
{
|
{
|
||||||
assertion = pluginCount config.build.package config.build.extraFiles "start" == 1;
|
assertion = pluginCount config.build.packageUnchecked config.build.extraFiles "start" == 1;
|
||||||
message = "More than one start plugin is defined in packpathDirs";
|
message = "More than one start plugin is defined in packpathDirs";
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
@ -303,7 +303,7 @@ in
|
||||||
'';
|
'';
|
||||||
assertions = [
|
assertions = [
|
||||||
{
|
{
|
||||||
assertion = pluginCount config.build.package config.build.extraFiles "start" == 1;
|
assertion = pluginCount config.build.packageUnchecked config.build.extraFiles "start" == 1;
|
||||||
message = "More than one start plugin is defined in packpathDirs";
|
message = "More than one start plugin is defined in packpathDirs";
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
@ -369,7 +369,7 @@ in
|
||||||
assertions = [
|
assertions = [
|
||||||
{
|
{
|
||||||
# plugin-pack, nvim-treesitter, nvim-lspconfig, telescope-nvim, nvim-cmp
|
# plugin-pack, nvim-treesitter, nvim-lspconfig, telescope-nvim, nvim-cmp
|
||||||
assertion = pluginCount config.build.package config.build.extraFiles "start" == 5;
|
assertion = pluginCount config.build.packageUnchecked config.build.extraFiles "start" == 5;
|
||||||
message = "Wrong number of plugins in packpathDirs";
|
message = "Wrong number of plugins in packpathDirs";
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
|
@ -24,7 +24,6 @@ let
|
||||||
modules = [
|
modules = [
|
||||||
./modules/darwin.nix
|
./modules/darwin.nix
|
||||||
];
|
];
|
||||||
check = false;
|
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
|
|
|
@ -31,7 +31,6 @@ let
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
check = false;
|
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
|
|
|
@ -24,7 +24,6 @@ let
|
||||||
modules = [
|
modules = [
|
||||||
./modules/nixos.nix
|
./modules/nixos.nix
|
||||||
];
|
];
|
||||||
check = false;
|
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue