about summary refs log tree commit diff
path: root/pkgs/development/tools/parsing/tree-sitter/update.nix
diff options
context:
space:
mode:
authorProfpatsch <mail@profpatsch.de>2022-09-12 17:43:26 +0200
committerProfpatsch <mail@profpatsch.de>2022-11-04 18:14:33 +0100
commit484bce31b7cf3541e01835545453c7545d20d043 (patch)
tree8d418a54d796ea278f4229f1a9dc1abb7ae6dede /pkgs/development/tools/parsing/tree-sitter/update.nix
parenta953387d22f56bc62c67b14cbdfca846f1eef69f (diff)
tree-sitter/update: move printing of the import nix file to python
This is a bit crappy, but the complexity should go away once it’s done
in all python. Might have been wiser to rewrite the other stuff first.
Diffstat (limited to 'pkgs/development/tools/parsing/tree-sitter/update.nix')
-rw-r--r--pkgs/development/tools/parsing/tree-sitter/update.nix22
1 files changed, 12 insertions, 10 deletions
diff --git a/pkgs/development/tools/parsing/tree-sitter/update.nix b/pkgs/development/tools/parsing/tree-sitter/update.nix
index 17b13bad8b0a6..055f42dc720a3 100644
--- a/pkgs/development/tools/parsing/tree-sitter/update.nix
+++ b/pkgs/development/tools/parsing/tree-sitter/update.nix
@@ -393,6 +393,7 @@ let
         curl = "${curl}/bin/curl";
         nix-prefetch-git = "${nix-prefetch-git}/bin/nix-prefetch-git";
         inherit atomically-write;
+        printf = "${coreutils}/bin/printf";
       };
       inherit
         knownTreeSitterOrgGrammarRepos
@@ -446,16 +447,17 @@ let
           })
           allGrammars)
     }
-    ${atomically-write} \
-      "${outputDir}/default.nix" \
-      ${writeShellScript "print-all-grammars" ''
-          echo "{ lib }:"
-          echo "{"
-          ${foreachSh allGrammars
-            ({name, ...}: ''
-              printf "  %s = lib.importJSON ./%s.json;\n" "${name}" "${name}"'')}
-          echo "}"
-       ''}
+    ${fetchImpl} print-all-grammars-nix-file "$(< ${
+        jsonFile "all-grammars.json" {
+          allGrammars =
+            (lib.mapAttrsToList
+              (nixRepoAttrName: attrs: attrs // {
+                inherit nixRepoAttrName;
+              })
+              allGrammars);
+          inherit outputDir;
+        }
+    })"
   '';
 
   # Atomically write a file (just `>` redirection in bash