From 47f7109d73cf814264f925736523ae2b5bde52e7 Mon Sep 17 00:00:00 2001 From: Stefan Frijters Date: Mon, 6 Jul 2026 17:43:04 +0200 Subject: [PATCH] tree-sitter-grammars: enable __structuredAttrs * Move existing env variables into env and stringify them, as is required. * `language` is used as an env variable by `jq`, so move it to env as well. * Do not clobber `env` if it exists, but merge in these attributes. --- .../tr/tree-sitter/grammars/build-grammar.nix | 39 ++++++++++++------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/pkgs/by-name/tr/tree-sitter/grammars/build-grammar.nix b/pkgs/by-name/tr/tree-sitter/grammars/build-grammar.nix index 598a14ff6ec3..177c031e1d62 100644 --- a/pkgs/by-name/tr/tree-sitter/grammars/build-grammar.nix +++ b/pkgs/by-name/tr/tree-sitter/grammars/build-grammar.nix @@ -37,21 +37,28 @@ stdenv.mkDerivation ( tree-sitter ]; - CFLAGS = [ - "-Isrc" - # Match upstream `tree-sitter build --wasm` - (if isWasi then "-Os" else "-O2") - ] - ++ lib.optionals isWasi [ - "-fvisibility=hidden" - ]; - CXXFLAGS = [ - "-Isrc" - (if isWasi then "-Os" else "-O2") - ] - ++ lib.optionals isWasi [ - "-fvisibility=hidden" - ]; + env = args.env or { } // { + CFLAGS = toString ( + [ + "-Isrc" + # Match upstream `tree-sitter build --wasm` + (if isWasi then "-Os" else "-O2") + ] + ++ lib.optionals isWasi [ + "-fvisibility=hidden" + ] + ); + CXXFLAGS = toString ( + [ + "-Isrc" + (if isWasi then "-Os" else "-O2") + ] + ++ lib.optionals isWasi [ + "-fvisibility=hidden" + ] + ); + inherit language; + }; stripDebugList = [ "parser" ]; @@ -170,5 +177,7 @@ stdenv.mkDerivation ( "generate" "excludeBrokenTreeSitterJson" "meta" + "language" + "env" ] )