-
Notifications
You must be signed in to change notification settings - Fork 1
/
lib.nix
39 lines (35 loc) · 920 Bytes
/
lib.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
{ flake-parts-lib, ... }:
with builtins;
let
inherit (flake-parts-lib) evalFlakeModule;
singleModuleBase = x: {
imports = [
./flake-modules/builtins/assertions.nix
x
];
};
evalAssertions = eval:
let
failedAssertions = map (x: x.message) (filter (x: !x.assertion) eval.config.assertions);
warnings = eval.config.warnings;
in
if (failedAssertions != [])
then
builtins.abort (concatStringsSep "\n\n" failedAssertions)
else
if (warnings != [])
then
builtins.trace (concatStringsSep "\n\n" warnings)
eval
else eval;
evalFlakeModuleWithAssertions = a: m:
evalAssertions (evalFlakeModule a (singleModuleBase m));
in
{
inherit evalFlakeModuleWithAssertions;
mkFlakeWithAssertions = args: module:
let
eval = evalFlakeModuleWithAssertions args module;
in
eval.config.flake;
}