From ce10c78c78be3da75d2856a84e5d3968746d05c7 Mon Sep 17 00:00:00 2001 From: Glib Shpychka <23005347+gshpychka@users.noreply.github.com> Date: Mon, 26 Jun 2023 18:36:03 +0300 Subject: tree-sitter: allow use of 'generate' argument --- pkgs/development/tools/parsing/tree-sitter/default.nix | 5 +++-- pkgs/development/tools/parsing/tree-sitter/grammar.nix | 6 +++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/pkgs/development/tools/parsing/tree-sitter/default.nix b/pkgs/development/tools/parsing/tree-sitter/default.nix index 9da09a10e7e..6579a039b70 100644 --- a/pkgs/development/tools/parsing/tree-sitter/default.nix +++ b/pkgs/development/tools/parsing/tree-sitter/default.nix @@ -41,7 +41,7 @@ let fetchSubmodules = true; }; - update-all-grammars = callPackage ./update.nix {}; + update-all-grammars = callPackage ./update.nix { }; fetchGrammar = (v: fetchgit { inherit (v) url rev sha256 fetchSubmodules; }); @@ -62,6 +62,7 @@ let inherit version; src = grammar.src or (fetchGrammar grammar); location = grammar.location or null; + generate = grammar.generate or false; }; grammars' = import ./grammars { inherit lib; } // extraGrammars; grammars = grammars' // @@ -111,7 +112,7 @@ rustPlatform.buildRustPackage { inherit src version cargoSha256; buildInputs = - lib.optionals stdenv.isDarwin [ Security CoreServices]; + lib.optionals stdenv.isDarwin [ Security CoreServices ]; nativeBuildInputs = [ which ] ++ lib.optionals webUISupport [ emscripten ]; diff --git a/pkgs/development/tools/parsing/tree-sitter/grammar.nix b/pkgs/development/tools/parsing/tree-sitter/grammar.nix index c2c3ce4a896..ce46e3623ba 100644 --- a/pkgs/development/tools/parsing/tree-sitter/grammar.nix +++ b/pkgs/development/tools/parsing/tree-sitter/grammar.nix @@ -28,10 +28,10 @@ stdenv.mkDerivation ({ stripDebugList = [ "parser" ]; - configurePhase = lib.optionalString generate '' - tree-sitter generate - '' + lib.optionalString (location != null) '' + configurePhase = lib.optionalString (location != null) '' cd ${location} + '' + lib.optionalString generate '' + tree-sitter generate ''; # When both scanner.{c,cc} exist, we should not link both since they may be the same but in -- cgit 1.4.1