Skip to content

Commit 5be521c

Browse files
committed
refactor(wrapperModules.neovim): light refactor to normalization logic
1 parent a351f98 commit 5be521c

File tree

2 files changed

+51
-54
lines changed

2 files changed

+51
-54
lines changed

wrapperModules/n/neovim/default-config.nix

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -354,12 +354,14 @@
354354
config.binName = "neovim-ruby-host";
355355
};
356356
config.extraPackages =
357-
lib.mkIf (config.hosts.ruby.nvim-host.enable || config.hosts.node.nvim-host.enable)
357+
lib.mkIf
358+
(config.hosts.ruby.nvim-host.enable or false || config.hosts.node.nvim-host.enable or false)
358359
(
359-
lib.optional config.hosts.ruby.nvim-host.enable config.hosts.ruby.wrapper
360-
++ lib.optional config.hosts.node.nvim-host.enable pkgs.nodejs
360+
lib.optional (config.hosts.ruby.nvim-host.enable or false) config.hosts.ruby.wrapper
361+
++ lib.optional (config.hosts.node.nvim-host.enable or false) pkgs.nodejs
361362
);
362-
config.env.GEM_HOME = lib.mkIf (config.hosts.ruby.nvim-host.enable) "${config.hosts.ruby.package}/${config.hosts.ruby.package.ruby.gemPath}";
363+
config.env.GEM_HOME = lib.mkIf (config.hosts.ruby.nvim-host.enable or false
364+
) "${config.hosts.ruby.package}/${config.hosts.ruby.package.ruby.gemPath or pkgs.ruby.gemPath}";
363365
config.hosts.neovide =
364366
{
365367
lib,

wrapperModules/n/neovim/normalize.nix

Lines changed: 45 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -9,55 +9,49 @@
99
...
1010
}:
1111
let
12-
mappedSpecs =
13-
let
14-
initialList =
15-
let
16-
pluginList = lib.pipe specs [
17-
(lib.mapAttrsToList (
18-
name: value:
19-
if builtins.isList value.data then
20-
{
21-
inherit name value;
22-
type = "parent";
23-
}
24-
else
25-
{
26-
inherit name value;
27-
type = "spec";
28-
}
29-
))
30-
(lib.concatMap (
31-
item:
32-
if item.type == "parent" then
33-
[
34-
(
35-
item
36-
// {
37-
value = item.value // {
38-
data = null;
39-
};
40-
}
41-
)
42-
]
43-
++ map (child: {
44-
name = item.name;
45-
value = child;
46-
type = "spec";
47-
}) item.value.data
48-
else
49-
[ item ]
50-
))
51-
];
52-
mappingFunctions = lib.pipe specMaps [
53-
(wlib.dag.unwrapSort "specMaps DAL")
54-
(builtins.filter (v: (v.enable or true)))
55-
(map (v: v.data))
56-
];
57-
in
58-
lib.pipe pluginList mappingFunctions;
59-
in
60-
lib.pipe initialList [
12+
mappedSpecs = lib.pipe specs (
13+
[
14+
(lib.mapAttrsToList (
15+
name: value:
16+
if builtins.isList value.data then
17+
{
18+
inherit name value;
19+
type = "parent";
20+
}
21+
else
22+
{
23+
inherit name value;
24+
type = "spec";
25+
}
26+
))
27+
(lib.concatMap (
28+
item:
29+
if item.type == "parent" then
30+
[
31+
(
32+
item
33+
// {
34+
value = item.value // {
35+
data = null;
36+
};
37+
}
38+
)
39+
]
40+
++ map (child: {
41+
name = item.name;
42+
value = child;
43+
type = "spec";
44+
}) item.value.data
45+
else
46+
[ item ]
47+
))
48+
]
49+
++ (lib.pipe specMaps [
50+
(wlib.dag.unwrapSort "specMaps DAL")
51+
(builtins.filter (v: (v.enable or true)))
52+
(map (v: v.data))
53+
])
54+
++ [
6155
(builtins.filter (v: v ? name && v ? value && v ? type))
6256
(lib.partition (v: v.type == "parent"))
6357
(
@@ -146,7 +140,8 @@ let
146140
)
147141
(builtins.filter (v: if v ? enable then v.enable else true))
148142
(wlib.dag.unwrapSort "config and plugin DAG")
149-
];
143+
]
144+
);
150145

151146
getNameFromSpec =
152147
v:

0 commit comments

Comments
 (0)