-
Notifications
You must be signed in to change notification settings - Fork 1
/
flake.nix
118 lines (112 loc) · 2.86 KB
/
flake.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
{
description = "devShell for Lua projects";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
flake-parts.url = "github:hercules-ci/flake-parts";
gen-luarc.url = "github:mrcjkb/nix-gen-luarc-json";
pre-commit-hooks.url = "github:cachix/pre-commit-hooks.nix";
};
outputs = inputs @ {
self,
nixpkgs,
flake-parts,
gen-luarc,
pre-commit-hooks,
...
}:
flake-parts.lib.mkFlake {inherit inputs;} {
systems = [
"x86_64-linux"
"x86_64-darwin"
"aarch64-darwin"
];
perSystem = {
config,
self',
inputs',
pkgs,
system,
...
}: let
pkgs = import nixpkgs {
inherit system;
overlays = [
gen-luarc.overlays.default
(import ./nix/overlay.nix {inherit self;})
];
};
luarc = pkgs.mk-luarc {
plugins = with pkgs.lua51Packages; [
luarocks
];
};
type-check = pre-commit-hooks.lib.${system}.run {
src = self;
hooks = {
lua-ls = {
enable = true;
settings.configuration = luarc;
};
};
};
pre-commit-check = pre-commit-hooks.lib.${system}.run {
src = self;
hooks = {
alejandra.enable = true;
stylua.enable = true;
luacheck.enable = true;
editorconfig-checker.enable = true;
};
};
in {
devShells.default = pkgs.mkShell {
name = "lua devShell";
shellHook = ''
${pre-commit-check.shellHook}
ln -fs ${pkgs.luarc-to-json luarc} .luarc.json
'';
buildInputs = with pre-commit-hooks.packages.${system};
[
alejandra
lua-language-server
stylua
luacheck
]
++ (with pkgs; [
(lua5_1.withPackages (ps: with ps; [luarocks luarocks-build-treesitter-parser]))
tree-sitter
]);
};
legacyPackages.fixtures = {
inherit
(pkgs.lua51Packages)
tree-sitter-haskell
tree-sitter-rust
tree-sitter-ocamllex
tree-sitter-xml
tree-sitter-toml
tree-sitter-latex
tree-sitter-norg
tree-sitter-html_tags
;
};
checks = {
inherit
pre-commit-check
type-check
;
inherit
(pkgs.lua51Packages)
tree-sitter-haskell
tree-sitter-rust
tree-sitter-ocamllex
tree-sitter-xml
tree-sitter-toml
tree-sitter-latex
tree-sitter-norg
tree-sitter-html_tags
;
};
};
};
}