3
0
Fork 0
forked from mirrors/nixpkgs

Merge pull request #161456 from siraben/tree-sitter-overridable

This commit is contained in:
Ben Siraphob 2022-03-21 23:51:52 -05:00 committed by GitHub
commit e6c5413578
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 6 deletions

View file

@ -20,6 +20,7 @@
, enableShared ? !stdenv.hostPlatform.isStatic
, enableStatic ? stdenv.hostPlatform.isStatic
, webUISupport ? false
, extraGrammars ? {}
}:
# TODO: move to carnix or https://github.com/kolloch/crate2nix
@ -51,19 +52,18 @@ let
runCommand "grammars" { } (''
mkdir $out
'' + (lib.concatStrings (lib.mapAttrsToList
(name: grammar: "ln -s ${fetchGrammar grammar} $out/${name}\n")
(name: grammar: "ln -s ${if grammar ? src then grammar.src else fetchGrammar grammar} $out/${name}\n")
(import ./grammars { inherit lib; }))));
builtGrammars =
let
change = name: grammar:
callPackage ./grammar.nix { } {
language = if grammar ? language then grammar.language else name;
inherit version;
source = fetchGrammar grammar;
source = if grammar ? src then grammar.src else fetchGrammar grammar;
location = if grammar ? location then grammar.location else null;
};
grammars' = (import ./grammars { inherit lib; });
grammars' = import ./grammars { inherit lib; } // extraGrammars;
grammars = grammars' //
{ tree-sitter-ocaml = grammars'.tree-sitter-ocaml // { location = "ocaml"; }; } //
{ tree-sitter-ocaml-interface = grammars'.tree-sitter-ocaml // { location = "interface"; }; } //
@ -71,7 +71,7 @@ let
{ tree-sitter-typescript = grammars'.tree-sitter-typescript // { location = "typescript"; }; } //
{ tree-sitter-tsx = grammars'.tree-sitter-typescript // { location = "tsx"; }; };
in
lib.mapAttrs change grammars;
lib.mapAttrs change (grammars);
# Usage:
# pkgs.tree-sitter.withPlugins (p: [ p.tree-sitter-c p.tree-sitter-java ... ])

View file

@ -15932,7 +15932,7 @@ with pkgs;
travis = callPackage ../development/tools/misc/travis { };
tree-sitter = callPackage ../development/tools/parsing/tree-sitter {
tree-sitter = makeOverridable (callPackage ../development/tools/parsing/tree-sitter) {
inherit (darwin.apple_sdk.frameworks) Security;
};