From 0d96613d9aa41f93ebb440bb1aa383456b49f28f Mon Sep 17 00:00:00 2001 From: Alexander Foremny Date: Fri, 15 Dec 2023 07:40:33 +0100 Subject: feat: drop haskell-tree-sitter Drop haskell-tree-sitter in favor of custom bindings to tree-sitter. haskell-tree-sitter is outdated and seems unmaintained. The implementation add low-level bindings to tree-sitter and traverses the AST in Haskell. We suspect that many FFI calls are more expensive than performing just a single API call to a C function that does the traversal. This will be addressed in upcoming commits. @prerequisite-for add-languages-elm-shell-nix --- default.nix | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) (limited to 'default.nix') diff --git a/default.nix b/default.nix index 59d560e..9667ef6 100644 --- a/default.nix +++ b/default.nix @@ -11,6 +11,25 @@ ''; }); }) + (self: super: { + tree-sitter-grammars = pkgs.lib.mapAttrs + (name: grammar: + if self.lib.isDerivation grammar then + pkgs.stdenv.mkDerivation + { + inherit (grammar) pname version; + phases = [ "installPhase" ]; + installPhase = '' + mkdir -p $out/lib + cp ${grammar}/parser $out/lib/lib${name}.so + ''; + } + else + grammar + + ) + super.tree-sitter-grammars; + }) (self: super: { anissue = pkgs.writers.writeDashBin "anissue" '' set -efu @@ -25,7 +44,10 @@ let haskellPackages = pkgs.haskellPackages.override { overrides = self: super: { - anissue = (super.callCabal2nix "anissue" ./. { }).overrideAttrs (oldAttrs: rec { + anissue = (super.callCabal2nix "anissue" ./. { + inherit (pkgs) tree-sitter; + inherit (pkgs.tree-sitter-grammars) tree-sitter-haskell; + }).overrideAttrs (oldAttrs: rec { nativeBuildInputs = [ pkgs.installShellFiles ]; buildInputs = oldAttrs.buildInputs or [ ] ++ [ pkgs.makeWrapper ]; passthru = oldAttrs.passthru // { @@ -63,7 +85,12 @@ rec { pkgs.ghcid pkgs.haskell-language-server pkgs.tree-sitter - ] ++ anissue.passthru.dependencies; + ] + ++ ( + pkgs.lib.filter pkgs.lib.isDerivation + (pkgs.lib.attrValues pkgs.tree-sitter-grammars) + ) + ++ anissue.passthru.dependencies; withHoogle = true; withHaddock = true; shellHook = '' -- cgit v1.2.3