2024-08-02 01:26:01 +01:00
|
|
|
{
|
|
|
|
lib,
|
2024-09-12 14:56:36 +01:00
|
|
|
self,
|
2024-08-02 01:26:01 +01:00
|
|
|
}:
|
|
|
|
rec {
|
|
|
|
# Build specialArgs for evaluating nixvim modules
|
|
|
|
specialArgsWith =
|
2024-09-12 14:56:36 +01:00
|
|
|
# TODO: switch defaultPkgs -> pkgsPath (i.e. pkgs.path or inputs.nixvim)
|
|
|
|
# FIXME: Ideally, we should not require callers to pass in _anything_ specific
|
|
|
|
{ defaultPkgs, ... }@extraSpecialArgs:
|
2024-08-02 01:26:01 +01:00
|
|
|
{
|
2024-09-12 14:56:36 +01:00
|
|
|
inherit lib defaultPkgs;
|
2024-08-02 01:26:01 +01:00
|
|
|
# TODO: deprecate `helpers`
|
2024-09-12 14:56:36 +01:00
|
|
|
helpers = self;
|
2024-08-02 01:26:01 +01:00
|
|
|
}
|
|
|
|
// extraSpecialArgs;
|
2024-08-04 21:54:17 +01:00
|
|
|
|
|
|
|
# Evaluate nixvim modules, checking warnings and assertions
|
|
|
|
evalNixvim =
|
|
|
|
{
|
|
|
|
modules ? [ ],
|
|
|
|
extraSpecialArgs ? { },
|
|
|
|
# Set to false to disable warnings and assertions
|
2024-08-05 12:21:24 +01:00
|
|
|
# Intended to aid accessing config.test.derivation
|
2024-08-04 21:54:17 +01:00
|
|
|
# WARNING: This argument may be removed without notice:
|
|
|
|
check ? true,
|
|
|
|
}:
|
|
|
|
let
|
|
|
|
result = 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))
|
|
|
|
];
|
2024-08-02 01:26:01 +01:00
|
|
|
}
|