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
|
@ -20,32 +20,17 @@ rec {
|
|||
{
|
||||
modules ? [ ],
|
||||
extraSpecialArgs ? { },
|
||||
# Set to false to disable warnings and assertions
|
||||
# Intended to aid accessing config.test.derivation
|
||||
# WARNING: This argument may be removed without notice:
|
||||
check ? true,
|
||||
}:
|
||||
let
|
||||
result = lib.evalModules {
|
||||
modules = [ ../modules/top-level ] ++ modules;
|
||||
specialArgs = specialArgsWith extraSpecialArgs;
|
||||
};
|
||||
check ? null, # TODO: Remove stub
|
||||
}@args:
|
||||
# TODO: `check` argument removed 2024-09-24
|
||||
# NOTE: this argument was always marked as experimental
|
||||
assert lib.assertMsg (!args ? "check")
|
||||
"`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.";
|
||||
lib.evalModules {
|
||||
modules = [ ../modules/top-level ] ++ modules;
|
||||
specialArgs = specialArgsWith extraSpecialArgs;
|
||||
};
|
||||
|
||||
failedAssertions = getAssertionMessages result.config.assertions;
|
||||
|
||||
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))
|
||||
];
|
||||
# TODO: Removed 2024-09-24
|
||||
getAssertionMessages = throw "`modules.getAssertionMessages` has been removed.";
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue