2022-06-01 16:15:54 +02:00
|
|
|
{
|
|
|
|
description = "A tree-sitter grammar for Tiger";
|
|
|
|
|
|
|
|
inputs = {
|
|
|
|
flake-utils = {
|
|
|
|
type = "github";
|
|
|
|
owner = "numtide";
|
|
|
|
repo = "flake-utils";
|
|
|
|
ref = "master";
|
|
|
|
};
|
|
|
|
|
|
|
|
nixpkgs = {
|
|
|
|
type = "github";
|
|
|
|
owner = "NixOS";
|
|
|
|
repo = "nixpkgs";
|
|
|
|
ref = "nixpkgs-unstable";
|
|
|
|
};
|
|
|
|
|
|
|
|
pre-commit-hooks = {
|
|
|
|
type = "github";
|
|
|
|
owner = "cachix";
|
|
|
|
repo = "pre-commit-hooks.nix";
|
|
|
|
ref = "master";
|
|
|
|
inputs = {
|
|
|
|
flake-utils.follows = "flake-utils";
|
|
|
|
nixpkgs.follows = "nixpkgs";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
outputs =
|
|
|
|
{ self
|
|
|
|
, flake-utils
|
|
|
|
, nixpkgs
|
|
|
|
, pre-commit-hooks
|
|
|
|
}:
|
2022-06-03 14:45:09 +02:00
|
|
|
let
|
|
|
|
inherit (flake-utils.lib) eachSystem system;
|
|
|
|
|
|
|
|
mySystems = [
|
|
|
|
system.aarch64-darwin
|
|
|
|
system.aarch64-linux
|
|
|
|
system.x86_64-darwin
|
|
|
|
system.x86_64-linux
|
|
|
|
];
|
|
|
|
|
|
|
|
eachMySystem = eachSystem mySystems;
|
|
|
|
in
|
|
|
|
eachMySystem
|
2022-06-01 16:15:54 +02:00
|
|
|
(system:
|
|
|
|
let
|
|
|
|
pkgs = import nixpkgs {
|
|
|
|
inherit system;
|
2022-06-03 14:48:15 +02:00
|
|
|
overlays = [ self.overlays.default ];
|
2022-06-01 16:15:54 +02:00
|
|
|
};
|
2022-06-03 15:56:32 +02:00
|
|
|
|
2022-06-13 10:03:40 +02:00
|
|
|
nvim-test = pkgs.writeShellScriptBin "nvim-test" ''
|
|
|
|
export NVIM_PLENARY='${pkgs.vimPlugins.plenary-nvim}'
|
|
|
|
export NVIM_TREESITTER='${pkgs.vimPlugins.nvim-treesitter}'
|
|
|
|
|
|
|
|
${pkgs.neovim}/bin/nvim --headless --noplugin -u scripts/minimal_init.lua \
|
|
|
|
-c "PlenaryBustedDirectory test/ { minimal_init = './scripts/minimal_init.lua' }"
|
|
|
|
'';
|
|
|
|
|
2022-06-13 13:40:12 +02:00
|
|
|
bump-version = pkgs.writeShellScriptBin "bump-version" ''
|
2022-06-13 13:43:12 +02:00
|
|
|
set -eu
|
|
|
|
|
2022-06-13 13:40:12 +02:00
|
|
|
NEW_VERSION="''${1}"
|
|
|
|
|
|
|
|
${pkgs.jq}/bin/jq ".version = \"''${NEW_VERSION}\"" package.json > package.json.tmp
|
|
|
|
mv package.json.tmp package.json
|
|
|
|
${pkgs.gnused}/bin/sed -i -e "s/version = \"[0-9.]\\+\"/version = \"''${NEW_VERSION}\"/" Cargo.toml
|
|
|
|
|
|
|
|
git add Cargo.toml package.json
|
2022-06-13 13:43:12 +02:00
|
|
|
echo "Release ''${NEW_VERSION}" | git commit -eF -
|
2022-06-13 13:40:12 +02:00
|
|
|
git tag -a "v''${NEW_VERSION}" -m "Release ''${NEW_VERSION}"
|
|
|
|
'';
|
|
|
|
|
2022-06-03 15:56:32 +02:00
|
|
|
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]}"
|
|
|
|
'';
|
|
|
|
};
|
2022-06-01 16:15:54 +02:00
|
|
|
in
|
|
|
|
rec {
|
|
|
|
checks = {
|
|
|
|
pre-commit = pre-commit-hooks.lib.${system}.run {
|
|
|
|
src = ./.;
|
|
|
|
|
|
|
|
hooks = {
|
2022-06-02 16:59:21 +02:00
|
|
|
clang-format = {
|
|
|
|
enable = true;
|
|
|
|
types = [ "text" "c" ];
|
|
|
|
# I don't care for generated files' formatting
|
|
|
|
excludes = [ "src/parser.c" "src/tree_sitter/parser.h" ];
|
|
|
|
};
|
|
|
|
|
2022-06-01 16:15:54 +02:00
|
|
|
nixpkgs-fmt = {
|
|
|
|
enable = true;
|
|
|
|
};
|
2022-06-02 17:02:29 +02:00
|
|
|
|
2022-06-13 10:03:40 +02:00
|
|
|
nvim-test = {
|
|
|
|
enable = true;
|
|
|
|
name = "nvim tests";
|
|
|
|
entry = "${nvim-test}/bin/nvim-test";
|
|
|
|
pass_filenames = false;
|
|
|
|
};
|
|
|
|
|
2022-06-02 17:04:32 +02:00
|
|
|
tree-sitter = {
|
|
|
|
enable = true;
|
|
|
|
name = "tree-sitter tests";
|
2022-06-03 15:56:32 +02:00
|
|
|
entry = "${tree-sitter-env}/bin/tree-sitter test";
|
2022-06-02 17:04:32 +02:00
|
|
|
pass_filenames = false;
|
|
|
|
};
|
|
|
|
|
2022-06-02 17:02:29 +02:00
|
|
|
tree-sitter-files = {
|
|
|
|
enable = true;
|
|
|
|
name = "tree-sitter generated files";
|
2022-06-03 15:56:32 +02:00
|
|
|
entry = "${tree-sitter-env}/bin/tree-sitter generate";
|
2022-06-02 17:02:29 +02:00
|
|
|
pass_filenames = false;
|
|
|
|
};
|
2022-06-01 16:15:54 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
devShells = {
|
|
|
|
default = pkgs.mkShell {
|
|
|
|
nativeBuildInputs = with pkgs; [
|
2022-06-13 13:40:12 +02:00
|
|
|
bump-version
|
2022-06-01 16:15:54 +02:00
|
|
|
nodejs
|
2022-06-13 10:03:40 +02:00
|
|
|
nvim-test
|
2022-06-03 20:00:30 +02:00
|
|
|
(tree-sitter.override { webUISupport = true; })
|
2022-06-01 16:15:54 +02:00
|
|
|
];
|
|
|
|
|
|
|
|
inherit (checks.pre-commit) shellHook;
|
|
|
|
};
|
|
|
|
};
|
2022-06-03 11:59:30 +02:00
|
|
|
|
|
|
|
packages = {
|
2022-06-03 14:48:15 +02:00
|
|
|
default = packages.tree-sitter-tiger;
|
|
|
|
|
|
|
|
inherit (pkgs.tree-sitter.passthru.builtGrammars) tree-sitter-tiger;
|
|
|
|
|
|
|
|
inherit (pkgs) tree-sitter;
|
|
|
|
};
|
|
|
|
}) // {
|
|
|
|
overlays = {
|
|
|
|
default = final: prev: {
|
|
|
|
tree-sitter = prev.tree-sitter.override {
|
|
|
|
extraGrammars = {
|
|
|
|
tree-sitter-tiger = {
|
|
|
|
src = ./.;
|
|
|
|
};
|
2022-06-03 11:59:30 +02:00
|
|
|
};
|
2022-06-03 14:48:15 +02:00
|
|
|
};
|
2022-06-03 11:59:30 +02:00
|
|
|
};
|
2022-06-03 14:48:15 +02:00
|
|
|
};
|
|
|
|
};
|
2022-06-01 16:15:54 +02:00
|
|
|
}
|