-
Notifications
You must be signed in to change notification settings - Fork 10
/
flake.nix
107 lines (97 loc) · 2.85 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
{
inputs = {
flake-utils.url = "github:numtide/flake-utils";
nixpkgs = {
url = "github:NixOS/nixpkgs/nixos-unstable";
};
pre-commit-hooks = {
url = "github:cachix/pre-commit-hooks.nix";
inputs = {
nixpkgs.follows = "nixpkgs";
};
};
};
outputs = {
self,
nixpkgs,
flake-utils,
pre-commit-hooks,
}:
{}
// flake-utils.lib.eachDefaultSystem
(
system: let
pkgs = import nixpkgs {
inherit system;
#overlays = [self.overlays.default];
};
tree-sitter-env = pkgs.stdenv.mkDerivation {
name = "tree-sitter-env";
nativeBuildInputs = with pkgs; [
makeWrapper
];
dontUnpack = true;
dontBuild = true;
installPhase = ''
mkdir -p $out/bin
makeWrapper \
${pkgs.tree-sitter}/bin/tree-sitter \
$out/bin/tree-sitter \
--prefix PATH : "${with pkgs; lib.makeBinPath [stdenv.cc nodejs]}"
'';
};
in rec {
checks = {
pre-commit = pre-commit-hooks.lib.${system}.run {
src = ./.;
hooks = {
# clang-format = {
# enable = true;
# name = "clang-format";
# entry = "${pkgs.clang-tools}/bin/clang-format -style=file -i";
# types = ["text" "c"];
# # I don't care for generated files' formatting
# excludes = ["src/parser.c" "src/tree_sitter/parser.h"];
# language = "system";
# };
alejandra.enable = true;
tree-sitter = {
enable = true;
name = "tree-sitter tests";
entry = "${tree-sitter-env}/bin/tree-sitter test";
pass_filenames = false;
};
# tree-sitter-files = {
# enable = true;
# name = "tree-sitter generated files";
# entry = "${tree-sitter-env}/bin/tree-sitter generate --no-bindings";
# pass_filenames = false;
# };
};
};
};
devShells = {
default = pkgs.mkShell {
nativeBuildInputs = with pkgs; [
nodejs
nodePackages.node-gyp
# broken (tree-sitter.override {webUISupport = true;})
tree-sitter
cargo
];
inherit (checks.pre-commit) shellHook;
};
};
packages = {
default = packages.tree-sitter-beancount;
tree-sitter-beancount = pkgs.tree-sitter.buildGrammar {
language = "beancount";
generate = true;
src = ./.;
version = "n/a";
};
inherit (pkgs) tree-sitter;
};
}
);
}