summaryrefslogtreecommitdiff
path: root/guix/build/node-build-system.scm
diff options
context:
space:
mode:
authorJulien Lepiller <julien@lepiller.eu>2019-07-14 20:16:19 +0200
committerJulien Lepiller <julien@lepiller.eu>2019-07-14 20:18:07 +0200
commita4bb18921099b2ec8c1699e08a73ca0fa78d0486 (patch)
treef4ebaf59f4aca03bfbc20b3415f832a76f3b8570 /guix/build/node-build-system.scm
parent3c6d7fa84274ab357b5e43dd412486b35872ab36 (diff)
Revert "guix: node-build-system: Use guile-json instead of a custom parser."
The effect of this change was to import the (json parser) from the host side into the build side. The solution here would be to do the equivalent of ‘with-extensions’ for gexps. Since we don't use gexps for build systems just yet, revert this for now. This reverts commit 8eb0ba532ebbebef23180e666e0607ea735f9c1a.
Diffstat (limited to 'guix/build/node-build-system.scm')
-rw-r--r--guix/build/node-build-system.scm28
1 files changed, 13 insertions, 15 deletions
diff --git a/guix/build/node-build-system.scm b/guix/build/node-build-system.scm
index 231e60488a..3c0ac2a12b 100644
--- a/guix/build/node-build-system.scm
+++ b/guix/build/node-build-system.scm
@@ -19,12 +19,12 @@
(define-module (guix build node-build-system)
#:use-module ((guix build gnu-build-system) #:prefix gnu:)
+ #:use-module (guix build json)
#:use-module (guix build union)
#:use-module (guix build utils)
#:use-module (ice-9 match)
#:use-module (ice-9 popen)
#:use-module (ice-9 regex)
- #:use-module (json parser)
#:use-module (srfi srfi-1)
#:use-module (srfi srfi-26)
#:export (%standard-phases
@@ -39,12 +39,12 @@
(define* (read-package-data #:key (filename "package.json"))
(call-with-input-file filename
(lambda (port)
- (json->scm port))))
+ (read-json port))))
(define* (build #:key inputs #:allow-other-keys)
(define (build-from-package-json? package-file)
(let* ((package-data (read-package-data #:filename package-file))
- (scripts (hash-ref package-data "scripts")))
+ (scripts (assoc-ref package-data "scripts")))
(assoc-ref scripts "build")))
"Build a new node module using the appropriate build system."
;; XXX: Develop a more robust heuristic, allow override
@@ -103,15 +103,13 @@ the @file{bin} directory."
(target (string-append out "/lib"))
(binaries (string-append out "/bin"))
(data (read-package-data))
- (modulename (hash-ref data "name"))
- (binary-configuration (match (hash-ref data "bin")
- ((? hash-table? hash-table)
- (hash-map->list cons hash-table))
- ((? string? configuration) configuration)
- (#f #f)))
- (dependencies (match (hash-ref data "dependencies")
- ((? hash-table? hash-table)
- (hash-map->list cons hash-table))
+ (modulename (assoc-ref data "name"))
+ (binary-configuration (match (assoc-ref data "bin")
+ (('@ configuration ...) configuration)
+ ((? string? configuration) configuration)
+ (#f #f)))
+ (dependencies (match (assoc-ref data "dependencies")
+ (('@ deps ...) deps)
(#f #f))))
(mkdir-p target)
(copy-recursively "." (string-append target "/node_modules/" modulename))
@@ -123,7 +121,7 @@ the @file{bin} directory."
(begin
(mkdir-p binaries)
(symlink (string-append target "/node_modules/" modulename "/"
- binary-configuration)
+ binary-configuration)
(string-append binaries "/" modulename))))
((list? binary-configuration)
(for-each
@@ -133,12 +131,12 @@ the @file{bin} directory."
(begin
(mkdir-p (dirname (string-append binaries "/" key)))
(symlink (string-append target "/node_modules/" modulename "/"
- value)
+ value)
(string-append binaries "/" key))))))
binary-configuration))
(else
(symlink (string-append target "/node_modules/" modulename "/bin")
- binaries)))
+ binaries)))
(when dependencies
(mkdir-p
(string-append target "/node_modules/" modulename "/node_modules"))