Skip to content

Commit 9f4e740

Browse files
authored
build(nix): use gen-luarc framework (mrcjkb#263)
1 parent 4d8edfd commit 9f4e740

File tree

6 files changed

+137
-115
lines changed

6 files changed

+137
-115
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
doc/tags
22
result/
33
.direnv
4+
.luarc.json

.luarc.json

-3
This file was deleted.

flake.lock

+88-33
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

+45-67
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,11 @@
66

77
flake-parts.url = "github:hercules-ci/flake-parts";
88

9-
pre-commit-hooks = {
10-
url = "github:cachix/pre-commit-hooks.nix";
11-
};
9+
pre-commit-hooks.url = "github:cachix/pre-commit-hooks.nix";
1210

13-
neorocks = {
14-
url = "github:nvim-neorocks/neorocks";
15-
};
11+
neorocks.url = "github:nvim-neorocks/neorocks";
1612

17-
neodev-nvim = {
18-
url = "github:folke/neodev.nvim";
19-
flake = false;
20-
};
13+
gen-luarc.url = "github:mrcjkb/nix-gen-luarc-json";
2114
};
2215

2316
outputs = inputs @ {
@@ -26,7 +19,7 @@
2619
flake-parts,
2720
pre-commit-hooks,
2821
neorocks,
29-
neodev-nvim,
22+
gen-luarc,
3023
...
3124
}: let
3225
name = "rustaceanvim";
@@ -51,7 +44,6 @@
5144
ci-overlay = import ./nix/ci-overlay.nix {
5245
inherit
5346
self
54-
neodev-nvim
5547
;
5648
plugin-name = name;
5749
};
@@ -61,72 +53,55 @@
6153
overlays = [
6254
ci-overlay
6355
neorocks.overlays.default
56+
gen-luarc.overlays.default
6457
plugin-overlay
6558
];
6659
};
6760

68-
mkTypeCheck = {
69-
rtp ? [],
70-
disabled-diagnostics ? [],
71-
}:
72-
pre-commit-hooks.lib.${system}.run {
73-
src = self;
74-
hooks = {
75-
lua-ls.enable = true;
76-
};
77-
settings = {
78-
lua-ls = {
79-
config = {
80-
runtime.version = "LuaJIT";
81-
Lua = {
82-
workspace = {
83-
library =
84-
rtp
85-
++ (with pkgs.vimPlugins; [
86-
"${nvim-dap}/lua"
87-
"${toggleterm-nvim}/lua"
88-
"${neotest}/lua"
89-
"\${3rd}/busted/library"
90-
"\${3rd}/luassert/library"
91-
]);
92-
checkThirdParty = false;
93-
ignoreDir = [
94-
".git"
95-
".github"
96-
".direnv"
97-
"result"
98-
"nix"
99-
"doc"
100-
"spec" # FIXME: busted library
101-
];
102-
};
103-
diagnostics = {
104-
libraryFiles = "Disable";
105-
disable = disabled-diagnostics;
106-
};
107-
};
108-
};
109-
};
110-
};
111-
};
61+
luarc-plugins = with pkgs.lua51Packages;
62+
[
63+
nvim-nio
64+
]
65+
++ (with pkgs.vimPlugins; [
66+
neotest
67+
nvim-dap
68+
]);
69+
70+
luarc-nightly = pkgs.mk-luarc {
71+
nvim = pkgs.neovim-nightly;
72+
neodev-types = "nightly";
73+
plugins = luarc-plugins;
74+
};
11275

113-
type-check-stable = mkTypeCheck {
114-
rtp = [
115-
"${pkgs.neovim}/share/nvim/runtime/lua"
116-
"${pkgs.neodev-plugin}/types/stable"
117-
];
76+
luarc-stable = pkgs.mk-luarc {
77+
nvim = pkgs.neovim-unwrapped;
78+
neodev-types = "stable";
79+
plugins = luarc-plugins;
11880
disabled-diagnostics = [
11981
"undefined-doc-name"
12082
"redundant-parameter"
12183
"invisible"
12284
];
12385
};
12486

125-
type-check-nightly = mkTypeCheck {
126-
rtp = [
127-
"${pkgs.neovim-nightly}/share/nvim/runtime/lua"
128-
"${pkgs.neodev-plugin}/types/nightly"
129-
];
87+
type-check-nightly = pre-commit-hooks.lib.${system}.run {
88+
src = self;
89+
hooks = {
90+
lua-ls.enable = true;
91+
};
92+
settings = {
93+
lua-ls.config = luarc-nightly;
94+
};
95+
};
96+
97+
type-check-stable = pre-commit-hooks.lib.${system}.run {
98+
src = self;
99+
hooks = {
100+
lua-ls.enable = true;
101+
};
102+
settings = {
103+
lua-ls.config = luarc-stable;
104+
};
130105
};
131106

132107
pre-commit-check = pre-commit-hooks.lib.${system}.run {
@@ -142,7 +117,10 @@
142117

143118
devShell = pkgs.nvim-nightly-tests.overrideAttrs (oa: {
144119
name = "rustaceanvim devShell";
145-
inherit (pre-commit-check) shellHook;
120+
shellHook = ''
121+
${pre-commit-check.shellHook}
122+
ln -fs ${pkgs.luarc-to-json luarc-nightly} .luarc.json
123+
'';
146124
buildInputs = with pre-commit-hooks.packages.${system};
147125
[
148126
alejandra

0 commit comments

Comments
 (0)