forked from nix-community/nixvim
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstandalone.nix
71 lines (67 loc) · 1.45 KB
/
standalone.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
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 = { };
};
mkEval =
mod:
lib.evalModules {
modules = [
mod
{ 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;
mkNvim =
mod:
let
evaledModule = mkEval mod;
config = handleAssertions evaledModule.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";
})
// {
inherit config;
inherit (evaledModule) options;
nixvimExtend =
extension:
mkNvim {
imports = [
mod
extension
];
};
};
in
mkNvim module