GNU bug report logs - #74900
[PATCH] Replace (guix build json) with (json) in node build system

Previous Next

Package: guix-patches;

Reported by: Daniel Khodabakhsh <d.khodabakhsh <at> gmail.com>

Date: Sun, 15 Dec 2024 20:31:01 UTC

Severity: normal

Tags: patch

Done: Jelle Licht <jlicht <at> fsfe.org>

Bug is archived. No further changes may be made.

Full log


Message #53 received at 74900 <at> debbugs.gnu.org (full text, mbox):

From: Nicolas Graves <ngraves <at> ngraves.fr>
To: 74900 <at> debbugs.gnu.org
Cc: Nicolas Graves <ngraves <at> ngraves.fr>, jlicht <at> fsfe.org,
 d.khodabakhsh <at> gmail.com
Subject: [PATCH v2 5/6] build-system/tree-sitter: Switch to (json).
Date: Tue, 18 Feb 2025 00:43:56 +0100
* guix/build/tree-sitter-build-system.scm (patch-dependencies,
install): Switch from (guix build json) to (json).
---
 guix/build/tree-sitter-build-system.scm | 44 +++++++++++--------------
 1 file changed, 20 insertions(+), 24 deletions(-)

diff --git a/guix/build/tree-sitter-build-system.scm b/guix/build/tree-sitter-build-system.scm
index 4106728bdf..1fe2601dd7 100644
--- a/guix/build/tree-sitter-build-system.scm
+++ b/guix/build/tree-sitter-build-system.scm
@@ -18,10 +18,10 @@
 
 (define-module (guix build tree-sitter-build-system)
   #:use-module ((guix build node-build-system) #:prefix node:)
-  #:use-module (guix build json)
   #:use-module (guix build utils)
   #:use-module (ice-9 match)
   #:use-module (ice-9 regex)
+  #:use-module (json)
   #:use-module (srfi srfi-1)
   #:export (%standard-phases
             tree-sitter-build))
@@ -47,28 +47,24 @@ (define* (patch-dependencies #:key inputs #:allow-other-keys)
   "Rewrite dependencies in 'package.json'.  We remove all runtime dependencies
 and replace development dependencies with tree-sitter grammar node modules."
 
-  (define (rewrite package.json)
-    (map (match-lambda
-           (("dependencies" @ . _)
-            '("dependencies" @))
-           (("devDependencies" @ . _)
-            `("devDependencies" @
-              ,@(filter-map (match-lambda
-                              ((key . directory)
-                               (let ((node-module
-                                      (string-append directory
-                                                     "/lib/node_modules/"
-                                                     key)))
-                                 (and (directory-exists? node-module)
-                                      `(,key . ,node-module)))))
-                            (alist-delete "node" inputs))))
-           (other other))
-         package.json))
-
-  (node:with-atomic-json-file-replacement "package.json"
-    (match-lambda
-      (('@ . package.json)
-       (cons '@ (rewrite package.json))))))
+  (node:with-atomic-json-file-replacement
+   (lambda (pkg-meta-alist)
+     (map (match-lambda
+            (("dependencies" dependencies ...)
+             '("dependencies"))
+            (("devDependencies" dev-dependencies ...)
+             `("devDependencies"
+               ,@(filter-map (match-lambda
+                               ((key . directory)
+                                (let ((node-module
+                                       (string-append directory
+                                                      "/lib/node_modules/"
+                                                      key)))
+                                  (and (directory-exists? node-module)
+                                       `(,key . ,node-module)))))
+                             (alist-delete "node" inputs))))
+            (other other))
+          pkg-meta-alist))))
 
 ;; FIXME: The node build-system's configure phase does not support
 ;; cross-compiling so we re-define it.
@@ -99,7 +95,7 @@ (define* (install #:key target grammar-directories outputs #:allow-other-keys)
     (define (compile-language dir)
       (with-directory-excursion dir
         (let ((lang (assoc-ref (call-with-input-file "src/grammar.json"
-                                 read-json)
+                                 json->scm)
                                "name"))
               (source-file (lambda (path)
                              (if (file-exists? path)
-- 
2.48.1





This bug report was last modified 95 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.