2024-04-07 20:59:34 +02:00
|
|
|
{
|
|
|
|
description = "A tree-sitter grammar for Blueprint";
|
|
|
|
|
|
|
|
inputs = {
|
|
|
|
flake-utils = {
|
|
|
|
type = "github";
|
|
|
|
owner = "numtide";
|
|
|
|
repo = "flake-utils";
|
|
|
|
ref = "main";
|
|
|
|
};
|
|
|
|
|
|
|
|
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";
|
|
|
|
nixpkgs-stable.follows = "nixpkgs";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
outputs =
|
|
|
|
{ self
|
|
|
|
, flake-utils
|
|
|
|
, nixpkgs
|
|
|
|
, pre-commit-hooks
|
|
|
|
}:
|
|
|
|
let
|
|
|
|
inherit (flake-utils.lib) eachDefaultSystem;
|
2024-04-11 20:42:25 +02:00
|
|
|
inherit (nixpkgs) lib;
|
2024-04-07 20:59:34 +02:00
|
|
|
in
|
|
|
|
eachDefaultSystem
|
|
|
|
(system:
|
|
|
|
let
|
|
|
|
pkgs = import nixpkgs {
|
|
|
|
inherit system;
|
|
|
|
overlays = [ self.overlays.default ];
|
|
|
|
};
|
|
|
|
|
2024-04-11 20:42:25 +02:00
|
|
|
nvim-test-runner = pkgs.writeShellApplication {
|
|
|
|
name = "nvim-test-runner";
|
|
|
|
|
|
|
|
runtimeInputs = with pkgs; [
|
|
|
|
highlight-assertions
|
|
|
|
neovim
|
|
|
|
];
|
|
|
|
|
|
|
|
text = ''
|
|
|
|
export NVIM_PLENARY='${pkgs.vimPlugins.plenary-nvim}'
|
|
|
|
export NVIM_TREESITTER='${pkgs.vimPlugins.nvim-treesitter}'
|
|
|
|
export NVIM_TREESITTER_TEXTOBJECTS='${pkgs.vimPlugins.nvim-treesitter-textobjects}'
|
|
|
|
export NVIM_TREESITTER_PARSER='${pkgs.vimPlugins.nvim-treesitter.grammarToPlugin self.packages.${system}.tree-sitter-bp}'
|
|
|
|
|
2024-05-13 17:38:28 +02:00
|
|
|
# FIXME: not sure why, but I get different behaviour when left untouched
|
|
|
|
XDG_CONFIG_HOME=$(mktemp -d)
|
|
|
|
export XDG_CONFIG_HOME
|
|
|
|
|
2024-04-11 20:42:25 +02:00
|
|
|
nvim --headless --noplugin -u ${scripts/minimal_init.lua} \
|
|
|
|
-c "PlenaryBustedDirectory test/ { minimal_init = '${./scripts/minimal_init.lua}' }"
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2024-04-08 03:14:21 +02:00
|
|
|
bump-version = pkgs.writeShellScriptBin "bump-version" ''
|
|
|
|
set -eu
|
|
|
|
|
|
|
|
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
|
2024-05-13 17:44:33 +02:00
|
|
|
${pkgs.gnused}/bin/sed -i -e "s/version = \"[0-9.]\\+\"/version = \"''${NEW_VERSION}\"/" pyproject.toml
|
2024-04-08 03:14:21 +02:00
|
|
|
|
2024-05-13 17:44:33 +02:00
|
|
|
git add Cargo.toml package.json pyproject.toml
|
2024-04-08 03:14:21 +02:00
|
|
|
echo "Release ''${NEW_VERSION}" | git commit -eF -
|
|
|
|
git tag -a "v''${NEW_VERSION}" -m "Release ''${NEW_VERSION}"
|
|
|
|
'';
|
|
|
|
|
2024-04-07 20:59:34 +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]}"
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
in
|
|
|
|
rec {
|
|
|
|
checks = {
|
|
|
|
pre-commit = pre-commit-hooks.lib.${system}.run {
|
|
|
|
src = ./.;
|
|
|
|
|
|
|
|
hooks = {
|
|
|
|
nixpkgs-fmt = {
|
|
|
|
enable = true;
|
|
|
|
};
|
|
|
|
|
2024-04-11 20:42:25 +02:00
|
|
|
nvim-test-runner = {
|
|
|
|
enable = true;
|
|
|
|
name = "nvim tests";
|
|
|
|
entry = "${lib.getExe nvim-test-runner}";
|
|
|
|
pass_filenames = false;
|
|
|
|
};
|
|
|
|
|
2024-04-07 20:59:34 +02:00
|
|
|
tree-sitter = {
|
|
|
|
enable = true;
|
|
|
|
name = "tree-sitter tests";
|
2024-04-22 11:49:18 +02:00
|
|
|
entry = "${tree-sitter-env}/bin/tree-sitter test";
|
2024-04-07 20:59:34 +02:00
|
|
|
pass_filenames = false;
|
|
|
|
};
|
|
|
|
|
|
|
|
tree-sitter-files = {
|
|
|
|
enable = true;
|
|
|
|
name = "tree-sitter generated files";
|
|
|
|
entry = "${tree-sitter-env}/bin/tree-sitter generate";
|
|
|
|
pass_filenames = false;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
devShells = {
|
|
|
|
default = pkgs.mkShell {
|
|
|
|
nativeBuildInputs = with pkgs; [
|
2024-04-08 03:14:21 +02:00
|
|
|
bump-version
|
2024-04-07 20:59:34 +02:00
|
|
|
nodejs
|
2024-04-11 20:42:25 +02:00
|
|
|
nvim-test-runner
|
2024-04-08 09:49:42 +02:00
|
|
|
# FIXME: waiting on #301336
|
|
|
|
# (tree-sitter.override { webUISupport = true; })
|
|
|
|
tree-sitter
|
2024-04-07 20:59:34 +02:00
|
|
|
];
|
|
|
|
|
|
|
|
inherit (checks.pre-commit) shellHook;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
packages = {
|
2024-04-10 17:30:57 +02:00
|
|
|
default = packages.tree-sitter-bp;
|
2024-04-07 20:59:34 +02:00
|
|
|
|
2024-04-10 17:30:57 +02:00
|
|
|
inherit (pkgs.tree-sitter.passthru.builtGrammars) tree-sitter-bp;
|
2024-04-07 20:59:34 +02:00
|
|
|
|
|
|
|
inherit (pkgs) tree-sitter;
|
|
|
|
};
|
|
|
|
}) // {
|
|
|
|
overlays = {
|
|
|
|
default = final: prev: {
|
|
|
|
tree-sitter = prev.tree-sitter.override {
|
|
|
|
extraGrammars = {
|
2024-04-10 17:30:57 +02:00
|
|
|
tree-sitter-bp = {
|
2024-04-07 20:59:34 +02:00
|
|
|
src = ./.;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|