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

authored by

Ben Siraphob and committed by
GitHub
e6c54135 1cec41b7

+6 -6
+5 -5
pkgs/development/tools/parsing/tree-sitter/default.nix
··· 20 20 , enableShared ? !stdenv.hostPlatform.isStatic 21 21 , enableStatic ? stdenv.hostPlatform.isStatic 22 22 , webUISupport ? false 23 + , extraGrammars ? {} 23 24 }: 24 25 25 26 # TODO: move to carnix or https://github.com/kolloch/crate2nix ··· 51 52 runCommand "grammars" { } ('' 52 53 mkdir $out 53 54 '' + (lib.concatStrings (lib.mapAttrsToList 54 - (name: grammar: "ln -s ${fetchGrammar grammar} $out/${name}\n") 55 + (name: grammar: "ln -s ${if grammar ? src then grammar.src else fetchGrammar grammar} $out/${name}\n") 55 56 (import ./grammars { inherit lib; })))); 56 - 57 57 builtGrammars = 58 58 let 59 59 change = name: grammar: 60 60 callPackage ./grammar.nix { } { 61 61 language = if grammar ? language then grammar.language else name; 62 62 inherit version; 63 - source = fetchGrammar grammar; 63 + source = if grammar ? src then grammar.src else fetchGrammar grammar; 64 64 location = if grammar ? location then grammar.location else null; 65 65 }; 66 - grammars' = (import ./grammars { inherit lib; }); 66 + grammars' = import ./grammars { inherit lib; } // extraGrammars; 67 67 grammars = grammars' // 68 68 { tree-sitter-ocaml = grammars'.tree-sitter-ocaml // { location = "ocaml"; }; } // 69 69 { tree-sitter-ocaml-interface = grammars'.tree-sitter-ocaml // { location = "interface"; }; } // ··· 71 71 { tree-sitter-typescript = grammars'.tree-sitter-typescript // { location = "typescript"; }; } // 72 72 { tree-sitter-tsx = grammars'.tree-sitter-typescript // { location = "tsx"; }; }; 73 73 in 74 - lib.mapAttrs change grammars; 74 + lib.mapAttrs change (grammars); 75 75 76 76 # Usage: 77 77 # pkgs.tree-sitter.withPlugins (p: [ p.tree-sitter-c p.tree-sitter-java ... ])
+1 -1
pkgs/top-level/all-packages.nix
··· 15932 15932 15933 15933 travis = callPackage ../development/tools/misc/travis { }; 15934 15934 15935 - tree-sitter = callPackage ../development/tools/parsing/tree-sitter { 15935 + tree-sitter = makeOverridable (callPackage ../development/tools/parsing/tree-sitter) { 15936 15936 inherit (darwin.apple_sdk.frameworks) Security; 15937 15937 }; 15938 15938