-
Notifications
You must be signed in to change notification settings - Fork 2
/
flake.nix
148 lines (121 loc) · 4.01 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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
};
outputs = { self, nixpkgs }:
let
system = "x86_64-linux";
pkgs = import nixpkgs {
inherit system;
overlays = [ self.overlays.default ];
};
pname = "tree-sitter-dhall";
version = "0.2.0";
fileset = nixpkgs.lib.fileset.unions [
./grammar.js
./package.json
./package-lock.json
./src/scanner.c
./tree-sitter.json
];
src = nixpkgs.lib.fileset.toSource {
root = ./.;
inherit fileset;
};
meta = {
description = "Dhall grammar for the tree-sitter parsing library";
homepage = "https://github.com/jbellerb/tree-sitter-dhall";
license = nixpkgs.lib.licenses.mit;
platforms = nixpkgs.lib.platforms.linux;
};
in {
packages."${system}" = {
tree-sitter-dhall = pkgs.callPackage (
{ lib, stdenv, nodejs, tree-sitter }:
stdenv.mkDerivation {
inherit pname version src meta;
nativeBuildInputs = [ nodejs tree-sitter ];
buildPhase = "tree-sitter generate";
installPhase = ''
mkdir "$out"
mv src/ "$out"
'';
}
) {};
};
checks."${system}" = {
tree-sitter-dhall-test = pkgs.callPackage (
{ stdenv, tree-sitter, tree-sitter-dhall }:
stdenv.mkDerivation {
pname = "${pname}-test";
inherit version;
src = nixpkgs.lib.fileset.toSource {
root = ./.;
fileset = nixpkgs.lib.fileset.unions [
fileset
./binding.gyp
./bindings/node
./test/corpus
];
};
configurePhase = "cp -r ${tree-sitter-dhall}/src .";
buildPhase = ''
export HOME=$(mktemp -d)
${tree-sitter}/bin/tree-sitter test
'';
installPhase = "touch $out";
meta = meta // { description = "Check tree-sitter parser tests"; };
}
) {};
tree-sitter-dhall-prettier = pkgs.callPackage (
{ stdenvNoCC, nodePackages }:
stdenvNoCC.mkDerivation {
pname = "${pname}-prettier";
inherit version src;
nativeBuildInputs = [ nodePackages.prettier ];
buildPhase = "prettier --check .";
installPhase = "touch $out";
meta = meta // { description = "Check Prettier formatting"; };
}
) {};
tree-sitter-dhall-coverage = pkgs.callPackage (
{ lib, stdenvNoCC, fetchFromGitHub }:
let
dhall = fetchFromGitHub {
owner = "dhall-lang";
repo = "dhall-lang";
rev = "4fecb49a83caac4477d1e413fa6e4ee722b43b62";
hash = "sha256-VjOBG5kYY89njGpOxIpLFRK2mRP1UWr6QDOHtb7VMzE=";
};
missing = [
"builtinsA.dhall" # modified
"unit/ShebangA.dhall"
"unit/ShebangNixA.dhall"
"unit/TrailingLineCommentWithoutNewlineA.dhall"
];
in stdenvNoCC.mkDerivation {
pname = "${pname}-coverage";
inherit version src;
buildPhase = ''
${./tests.sh} -c ${test/corpus}\
-i ${lib.strings.concatStringsSep "," missing}\
${dhall}/tests/parser/success/
'';
installPhase = "touch $out";
meta = meta // { description = "Check test coverage"; };
}
) {};
};
overlays.default = final: prev: { } // self.packages."${system}";
devShells."${system}".default = pkgs.mkShell {
nativeBuildInputs = [
pkgs.nodejs
pkgs.nodePackages.node-gyp
pkgs.nodePackages.typescript-language-server
(pkgs.python3.withPackages(ps: [ ps.gyp ]))
pkgs.shellcheck
pkgs.tree-sitter
];
};
};
}