unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
* [bug#47282] [PATCH 00/13] node going forward
@ 2021-03-20 14:57 Jelle Licht
  2021-03-20 14:59 ` [bug#47282] [PATCH 01/13] build-system: Rewrite node build system Jelle Licht
                   ` (2 more replies)
  0 siblings, 3 replies; 37+ messages in thread
From: Jelle Licht @ 2021-03-20 14:57 UTC (permalink / raw)
  To: 47282

So, some people seem to be interested in this one; please review and test.

Thanks again to Timothy Sample, who made quite some of these things happen.

Jelle Licht (13):
  build-system: Rewrite node build system.
  gnu: Add libuv-node
  gnu: node: Use license prefix.
  gnu: node: Add node-bootstrap.
  gnu: node: Add node-semver-bootstrap.
  gnu: node: Add node-ms-bootstrap.
  gnu: node: Add node-binary-search-bootstrap.
  gnu: node: Add node-debug-bootstrap.
  gnu: node: Add node-llparse-builder-bootstrap.
  gnu: node: Add node-llparse-frontend-bootstrap.
  gnu: node: Add node-llparse-bootstrap.
  gnu: node: Add llhttp-bootstrap.
  gnu: node: Add node-lts

 gnu/packages/libevent.scm        |  16 +
 gnu/packages/node-xyz.scm        |  74 +++--
 gnu/packages/node.scm            | 547 ++++++++++++++++++++++++++++++-
 guix/build-system/node.scm       |  39 +--
 guix/build/node-build-system.scm | 203 ++++++------
 5 files changed, 720 insertions(+), 159 deletions(-)

-- 
2.31.0





^ permalink raw reply	[flat|nested] 37+ messages in thread

* [bug#47282] [PATCH 01/13] build-system: Rewrite node build system.
  2021-03-20 14:57 [bug#47282] [PATCH 00/13] node going forward Jelle Licht
@ 2021-03-20 14:59 ` Jelle Licht
  2021-03-20 14:59   ` [bug#47282] [PATCH 02/13] gnu: Add libuv-node Jelle Licht
                     ` (11 more replies)
  2021-03-23  9:05 ` [bug#47282] [PATCH 00/13] node going forward Lars-Dominik Braun
  2021-03-30  5:24 ` Timothy Sample
  2 siblings, 12 replies; 37+ messages in thread
From: Jelle Licht @ 2021-03-20 14:59 UTC (permalink / raw)
  To: 47282; +Cc: Timothy Sample

* guix/build/node-build-system.scm: Rewrite it.
* guix/build-system/node.scm: Adjust accordingly.
* gnu/packages/node-xyz.scm (node-color-name, node-env-variable, node-far,
node-long-stack-traces, node-mersenne, node-oop, node-stack-trace,
node-statsd-parser, node-utils-deprecate, node-semver): Likewise.

Co-authored-by: Timothy Sample <samplet@ngyro.com>
---
 gnu/packages/node-xyz.scm        |  74 +++++++----
 guix/build-system/node.scm       |  37 ++----
 guix/build/node-build-system.scm | 203 ++++++++++++++-----------------
 3 files changed, 158 insertions(+), 156 deletions(-)

diff --git a/gnu/packages/node-xyz.scm b/gnu/packages/node-xyz.scm
index b1d6d4ce59..7d7f0251d1 100644
--- a/gnu/packages/node-xyz.scm
+++ b/gnu/packages/node-xyz.scm
@@ -38,6 +38,11 @@
          (base32
           "09rbmj16nfwcwkhrybqxyy66bkrs50vpw6hkdqqb14l3gsyxpr74"))))
     (build-system node-build-system)
+    (arguments
+     `(#:phases
+       (modify-phases
+           %standard-phases
+         (delete 'build))))
     (home-page "https://github.com/colorjs/color-name")
     (synopsis "JSON with CSS color names")
     (description
@@ -59,7 +64,11 @@
          (base32
           "0nnpxjxfhy4na7fixb7p3ww6ard5xgggfm83b78i333867r4gmsq"))))
     (build-system node-build-system)
-    (arguments '(#:tests? #f)) ; No tests.
+    (arguments '(#:tests? #f ; No tests.
+                 #:phases
+                 (modify-phases
+                     %standard-phases
+                   (delete 'build))))
     (home-page "https://github.com/bigpipe/env-variable")
     (synopsis "Environment variables for Node with fallbacks")
     (description "This package provides environment variables with
@@ -85,6 +94,7 @@
     (arguments
      '(#:phases
        (modify-phases %standard-phases
+         (delete 'build)
          (replace 'check
            (lambda _
              ;; We skip the two tests which are supposed to fail.
@@ -113,7 +123,10 @@ codes.")
          (base32
           "0famwsyc6xawi30v25zi65d8fhbvlvh976bqydf1dqn5gz200cl3"))))
     (build-system node-build-system)
-    (arguments '(#:tests? #f)) ; No tests.
+    (arguments '(#:tests? #f ; No tests.
+                 #:phases
+                 (modify-phases %standard-phases
+                   (delete 'build))))
     (home-page "https://github.com/tlrobinson/long-stack-traces")
     (synopsis "Long stacktraces implemented in user-land JavaScript")
     (description "This package provides long stacktraces for V8 implemented in
@@ -136,7 +149,10 @@ user-land JavaScript.")
          (base32
           "034iaiq2pdqn342p2404cpz364g282d2hkp9375hysnh9i968wbb"))))
     (build-system node-build-system)
-    (arguments '(#:tests? #f)) ; No tests.
+    (arguments '(#:tests? #f ; No tests.
+                 #:phases
+                 (modify-phases %standard-phases
+                   (delete 'build))))
     (home-page "http://www.enchantedage.com/node-mersenne")
     (synopsis "Node.js module for generating Mersenne Twister random numbers")
     (description "Thix package provides a node.js port of the Mersenne Twister
@@ -161,7 +177,11 @@ random number generator.")
            (base32
             "0mqrcf0xi2jbwffwkk00cljpqfsri1jk8s6kz8jny45apn7zjds1"))))
       (build-system node-build-system)
-      (arguments '(#:tests? #f)) ; Tests run during build phase.
+      (arguments '(#:tests? #f ; Tests run during build phase.
+                   #:phases
+                   (modify-phases
+                       %standard-phases
+                     (delete 'build))))
       (home-page "https://github.com/felixge/node-oop")
       (synopsis "Simple, light-weight oop module for Node")
       (description "This library tries to bring basic oop features to JavaScript
@@ -189,11 +209,12 @@ while being as light-weight and simple as possible.")
       (arguments
        '(#:phases
          (modify-phases %standard-phases
-         (add-before 'check 'skip-intentionally-failing-test
-           (lambda _
-             (substitute* "test/run.js"
-               (("far.include") "far.exclude(/test-parse.js/)\nfar.include"))
-             #t)))))
+           (delete 'build)
+           (add-before 'check 'skip-intentionally-failing-test
+             (lambda _
+               (substitute* "test/run.js"
+                 (("far.include") "far.exclude(/test-parse.js/)\nfar.include"))
+               #t)))))
       (native-inputs
        `(("node-far" ,node-far)
          ("node-long-stack-traces" ,node-long-stack-traces)))
@@ -207,17 +228,20 @@ while being as light-weight and simple as possible.")
     (name "node-statsd-parser")
     (version "0.0.4")
     (source
-      (origin
-        (method git-fetch)
-        (uri (git-reference
-               (url "https://github.com/dscape/statsd-parser")
-               (commit version)))
-        (file-name (git-file-name name version))
-        (sha256
-         (base32
-          "049rnczsd6pv6bk282q4w72bhqc5cs562djgr7yncy7lk0wzq5j3"))))
+     (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://github.com/dscape/statsd-parser")
+             (commit version)))
+       (file-name (git-file-name name version))
+       (sha256
+        (base32
+         "049rnczsd6pv6bk282q4w72bhqc5cs562djgr7yncy7lk0wzq5j3"))))
     (build-system node-build-system)
-    (arguments '(#:tests? #f)) ; No tests.
+    (arguments '(#:tests? #f            ; No tests.
+                 #:phases
+                 (modify-phases %standard-phases
+                   (delete 'build))))
     (home-page "https://github.com/dscape/statsd-parser")
     (synopsis "Streaming parser for the statsd protocol")
     (description "This package provides a streaming parser for the statsd
@@ -239,7 +263,10 @@ protocol used in @code{node-lynx}.")
          (base32
           "1rk94nl3qc7znsk8400bnga30v0m7j2mmvz9ldwjinxv1d3n11xc"))))
     (build-system node-build-system)
-    (arguments '(#:tests? #f)) ; No test suite.
+    (arguments '(#:tests? #f            ; No tests.
+                 #:phases
+                 (modify-phases %standard-phases
+                   (delete 'build))))
     (home-page "https://github.com/TooTallNate/util-deprecate")
     (synopsis "Node.js `util.deprecate()` function with browser support")
     (description "This package provides the Node.js @code{util.deprecate()}
@@ -261,7 +288,12 @@ function with browser support.")
                 "06biknqb05r9xsmcflm3ygh50pjvdk84x6r79w43kmck4fn3qn5p"))))
     (build-system node-build-system)
     (arguments
-     `(#:tests? #f)) ;; FIXME: Tests depend on node-tap
+     '(#:tests? #f
+       #:phases
+       (modify-phases
+           %standard-phases
+         (delete 'configure)
+         (delete 'build)))) ;; FIXME: Tests depend on node-tap
     (home-page "https://github.com/npm/node-semver")
     (synopsis "Parses semantic versions strings")
     (description
diff --git a/guix/build-system/node.scm b/guix/build-system/node.scm
index 05c24c47d5..560f0ee4da 100644
--- a/guix/build-system/node.scm
+++ b/guix/build-system/node.scm
@@ -1,5 +1,6 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2016 Jelle Licht <jlicht@fsfe.org>
+;;; Copyright © 2019 Timothy Sample <samplet@ngyro.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -17,32 +18,22 @@
 ;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
 
 (define-module (guix build-system node)
-  #:use-module (guix store)
-  #:use-module (guix build json)
-  #:use-module (guix build union)
-  #:use-module (guix utils)
-  #:use-module (guix packages)
-  #:use-module (guix derivations)
-  #:use-module (guix search-paths)
   #:use-module (guix build-system)
   #:use-module (guix build-system gnu)
+  #:use-module (guix derivations)
+  #:use-module (guix packages)
+  #:use-module (guix search-paths)
+  #:use-module (guix utils)
   #:use-module (ice-9 match)
-  #:export (npm-meta-uri
-            %node-build-system-modules
+  #:export (%node-build-system-modules
             node-build
             node-build-system))
 
-(define (npm-meta-uri name)
-  "Return a URI string for the metadata of node module NAME found in the npm
-registry."
-  (string-append "https://registry.npmjs.org/" name))
-
 (define %node-build-system-modules
   ;; Build-side modules imported by default.
   `((guix build node-build-system)
     (guix build json)
-    (guix build union)
-    ,@%gnu-build-system-modules)) ;; TODO: Might be not needed
+    ,@%gnu-build-system-modules))
 
 (define (default-node)
   "Return the default Node package."
@@ -78,7 +69,7 @@ registry."
 
 (define* (node-build store name inputs
                      #:key
-                     (npm-flags ''())
+                     (test-target "test")
                      (tests? #t)
                      (phases '(@ (guix build node-build-system)
                                  %standard-phases))
@@ -88,8 +79,6 @@ registry."
                      (guile #f)
                      (imported-modules %node-build-system-modules)
                      (modules '((guix build node-build-system)
-				(guix build json)
-				(guix build union)
                                 (guix build utils))))
   "Build SOURCE using NODE and INPUTS."
   (define builder
@@ -99,12 +88,10 @@ registry."
                    #:source ,(match (assoc-ref inputs "source")
                                (((? derivation? source))
                                 (derivation->output-path source))
-                               ((source)
-                                source)
-                               (source
-                                source))
+                               ((source) source)
+                               (source source))
                    #:system ,system
-                   #:npm-flags ,npm-flags
+                   #:test-target ,test-target
                    #:tests? ,tests?
                    #:phases ,phases
                    #:outputs %outputs
@@ -131,5 +118,5 @@ registry."
 (define node-build-system
   (build-system
     (name 'node)
-    (description "The standard Node build system")
+    (description "The Node build system")
     (lower lower)))
diff --git a/guix/build/node-build-system.scm b/guix/build/node-build-system.scm
index 7799f03595..ecba27166b 100644
--- a/guix/build/node-build-system.scm
+++ b/guix/build/node-build-system.scm
@@ -1,6 +1,7 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2015 David Thompson <davet@gnu.org>
-;;; Copyright © 2016 Jelle Licht <jlicht@fsfe.org>
+;;; Copyright © 2016, 2020 Jelle Licht <jlicht@fsfe.org>
+;;; Copyright © 2019 Timothy Sample <samplet@ngyro.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -19,144 +20,126 @@
 
 (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 (guix build json)
+  #:use-module (ice-9 ftw)
   #:use-module (ice-9 match)
-  #:use-module (ice-9 popen)
-  #:use-module (ice-9 regex)
   #:use-module (srfi srfi-1)
-  #:use-module (srfi srfi-26)
   #:export (%standard-phases
             node-build))
 
 ;; Commentary:
 ;;
-;; Builder-side code of the standard Node/npm package build procedure.
+;; Builder-side code of the standard Node/NPM package install procedure.
 ;;
 ;; Code:
 
-(define* (read-package-data #:key (filename "package.json"))
-  (call-with-input-file filename
-    (lambda (port)
-      (read-json port))))
+(define (set-home . _)
+  (with-directory-excursion ".."
+    (let loop ((i 0))
+      (let ((dir (string-append "npm-home-" (number->string i))))
+        (if (directory-exists? dir)
+            (loop (1+ i))
+            (begin
+              (mkdir dir)
+              (setenv "HOME" (string-append (getcwd) "/" dir))
+              (format #t "Set HOME to ~s~%" (getenv "HOME")))))))
+  #t)
 
-(define* (build #:key inputs #:allow-other-keys)
-  (define (build-from-package-json? package-file)
-    (let* ((package-data (read-package-data #:filename package-file))
-           (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
-  (cond ((file-exists? "gulpfile.js")
-         (invoke "gulp"))
-        ((file-exists? "gruntfile.js")
-         (invoke "grunt"))
-        ((file-exists? "Makefile")
-         (invoke "make"))
-        ((and (file-exists? "package.json")
-              (build-from-package-json? "package.json"))
-         (invoke "npm" "run" "build")))
+(define (module-name module)
+  (let* ((package.json (string-append module "/package.json"))
+         (package-meta (call-with-input-file package.json read-json)))
+    (assoc-ref package-meta "name")))
+
+(define (index-modules input-paths)
+  (define (list-modules directory)
+    (append-map (lambda (x)
+                  (if (string-prefix? "@" x)
+                      (list-modules (string-append directory "/" x))
+                      (list (string-append directory "/" x))))
+                (filter (lambda (x)
+                          (not (member x '("." ".."))))
+                        (or (scandir directory) '()))))
+  (let ((index (make-hash-table (* 2 (length input-paths)))))
+    (for-each (lambda (dir)
+                (let ((nm (string-append dir "/lib/node_modules")))
+                  (for-each (lambda (module)
+                              (hash-set! index (module-name module) module))
+                            (list-modules nm))))
+              input-paths)
+    index))
+
+(define* (patch-dependencies #:key inputs #:allow-other-keys)
+
+  (define index (index-modules (map cdr inputs)))
+
+  (define (resolve-dependencies package-meta meta-key)
+    (fold (lambda (key+value acc)
+            (match key+value
+              ('@ acc)
+              ((key . value) (acons key (hash-ref index key value) acc))))
+          '()
+          (or (assoc-ref package-meta meta-key) '())))
+
+  (with-atomic-file-replacement "package.json"
+    (lambda (in out)
+      (let ((package-meta (read-json in)))
+        (assoc-set! package-meta "dependencies"
+                    (append
+                     '(@)
+                     (resolve-dependencies package-meta "dependencies")
+                     (resolve-dependencies package-meta "peerDependencies")))
+        (assoc-set! package-meta "devDependencies"
+                    (append
+                     '(@)
+                     (resolve-dependencies package-meta "devDependencies")))
+        (write-json package-meta out))))
   #t)
 
-(define* (link-npm-dependencies #:key inputs #:allow-other-keys)
-  (define (inputs->node-inputs inputs)
-    "Filter the directory part from INPUTS."
-    (filter (lambda (input)
-              (match input
-                ((name . _) (node-package? name))))
-            inputs))
-  (define (inputs->directories inputs)
-    "Extract the directory part from INPUTS."
-    (match inputs
-      (((names . directories) ...)
-       directories)))
-  (define (make-node-path root)
-    (string-append root "/lib/node_modules/"))
-
-  (let ((input-node-directories (inputs->directories
-                                 (inputs->node-inputs inputs))))
-    (union-build "node_modules"
-                 (map make-node-path input-node-directories))
+(define* (configure #:key outputs inputs #:allow-other-keys)
+  (let ((npm (string-append (assoc-ref inputs "node") "/bin/npm")))
+    (invoke npm "--offline" "--ignore-scripts" "install")
     #t))
 
-(define configure link-npm-dependencies)
+(define* (build #:key inputs #:allow-other-keys)
+  (let ((npm (string-append (assoc-ref inputs "node") "/bin/npm")))
+    (invoke npm "run" "build")
+    #t))
 
-(define* (check #:key tests? #:allow-other-keys)
+
+(define* (check #:key tests? inputs #:allow-other-keys)
   "Run 'npm test' if TESTS?"
   (if tests?
-      ;; Should only be enabled once we know that there are tests
-      (invoke "npm" "test"))
+      (let ((npm (string-append (assoc-ref inputs "node") "/bin/npm")))
+        (invoke npm "test"))
+      (format #t "test suite not run~%"))
   #t)
 
-(define (node-package? name)
-  "Check if NAME correspond to the name of an Node package."
-  (string-prefix? "node-" name))
+(define* (repack #:key inputs #:allow-other-keys)
+  (invoke "tar" "-czf" "../package.tgz" ".")
+  #t)
 
 (define* (install #:key outputs inputs #:allow-other-keys)
-  "Install the node module to the output store item. The module itself is
-installed in a subdirectory of @file{node_modules} and its runtime dependencies
-as defined by @file{package.json} are symlinked into a @file{node_modules}
-subdirectory of the module's directory. Additionally, binaries are installed in
-the @file{bin} directory."
-  (let* ((out                  (assoc-ref outputs "out"))
-         (target               (string-append out "/lib"))
-         (binaries             (string-append out "/bin"))
-         (data                 (read-package-data))
-         (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))
-    ;; Remove references to dependencies
-    (delete-file-recursively
-      (string-append target "/node_modules/" modulename "/node_modules"))
-    (cond
-      ((string? binary-configuration)
-       (begin
-         (mkdir-p binaries)
-         (symlink (string-append target "/node_modules/" modulename "/"
-				 binary-configuration)
-                  (string-append binaries "/" modulename))))
-      ((list? binary-configuration)
-       (for-each
-         (lambda (conf)
-           (match conf
-             ((key . value)
-              (begin
-                (mkdir-p (dirname (string-append binaries "/" key)))
-                (symlink (string-append target "/node_modules/" modulename "/"
-					value)
-                         (string-append binaries "/" key))))))
-         binary-configuration)))
-    (when dependencies
-      (mkdir-p
-        (string-append target "/node_modules/" modulename "/node_modules"))
-      (for-each
-        (lambda (dependency)
-          (let ((dependency (car dependency)))
-            (symlink
-              (string-append (assoc-ref inputs (string-append "node-" dependency))
-                             "/lib/node_modules/" dependency)
-              (string-append target "/node_modules/" modulename
-                             "/node_modules/" dependency))))
-        dependencies))
+  "Install the node module to the output store item."
+  (let ((out (assoc-ref outputs "out"))
+        (npm (string-append (assoc-ref inputs "node") "/bin/npm")))
+    (invoke npm "--prefix" out
+            "--global"
+            "--offline"
+            "--loglevel" "silly"
+            "--production"
+            "install" "../package.tgz")
     #t))
 
-
 (define %standard-phases
   (modify-phases gnu:%standard-phases
+    (add-after 'unpack 'set-home set-home)
+    (add-before 'configure 'patch-dependencies patch-dependencies)
     (replace 'configure configure)
     (replace 'build build)
-    (replace 'install install)
-    (delete 'check)
-    (add-after 'install 'check check)
-    (delete 'strip)))
+    (replace 'check check)
+    (add-before 'install 'repack repack)
+    (replace 'install install)))
 
 (define* (node-build #:key inputs (phases %standard-phases)
                      #:allow-other-keys #:rest args)
-- 
2.31.0





^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [bug#47282] [PATCH 02/13] gnu: Add libuv-node
  2021-03-20 14:59 ` [bug#47282] [PATCH 01/13] build-system: Rewrite node build system Jelle Licht
@ 2021-03-20 14:59   ` Jelle Licht
  2021-03-20 14:59   ` [bug#47282] [PATCH 03/13] gnu: node: Use license prefix Jelle Licht
                     ` (10 subsequent siblings)
  11 siblings, 0 replies; 37+ messages in thread
From: Jelle Licht @ 2021-03-20 14:59 UTC (permalink / raw)
  To: 47282

* gnu/packages/libevent.scm (libuv-node): New variable.
---
 gnu/packages/libevent.scm | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/gnu/packages/libevent.scm b/gnu/packages/libevent.scm
index 7109d9a88d..699d0705dd 100644
--- a/gnu/packages/libevent.scm
+++ b/gnu/packages/libevent.scm
@@ -134,6 +134,22 @@ resolution, asynchronous file system operations, and threading primitives.")
     ;; details.  Documentation is CC-BY 4.0 as of 1.12.0; see 'LICENSE-docs'.
     (license (list expat cc-by4.0))))
 
+(define-public libuv-node
+  ;; When upgrading Node, also upgrade this. Get the version from
+  ;; https://github.com/nodejs/node/blob/master/deps/uv/include/uv/version.h
+  (package
+    (inherit libuv)
+    (name "libuv-node")
+    (version "1.40.0")
+    (source (origin
+              (method url-fetch)
+              (uri (string-append "https://dist.libuv.org/dist/v" version
+                                  "/libuv-v" version ".tar.gz"))
+              (sha256
+               (base32
+                "1551k3ab27vbg9517l9b4iqbramwxdkwgpf53knas05cbfwhvab1"))))))
+
+
 (define-public perl-anyevent
   (package
     (name "perl-anyevent")
-- 
2.31.0





^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [bug#47282] [PATCH 03/13] gnu: node: Use license prefix.
  2021-03-20 14:59 ` [bug#47282] [PATCH 01/13] build-system: Rewrite node build system Jelle Licht
  2021-03-20 14:59   ` [bug#47282] [PATCH 02/13] gnu: Add libuv-node Jelle Licht
@ 2021-03-20 14:59   ` Jelle Licht
  2021-03-20 14:59   ` [bug#47282] [PATCH 04/13] gnu: node: Add node-bootstrap Jelle Licht
                     ` (9 subsequent siblings)
  11 siblings, 0 replies; 37+ messages in thread
From: Jelle Licht @ 2021-03-20 14:59 UTC (permalink / raw)
  To: 47282

* gnu/packages/node.scm (node)[license]: Use prefix for license.
---
 gnu/packages/node.scm | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gnu/packages/node.scm b/gnu/packages/node.scm
index a0df3d2cad..82a2ca7ce0 100644
--- a/gnu/packages/node.scm
+++ b/gnu/packages/node.scm
@@ -26,7 +26,7 @@
 ;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
 
 (define-module (gnu packages node)
-  #:use-module ((guix licenses) #:select (expat))
+  #:use-module ((guix licenses) #:prefix license:)
   #:use-module ((guix build utils) #:select (alist-replace))
   #:use-module (guix packages)
   #:use-module (guix derivations)
@@ -207,7 +207,7 @@ event-driven, non-blocking I/O model that makes it lightweight and efficient,
 perfect for data-intensive real-time applications that run across distributed
 devices.")
     (home-page "https://nodejs.org/")
-    (license expat)
+    (license license:expat)
     (properties '((max-silent-time . 7200)     ;2h, needed on ARM
                   (timeout . 21600)))))        ;6h
 
-- 
2.31.0





^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [bug#47282] [PATCH 04/13] gnu: node: Add node-bootstrap.
  2021-03-20 14:59 ` [bug#47282] [PATCH 01/13] build-system: Rewrite node build system Jelle Licht
  2021-03-20 14:59   ` [bug#47282] [PATCH 02/13] gnu: Add libuv-node Jelle Licht
  2021-03-20 14:59   ` [bug#47282] [PATCH 03/13] gnu: node: Use license prefix Jelle Licht
@ 2021-03-20 14:59   ` Jelle Licht
  2021-03-20 14:59   ` [bug#47282] [PATCH 05/13] gnu: node: Add node-semver-bootstrap Jelle Licht
                     ` (8 subsequent siblings)
  11 siblings, 0 replies; 37+ messages in thread
From: Jelle Licht @ 2021-03-20 14:59 UTC (permalink / raw)
  To: 47282

* gnu/packages/node (node-bootstrap): Add hidden alias for node.
---
 gnu/packages/node.scm | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/gnu/packages/node.scm b/gnu/packages/node.scm
index 82a2ca7ce0..9baf3719d7 100644
--- a/gnu/packages/node.scm
+++ b/gnu/packages/node.scm
@@ -211,6 +211,11 @@ devices.")
     (properties '((max-silent-time . 7200)     ;2h, needed on ARM
                   (timeout . 21600)))))        ;6h
 
+;; This should be the latest version of node that still builds without
+;; depending on lltthp.
+(define-public node-bootstrap
+  (hidden-package node))
+
 (define-public libnode
   (package/inherit node
     (name "libnode")
-- 
2.31.0





^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [bug#47282] [PATCH 05/13] gnu: node: Add node-semver-bootstrap.
  2021-03-20 14:59 ` [bug#47282] [PATCH 01/13] build-system: Rewrite node build system Jelle Licht
                     ` (2 preceding siblings ...)
  2021-03-20 14:59   ` [bug#47282] [PATCH 04/13] gnu: node: Add node-bootstrap Jelle Licht
@ 2021-03-20 14:59   ` Jelle Licht
  2021-03-20 14:59   ` [bug#47282] [PATCH 06/13] gnu: node: Add node-ms-bootstrap Jelle Licht
                     ` (7 subsequent siblings)
  11 siblings, 0 replies; 37+ messages in thread
From: Jelle Licht @ 2021-03-20 14:59 UTC (permalink / raw)
  To: 47282

* gnu/packages/node.scm (node-semver-bootstrap): New package.
---
 gnu/packages/node.scm | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)

diff --git a/gnu/packages/node.scm b/gnu/packages/node.scm
index 9baf3719d7..f332d33536 100644
--- a/gnu/packages/node.scm
+++ b/gnu/packages/node.scm
@@ -41,6 +41,7 @@
   #:use-module (gnu packages icu4c)
   #:use-module (gnu packages libevent)
   #:use-module (gnu packages linux)
+  #:use-module (gnu packages node-xyz)
   #:use-module (gnu packages perl)
   #:use-module (gnu packages pkg-config)
   #:use-module (gnu packages python)
@@ -216,6 +217,37 @@ devices.")
 (define-public node-bootstrap
   (hidden-package node))
 
+;; Duplicate of node-semver
+(define-public node-semver-bootstrap
+  (package
+    (name "node-semver")
+    (version "7.2.1")
+    (source (origin
+              (method git-fetch)
+              (uri (git-reference
+                    (url "https://github.com/npm/node-semver")
+                    (commit (string-append "v" version))))
+              (file-name (git-file-name name version))
+              (sha256
+               (base32
+                "06biknqb05r9xsmcflm3ygh50pjvdk84x6r79w43kmck4fn3qn5p"))))
+    (build-system node-build-system)
+    (arguments
+     `(#:node ,node-bootstrap
+       #:tests? #f
+       #:phases
+       (modify-phases
+           %standard-phases
+         (delete 'configure)
+         (delete 'build))))
+    (home-page "https://github.com/npm/node-semver")
+    (properties '((hidden? . #t)))
+    (synopsis "Parses semantic versions strings")
+    (description
+     "@code{node-semver} is a JavaScript implementation of the
+@uref{https://semver.org/, SemVer.org} specification.")
+    (license license:isc)))
+
 (define-public libnode
   (package/inherit node
     (name "libnode")
-- 
2.31.0





^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [bug#47282] [PATCH 06/13] gnu: node: Add node-ms-bootstrap.
  2021-03-20 14:59 ` [bug#47282] [PATCH 01/13] build-system: Rewrite node build system Jelle Licht
                     ` (3 preceding siblings ...)
  2021-03-20 14:59   ` [bug#47282] [PATCH 05/13] gnu: node: Add node-semver-bootstrap Jelle Licht
@ 2021-03-20 14:59   ` Jelle Licht
  2021-03-20 14:59   ` [bug#47282] [PATCH 07/13] gnu: node: Add node-binary-search-bootstrap Jelle Licht
                     ` (6 subsequent siblings)
  11 siblings, 0 replies; 37+ messages in thread
From: Jelle Licht @ 2021-03-20 14:59 UTC (permalink / raw)
  To: 47282

* gnu/packages/node.scm (node-ms-bootstrap): New package.
---
 gnu/packages/node.scm | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)

diff --git a/gnu/packages/node.scm b/gnu/packages/node.scm
index f332d33536..6cc8a2d0d1 100644
--- a/gnu/packages/node.scm
+++ b/gnu/packages/node.scm
@@ -31,8 +31,10 @@
   #:use-module (guix packages)
   #:use-module (guix derivations)
   #:use-module (guix download)
+  #:use-module (guix git-download)
   #:use-module (guix utils)
   #:use-module (guix build-system gnu)
+  #:use-module (guix build-system node)
   #:use-module (gnu packages)
   #:use-module (gnu packages adns)
   #:use-module (gnu packages base)
@@ -248,6 +250,37 @@ devices.")
 @uref{https://semver.org/, SemVer.org} specification.")
     (license license:isc)))
 
+(define-public node-ms-bootstrap
+  (package
+    (name "node-ms")
+    (version "2.1.2")
+    (source
+     (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://github.com/vercel/ms.git")
+             (commit version)))
+       (file-name (git-file-name name version))
+       (sha256
+        (base32
+         "1pjxzbi4j8pinlsc7yxvfrh0b47kb2dc4lfc2rjq4wx5bdwl33fj"))))
+    (build-system node-build-system)
+    (arguments
+     `(#:node ,node-bootstrap
+       #:tests? #f
+       #:phases
+       (modify-phases
+           %standard-phases
+         (delete 'configure)
+         (delete 'build))))
+    (home-page "https://github.com/zeit/ms#readme")
+    (properties '((hidden? . #t)))
+    (synopsis "Tiny millisecond conversion utility")
+    (description
+     "Use this package to easily convert various time formats to
+milliseconds.")
+    (license license:expat)))
+
 (define-public libnode
   (package/inherit node
     (name "libnode")
-- 
2.31.0





^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [bug#47282] [PATCH 07/13] gnu: node: Add node-binary-search-bootstrap.
  2021-03-20 14:59 ` [bug#47282] [PATCH 01/13] build-system: Rewrite node build system Jelle Licht
                     ` (4 preceding siblings ...)
  2021-03-20 14:59   ` [bug#47282] [PATCH 06/13] gnu: node: Add node-ms-bootstrap Jelle Licht
@ 2021-03-20 14:59   ` Jelle Licht
  2021-03-20 14:59   ` [bug#47282] [PATCH 08/13] gnu: node: Add node-debug-bootstrap Jelle Licht
                     ` (5 subsequent siblings)
  11 siblings, 0 replies; 37+ messages in thread
From: Jelle Licht @ 2021-03-20 14:59 UTC (permalink / raw)
  To: 47282

* gnu/packages/node.scm (node-binary-search-bootstrap): New package.
---
 gnu/packages/node.scm | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)

diff --git a/gnu/packages/node.scm b/gnu/packages/node.scm
index 6cc8a2d0d1..b7937b29f4 100644
--- a/gnu/packages/node.scm
+++ b/gnu/packages/node.scm
@@ -281,6 +281,38 @@ devices.")
 milliseconds.")
     (license license:expat)))
 
+(define-public node-binary-search-bootstrap
+  (package
+    (name "node-binary-search")
+    (version "1.3.6")
+    (source
+     (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://github.com/darkskyapp/binary-search.git")
+             (commit (string-append "v" version))))
+       (file-name (git-file-name name version))
+       (sha256
+        (base32
+         "1xr2msdc143cd3xwgq7n3rhzy7j8wrnaidxl0r6l6b6g3mpbpjig"))))
+    (build-system node-build-system)
+    (arguments
+     `(#:node ,node-bootstrap
+       #:tests? #f
+       #:phases
+       (modify-phases
+           %standard-phases
+         (delete 'configure)
+         (delete 'build))))
+    (home-page
+     "https://github.com/darkskyapp/binary-search#readme")
+    (properties '((hidden? . #t)))
+    (synopsis
+     "Tiny binary search function with comparators")
+    (description
+     "This package is a binary search function for @code{Node.js}.")
+    (license license:cc0)))
+
 (define-public libnode
   (package/inherit node
     (name "libnode")
-- 
2.31.0





^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [bug#47282] [PATCH 08/13] gnu: node: Add node-debug-bootstrap.
  2021-03-20 14:59 ` [bug#47282] [PATCH 01/13] build-system: Rewrite node build system Jelle Licht
                     ` (5 preceding siblings ...)
  2021-03-20 14:59   ` [bug#47282] [PATCH 07/13] gnu: node: Add node-binary-search-bootstrap Jelle Licht
@ 2021-03-20 14:59   ` Jelle Licht
  2021-03-20 14:59   ` [bug#47282] [PATCH 09/13] gnu: node: Add node-llparse-builder-bootstrap Jelle Licht
                     ` (4 subsequent siblings)
  11 siblings, 0 replies; 37+ messages in thread
From: Jelle Licht @ 2021-03-20 14:59 UTC (permalink / raw)
  To: 47282

* gnu/packages/node.scm (node-debug-bootstrap): New package.
---
 gnu/packages/node.scm | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)

diff --git a/gnu/packages/node.scm b/gnu/packages/node.scm
index b7937b29f4..58e3fd1acc 100644
--- a/gnu/packages/node.scm
+++ b/gnu/packages/node.scm
@@ -313,6 +313,39 @@ milliseconds.")
      "This package is a binary search function for @code{Node.js}.")
     (license license:cc0)))
 
+(define-public node-debug-bootstrap
+  (package
+    (name "node-debug")
+    (version "4.3.0")
+    (source
+     (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://github.com/visionmedia/debug.git")
+             (commit version)))
+       (file-name (git-file-name name version))
+       (sha256
+        (base32
+         "08g52r1d4yqcsfdfb7n5if33d4cghaq75gx5n9hj6m6fd8jfp2pi"))))
+    (build-system node-build-system)
+    (arguments
+     `(#:node ,node-bootstrap
+       #:tests? #f
+       #:phases
+       (modify-phases
+           %standard-phases
+         (delete 'configure)
+         (delete 'build))))
+    (inputs `(("node-ms" ,node-ms-bootstrap)))
+    (home-page
+     "https://github.com/visionmedia/debug#readme")
+    (properties '((hidden? . #t)))
+    (synopsis "Small debugging utility")
+    (description "This packages contains a tiny JavaScript debugging utility
+modelled after @code{Node.js} core's debugging technique.  It works in
+@code{Node.js} and web browsers.")
+    (license license:expat)))
+
 (define-public libnode
   (package/inherit node
     (name "libnode")
-- 
2.31.0





^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [bug#47282] [PATCH 09/13] gnu: node: Add node-llparse-builder-bootstrap.
  2021-03-20 14:59 ` [bug#47282] [PATCH 01/13] build-system: Rewrite node build system Jelle Licht
                     ` (6 preceding siblings ...)
  2021-03-20 14:59   ` [bug#47282] [PATCH 08/13] gnu: node: Add node-debug-bootstrap Jelle Licht
@ 2021-03-20 14:59   ` Jelle Licht
  2021-03-20 14:59   ` [bug#47282] [PATCH 10/13] gnu: node: Add node-llparse-frontend-bootstrap Jelle Licht
                     ` (3 subsequent siblings)
  11 siblings, 0 replies; 37+ messages in thread
From: Jelle Licht @ 2021-03-20 14:59 UTC (permalink / raw)
  To: 47282

* gnu/packages/node.scm (node-llparse-builder-bootstrap): New package.
---
 gnu/packages/node.scm | 71 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 71 insertions(+)

diff --git a/gnu/packages/node.scm b/gnu/packages/node.scm
index 58e3fd1acc..85e57f5f2d 100644
--- a/gnu/packages/node.scm
+++ b/gnu/packages/node.scm
@@ -346,6 +346,77 @@ modelled after @code{Node.js} core's debugging technique.  It works in
 @code{Node.js} and web browsers.")
     (license license:expat)))
 
+(define-public node-llparse-builder-bootstrap
+  (package
+    (name "node-llparse-builder")
+    (version "1.5.2")
+    (source
+     (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://github.com/indutny/llparse-builder.git")
+             (commit (string-append "v" version))))
+       (file-name (git-file-name name version))
+       (sha256
+        (base32
+         "0r82iiwqsb73k2fxw7842rjjiixllxpyc6yl9cq4ma6ybkf6xmzm"))
+       (modules '((guix build utils)))
+       (snippet
+        '(begin
+           ;; FIXME: Unneeded runtime dependency
+           ;; https://github.com/indutny/llparse-builder/pull/2
+           (substitute* "package.json"
+             (("\"@types/debug.*,") ""))
+           ;; Fix incorrect import semantics
+           ;; https://github.com/evanw/esbuild/issues/477
+           (substitute* (list
+                         "src/node/invoke.ts"
+                         "src/node/base.ts"
+                         "src/node/consume.ts"
+                         "src/node/match.ts"
+                         "src/node/error.ts"
+                         "src/node/pause.ts"
+                         "src/edge.ts"
+                         "src/utils.ts"
+                         "src/loop-checker/index.ts"
+                         "src/loop-checker/lattice.ts"
+                         "src/code/field.ts"
+                         "src/span-allocator.ts")
+             (("\\* as assert") "assert")
+             (("\\* as debugAPI") "debugAPI"))
+           #t))))
+    (build-system node-build-system)
+    (arguments
+     `(#:node ,node-bootstrap
+       #:tests? #f
+       #:phases
+       (modify-phases
+           %standard-phases
+         (delete 'configure)
+         (replace 'build
+           (lambda* (#:key inputs #:allow-other-keys)
+             (let ((esbuild (string-append
+                             (assoc-ref inputs "esbuild")
+                             "/bin/esbuild")))
+               (invoke esbuild
+                       "--platform=node"
+                       "--outfile=lib/builder.js"
+                       "--bundle"
+                       "src/builder.ts")))))))
+    (inputs
+     `(("node-binary-search" ,node-binary-search-bootstrap)
+       ("node-debug" ,node-debug-bootstrap)))
+    (native-inputs
+     `(("esbuild" ,esbuild)))
+    (home-page
+     "https://github.com/indutny/llparse-builder#readme")
+    (properties '((hidden? . #t)))
+    (synopsis
+     "Graph builder for consumption by @code{llparse}")
+    (description
+     "This package builds graphs for consumption by @code{llparse}.")
+    (license license:expat)))
+
 (define-public libnode
   (package/inherit node
     (name "libnode")
-- 
2.31.0





^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [bug#47282] [PATCH 10/13] gnu: node: Add node-llparse-frontend-bootstrap.
  2021-03-20 14:59 ` [bug#47282] [PATCH 01/13] build-system: Rewrite node build system Jelle Licht
                     ` (7 preceding siblings ...)
  2021-03-20 14:59   ` [bug#47282] [PATCH 09/13] gnu: node: Add node-llparse-builder-bootstrap Jelle Licht
@ 2021-03-20 14:59   ` Jelle Licht
  2021-03-20 14:59   ` [bug#47282] [PATCH 11/13] gnu: node: Add node-llparse-bootstrap Jelle Licht
                     ` (2 subsequent siblings)
  11 siblings, 0 replies; 37+ messages in thread
From: Jelle Licht @ 2021-03-20 14:59 UTC (permalink / raw)
  To: 47282

* gnu/packages/node.scm (node-llparse-frontend-bootstrap): New package.
---
 gnu/packages/node.scm | 60 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 60 insertions(+)

diff --git a/gnu/packages/node.scm b/gnu/packages/node.scm
index 85e57f5f2d..41c50e209e 100644
--- a/gnu/packages/node.scm
+++ b/gnu/packages/node.scm
@@ -417,6 +417,66 @@ modelled after @code{Node.js} core's debugging technique.  It works in
      "This package builds graphs for consumption by @code{llparse}.")
     (license license:expat)))
 
+(define-public node-llparse-frontend-bootstrap
+  (package
+    (name "node-llparse-frontend")
+    (version "3.0.0")
+    (source
+     (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://github.com/indutny/llparse-frontend.git")
+             (commit (string-append "v" version))))
+       (file-name (git-file-name name version))
+       (sha256
+        (base32 "1rm9g4ifyip30svm5cgnf0gx7d45jgh4mpf2hkd092xhngmfvicc"))
+       (modules '((guix build utils)))
+       (snippet
+        '(begin
+           ;; Fix incorrect import semantics
+           ;; https://github.com/evanw/esbuild/issues/477
+           (substitute* (list "src/frontend.ts"
+                              "src/code/field-value.ts"
+                              "src/container/index.ts"
+                              "src/container/wrap.ts"
+                              "src/node/sequence.ts"
+                              "src/node/single.ts"
+                              "src/node/table-lookup.ts"
+                              "src/trie/index.ts")
+             (("\\* as assert") "assert")
+             (("\\* as debugAPI") "debugAPI"))
+           #t))))
+    (build-system node-build-system)
+    (arguments
+     `(#:node ,node-bootstrap
+       #:tests? #f
+       #:phases
+       (modify-phases
+           %standard-phases
+         (delete 'configure)
+         (replace 'build
+           (lambda* (#:key inputs #:allow-other-keys)
+             (let ((esbuild (string-append
+                             (assoc-ref inputs "esbuild")
+                             "/bin/esbuild")))
+               (invoke esbuild
+                       "--platform=node"
+                       "--outfile=lib/frontend.js"
+                       "--bundle"
+                       "src/frontend.ts")))))))
+    (inputs
+     `(("node-debug" ,node-debug-bootstrap)
+       ("node-llparse-builder" ,node-llparse-builder-bootstrap)))
+    (native-inputs
+     `(("esbuild" ,esbuild)))
+    (home-page
+     "https://github.com/indutny/llparse-frontend#readme")
+    (properties '((hidden? . #t)))
+    (synopsis "Frontend for @code{llparse} compiler")
+    (description "This package is a frontend for the @code{llparse}
+compiler.")
+    (license license:expat)))
+
 (define-public libnode
   (package/inherit node
     (name "libnode")
-- 
2.31.0





^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [bug#47282] [PATCH 11/13] gnu: node: Add node-llparse-bootstrap.
  2021-03-20 14:59 ` [bug#47282] [PATCH 01/13] build-system: Rewrite node build system Jelle Licht
                     ` (8 preceding siblings ...)
  2021-03-20 14:59   ` [bug#47282] [PATCH 10/13] gnu: node: Add node-llparse-frontend-bootstrap Jelle Licht
@ 2021-03-20 14:59   ` Jelle Licht
  2021-03-20 14:59   ` [bug#47282] [PATCH 12/13] gnu: node: Add llhttp-bootstrap Jelle Licht
  2021-03-20 14:59   ` [bug#47282] [PATCH 13/13] gnu: node: Add node-lts Jelle Licht
  11 siblings, 0 replies; 37+ messages in thread
From: Jelle Licht @ 2021-03-20 14:59 UTC (permalink / raw)
  To: 47282

* gnu/packages/node.scm (node-llparse-bootstrap): New package.
---
 gnu/packages/node.scm | 62 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 62 insertions(+)

diff --git a/gnu/packages/node.scm b/gnu/packages/node.scm
index 41c50e209e..380e959a58 100644
--- a/gnu/packages/node.scm
+++ b/gnu/packages/node.scm
@@ -477,6 +477,68 @@ modelled after @code{Node.js} core's debugging technique.  It works in
 compiler.")
     (license license:expat)))
 
+(define-public node-llparse-bootstrap
+  (package
+    (name "node-llparse")
+    (version "7.1.0")
+    (source
+     (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://github.com/indutny/llparse.git")
+             (commit (string-append "v" version))))
+       (file-name (git-file-name name version))
+       (sha256
+        (base32
+         "10da273iy2if88hp79cwms6c8qpsl1fkgzll6gmqyx5yxv5mkyp6"))
+       (modules '((guix build utils)))
+       (snippet
+        '(begin
+           ;; Fix incorrect import semantics
+           ;; https://github.com/evanw/esbuild/issues/477
+           (substitute* (list "src/compiler/index.ts"
+                              "src/implementation/c/node/base.ts"
+                              "src/implementation/c/node/table-lookup.ts"
+                              "src/implementation/c/compilation.ts"
+                              "src/implementation/c/helpers/match-sequence.ts"
+                              "src/implementation/c/code/mul-add.ts")
+             (("\\* as assert") "assert")
+             (("\\* as debugAPI") "debugAPI"))
+           #t))))
+    (build-system node-build-system)
+    (arguments
+     `(#:node ,node-bootstrap
+       #:tests? #f
+       #:phases
+       (modify-phases
+           %standard-phases
+         (delete 'configure)
+         (replace 'build
+           (lambda* (#:key inputs #:allow-other-keys)
+             (let ((esbuild (string-append
+                             (assoc-ref inputs "esbuild")
+                             "/bin/esbuild")))
+               (invoke esbuild
+                       "--platform=node"
+                       "--outfile=lib/api.js"
+                       "--bundle"
+                       "src/api.ts")))))))
+    (inputs
+     `(("node-debug" ,node-debug-bootstrap)
+       ("node-llparse-frontend"
+        ,node-llparse-frontend-bootstrap)))
+    (native-inputs
+     `(("esbuild" ,esbuild)))
+    (home-page
+     "https://github.com/nodejs/llparse#readme")
+    (properties '((hidden? . #t)))
+    (synopsis
+     "Compile incremental parsers to C code")
+    (description
+     "This package offers an API for compiling an incremental parser
+definition into a C output.")
+    (license license:expat)))
+
 (define-public libnode
   (package/inherit node
     (name "libnode")
-- 
2.31.0





^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [bug#47282] [PATCH 12/13] gnu: node: Add llhttp-bootstrap.
  2021-03-20 14:59 ` [bug#47282] [PATCH 01/13] build-system: Rewrite node build system Jelle Licht
                     ` (9 preceding siblings ...)
  2021-03-20 14:59   ` [bug#47282] [PATCH 11/13] gnu: node: Add node-llparse-bootstrap Jelle Licht
@ 2021-03-20 14:59   ` Jelle Licht
  2021-03-20 14:59   ` [bug#47282] [PATCH 13/13] gnu: node: Add node-lts Jelle Licht
  11 siblings, 0 replies; 37+ messages in thread
From: Jelle Licht @ 2021-03-20 14:59 UTC (permalink / raw)
  To: 47282

* gnu/packages/node.scm (llhttp-bootstrap): New package.
---
 gnu/packages/node.scm | 67 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 67 insertions(+)

diff --git a/gnu/packages/node.scm b/gnu/packages/node.scm
index 380e959a58..d44bec7ca4 100644
--- a/gnu/packages/node.scm
+++ b/gnu/packages/node.scm
@@ -539,6 +539,73 @@ compiler.")
 definition into a C output.")
     (license license:expat)))
 
+(define-public llhttp-bootstrap
+  (package
+    (name "llhttp")
+    (version "2.1.0")
+    (source (origin
+              (method git-fetch)
+              (uri (git-reference
+                    (url "https://github.com/nodejs/llhttp.git")
+                    (commit (string-append "v" version))))
+              (file-name (git-file-name name version))
+              (sha256
+               (base32
+                "08ylnirqrk63h0ww1m79p0bh6rwayrhd4v28p353qlp3qcffwwb0"))
+              (modules '((guix build utils)))
+              (snippet
+               '(begin
+                  ;; Fix incorrect import semantics
+                  ;; https://github.com/evanw/esbuild/issues/477
+                  (substitute* "src/llhttp/http.ts"
+                    (("\\* as assert")
+                     "assert"))
+                  (substitute* "Makefile"
+                    (("npx ts-node bin/generate.ts")
+                     "node bin/generate.js"))
+                  #t))))
+    (build-system gnu-build-system)
+    (arguments
+     `(#:tests? #f                      ; no tests
+       #:make-flags (list "CLANG=gcc"
+                          (string-append "DESTDIR=" (assoc-ref %outputs "out"))
+                          "PREFIX=")
+       #:phases (modify-phases %standard-phases
+                  (replace 'configure
+                    (lambda* (#:key inputs #:allow-other-keys)
+                      (let ((esbuild (string-append
+                                      (assoc-ref inputs "esbuild")
+                                      "/bin/esbuild")))
+                        (invoke esbuild
+                                "--platform=node"
+                                "--outfile=bin/generate.js"
+                                "--bundle" "bin/generate.ts"))))
+                  (add-before 'install 'create-install-directories
+                    (lambda* (#:key outputs #:allow-other-keys)
+                      (let ((out (assoc-ref outputs "out")))
+                        (for-each (lambda (dir)
+                                    (mkdir-p (string-append out dir)))
+                                  (list "/lib" "/include" "/src"))
+                        #t)))
+                  (add-after 'install 'install-src
+                    (lambda* (#:key outputs #:allow-other-keys)
+                      (let* ((out (assoc-ref outputs "out"))
+                             (src-dir (string-append out "/src")))
+                        (install-file "build/c/llhttp.c" src-dir)
+                        #t))))))
+    (native-inputs
+     `(("esbuild" ,esbuild)
+       ("node" ,node-bootstrap)
+       ("node-semver" ,node-semver-bootstrap)
+       ("node-llparse-bootstrap" ,node-llparse-bootstrap)))
+    (home-page "https://github.com/nodejs/llhttp")
+    (properties '((hidden? . #t)))
+    (synopsis "Port of @code{http_parser} to @code{llparse}")
+    (description "@code{llhttp} is a port of @code{http_parser} to TypeScript.
+@code{llparse} is used to generate the output C source file, which can be
+compiled and linked with the embedder's program (like @code{Node.js}).")
+    (license license:expat)))
+
 (define-public libnode
   (package/inherit node
     (name "libnode")
-- 
2.31.0





^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [bug#47282] [PATCH 13/13] gnu: node: Add node-lts
  2021-03-20 14:59 ` [bug#47282] [PATCH 01/13] build-system: Rewrite node build system Jelle Licht
                     ` (10 preceding siblings ...)
  2021-03-20 14:59   ` [bug#47282] [PATCH 12/13] gnu: node: Add llhttp-bootstrap Jelle Licht
@ 2021-03-20 14:59   ` Jelle Licht
  11 siblings, 0 replies; 37+ messages in thread
From: Jelle Licht @ 2021-03-20 14:59 UTC (permalink / raw)
  To: 47282

* gnu/packages/node.scm (node-lts): New package.

wip
---
 gnu/packages/node.scm      | 156 ++++++++++++++++++++++++++++++++++++-
 guix/build-system/node.scm |   2 +-
 2 files changed, 153 insertions(+), 5 deletions(-)

diff --git a/gnu/packages/node.scm b/gnu/packages/node.scm
index d44bec7ca4..2a7e9ca2fa 100644
--- a/gnu/packages/node.scm
+++ b/gnu/packages/node.scm
@@ -542,7 +542,7 @@ definition into a C output.")
 (define-public llhttp-bootstrap
   (package
     (name "llhttp")
-    (version "2.1.0")
+    (version "2.2.1")
     (source (origin
               (method git-fetch)
               (uri (git-reference
@@ -551,7 +551,7 @@ definition into a C output.")
               (file-name (git-file-name name version))
               (sha256
                (base32
-                "08ylnirqrk63h0ww1m79p0bh6rwayrhd4v28p353qlp3qcffwwb0"))
+                "093ag8w0y8irsy0ph7sk06rrs03ic3is41wgxjkgwvc2qys9iqdr"))
               (modules '((guix build utils)))
               (snippet
                '(begin
@@ -566,7 +566,7 @@ definition into a C output.")
                   #t))))
     (build-system gnu-build-system)
     (arguments
-     `(#:tests? #f                      ; no tests
+     `(#:tests? #f                    ; no tests
        #:make-flags (list "CLANG=gcc"
                           (string-append "DESTDIR=" (assoc-ref %outputs "out"))
                           "PREFIX=")
@@ -592,6 +592,8 @@ definition into a C output.")
                       (let* ((out (assoc-ref outputs "out"))
                              (src-dir (string-append out "/src")))
                         (install-file "build/c/llhttp.c" src-dir)
+                        (install-file "src/native/api.c" src-dir)
+                        (install-file "src/native/http.c" src-dir)
                         #t))))))
     (native-inputs
      `(("esbuild" ,esbuild)
@@ -599,13 +601,159 @@ definition into a C output.")
        ("node-semver" ,node-semver-bootstrap)
        ("node-llparse-bootstrap" ,node-llparse-bootstrap)))
     (home-page "https://github.com/nodejs/llhttp")
-    (properties '((hidden? . #t)))
+    ;; (properties '((hidden? . #t)))
     (synopsis "Port of @code{http_parser} to @code{llparse}")
     (description "@code{llhttp} is a port of @code{http_parser} to TypeScript.
 @code{llparse} is used to generate the output C source file, which can be
 compiled and linked with the embedder's program (like @code{Node.js}).")
     (license license:expat)))
 
+(define-public node-lts
+  (package
+    (inherit node)
+    (version "14.16.0")
+    (source (origin
+              (method url-fetch)
+              (uri (string-append "https://nodejs.org/dist/v" version
+                                  "/node-v" version ".tar.xz"))
+              (sha256
+               (base32
+                "19nz2mhmn6ikahxqyna1dn25pb5v3z9vsz9zb2flb6zp2yk4hxjf"))
+              (modules '((guix build utils)))
+              (snippet
+               `(begin
+                  ;; Remove bundled software, where possible
+                  (for-each delete-file-recursively
+                            '("deps/cares"
+                              "deps/icu-small"
+                              "deps/nghttp2"
+                              "deps/openssl"
+                              "deps/zlib"))
+                  (substitute* "Makefile"
+                    ;; Remove references to bundled software.
+                    (("deps/uv/uv.gyp") "")
+                    (("deps/zlib/zlib.gyp") ""))
+                  #t))))
+    (arguments
+     (substitute-keyword-arguments (package-arguments node)
+       ((#:configure-flags configure-flags)
+        ''("--shared-cares"
+           "--shared-libuv"
+           "--shared-nghttp2"
+           "--shared-openssl"
+           "--shared-zlib"
+           "--shared-brotli"
+           "--with-intl=system-icu"))
+       ((#:phases phases)
+        `(modify-phases ,phases
+           (replace 'configure
+             ;; Node's configure script is actually a python script, so we can't
+             ;; run it with bash.
+             (lambda* (#:key outputs (configure-flags '()) inputs
+                       #:allow-other-keys)
+               (let* ((prefix (assoc-ref outputs "out"))
+                      (flags (cons (string-append "--prefix=" prefix)
+                                   configure-flags)))
+                 (format #t "build directory: ~s~%" (getcwd))
+                 (format #t "configure flags: ~s~%" flags)
+                 ;; Node's configure script expects the CC environment variable to
+                 ;; be set.
+                 (setenv "CC" (string-append (assoc-ref inputs "gcc") "/bin/gcc"))
+                 (apply invoke
+                        (string-append (assoc-ref inputs "python")
+                                       "/bin/python3")
+                        "configure" flags))))
+           (replace 'patch-files
+             (lambda* (#:key inputs #:allow-other-keys)
+               ;; Fix hardcoded /bin/sh references.
+               (substitute* '("lib/child_process.js"
+                              "lib/internal/v8_prof_polyfill.js"
+                              "test/parallel/test-child-process-spawnsync-shell.js"
+                              "test/parallel/test-stdio-closed.js"
+                              "test/sequential/test-child-process-emfile.js")
+                 (("'/bin/sh'")
+                  (string-append "'" (which "sh") "'")))
+
+               ;; Fix hardcoded /usr/bin/env references.
+               (substitute* '("test/parallel/test-child-process-default-options.js"
+                              "test/parallel/test-child-process-env.js"
+                              "test/parallel/test-child-process-exec-env.js")
+                 (("'/usr/bin/env'")
+                  (string-append "'" (which "env") "'")))
+               ;; Because we have a custom version of llhttp, we should expect a superset of supported http methods.
+               (substitute* '("test/parallel/test-http-methods.js")
+                 (("assert\\.deepStrictEqual\\(http\\.METHODS, methods\\.sort\\(\\)\\);")
+                  "methods.every(v => assert(http.METHODS.includes(v)));"))
+
+               ;; FIXME: These tests fail in the build container, but they don't
+               ;; seem to be indicative of real problems in practice.
+               (for-each delete-file
+                         '("test/parallel/test-cluster-master-error.js"
+                           "test/parallel/test-cluster-master-kill.js"))
+
+               ;; This requires a DNS resolver.
+               (for-each delete-file
+                         '("test/parallel/test-dns.js"
+                           "test/parallel/test-dns-lookupService-promises.js"))
+
+               ;; TODO: why does this fail. It seems to _almost_ pass, but it parses 1 byte?
+               (delete-file "test/parallel/test-http-server-destroy-socket-on-client-error.js")
+
+               ;; TODO: this seems to fail because of spawning processes?
+               (delete-file "test/parallel/test-fs-write-sigxfsz.js")
+
+               ;; FIXME: This test fails randomly:
+               ;; https://github.com/nodejs/node/issues/31213
+               (delete-file "test/parallel/test-net-listen-after-destroying-stdin.js")
+
+               ;; FIXME: These tests fail on armhf-linux:
+               ;; https://github.com/nodejs/node/issues/31970
+               ,@(if (string-prefix? "arm" (%current-system))
+                     '((for-each delete-file
+                                 '("test/parallel/test-zlib.js"
+                                   "test/parallel/test-zlib-brotli.js"
+                                   "test/parallel/test-zlib-brotli-flush.js"
+                                   "test/parallel/test-zlib-brotli-from-brotli.js"
+                                   "test/parallel/test-zlib-brotli-from-string.js"
+                                   "test/parallel/test-zlib-convenience-methods.js"
+                                   "test/parallel/test-zlib-random-byte-pipes.js"
+                                   "test/parallel/test-zlib-write-after-flush.js")))
+                     '())
+
+               ;; These tests have an expiry date: they depend on the validity of
+               ;; TLS certificates that are bundled with the source.  We want this
+               ;; package to be reproducible forever, so remove those.
+               ;; TODO: Regenerate certs instead.
+               (for-each delete-file
+                         '("test/parallel/test-tls-passphrase.js"
+                           "test/parallel/test-tls-server-verify.js"))
+
+               ;; Replace pre-generated llhttp sources
+               (let ((llhttp (assoc-ref inputs "llhttp"))
+                     ;; (llhttp-src (assoc-ref inputs "llhttp-sources"))
+                     )
+                 (copy-file (string-append llhttp "/src/llhttp.c")
+                            "deps/llhttp/src/llhttp.c")
+                 (copy-file (string-append llhttp "/src/api.c")
+                            "deps/llhttp/src/api.c")
+                 (copy-file (string-append llhttp "/src/http.c")
+                            "deps/llhttp/src/http.c")
+                 (copy-file (string-append llhttp "/include/llhttp.h")
+                            "deps/llhttp/include/llhttp.h"))
+               #t))))))
+    (inputs
+     `(("c-ares" ,c-ares)
+       ("icu4c" ,icu4c-67)
+       ("libuv" ,libuv-node)
+       ("llhttp" ,llhttp-bootstrap)
+       ("google-brotli" ,google-brotli)
+       ("nghttp2" ,nghttp2 "lib")
+       ("openssl" ,openssl)
+       ("zlib" ,zlib)))
+    (native-inputs
+     (alist-replace "python" (list python-3)
+                    (package-native-inputs node)))))
+
 (define-public libnode
   (package/inherit node
     (name "libnode")
diff --git a/guix/build-system/node.scm b/guix/build-system/node.scm
index 560f0ee4da..5737c8ea6e 100644
--- a/guix/build-system/node.scm
+++ b/guix/build-system/node.scm
@@ -39,7 +39,7 @@
   "Return the default Node package."
   ;; Lazily resolve the binding to avoid a circular dependency.
   (let ((node (resolve-interface '(gnu packages node))))
-    (module-ref node 'node)))
+    (module-ref node 'node-lts)))
 
 (define* (lower name
                 #:key source inputs native-inputs outputs system target
-- 
2.31.0





^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [bug#47282] [PATCH 00/13] node going forward
  2021-03-20 14:57 [bug#47282] [PATCH 00/13] node going forward Jelle Licht
  2021-03-20 14:59 ` [bug#47282] [PATCH 01/13] build-system: Rewrite node build system Jelle Licht
@ 2021-03-23  9:05 ` Lars-Dominik Braun
  2021-03-25 15:51   ` Léo Le Bouter via Guix-patches via
  2021-03-30  5:24 ` Timothy Sample
  2 siblings, 1 reply; 37+ messages in thread
From: Lars-Dominik Braun @ 2021-03-23  9:05 UTC (permalink / raw)
  To: Jelle Licht; +Cc: 47282

[-- Attachment #1: Type: text/plain, Size: 795 bytes --]

Hi,

> So, some people seem to be interested in this one; please review and test.
that would be me :)

The first patch currently does not apply cleanly to master, but it’s an easy
merge.

There is a stray “wip” in the commit message of the last patch.

I imported (using the “binary” importer from wip-node-14 and some private
fixes) and built more than 18000 NPM packages with this patchset and the
resulting RStudio is working fine, so this is a welcome improvement for
guix-science.

Cheers,
Lars

-- 
Lars-Dominik Braun
Wissenschaftlicher Mitarbeiter/Research Associate

www.leibniz-psychology.org
ZPID - Leibniz-Institut für Psychologie /
ZPID - Leibniz Institute for Psychology
Universitätsring 15
D-54296 Trier - Germany
Tel.: +49–651–201-4964

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]

^ permalink raw reply	[flat|nested] 37+ messages in thread

* [bug#47282] [PATCH 00/13] node going forward
  2021-03-23  9:05 ` [bug#47282] [PATCH 00/13] node going forward Lars-Dominik Braun
@ 2021-03-25 15:51   ` Léo Le Bouter via Guix-patches via
  2021-03-25 16:14     ` Lars-Dominik Braun
  0 siblings, 1 reply; 37+ messages in thread
From: Léo Le Bouter via Guix-patches via @ 2021-03-25 15:51 UTC (permalink / raw)
  To: Lars-Dominik Braun, Jelle Licht; +Cc: 47282

[-- Attachment #1: Type: text/plain, Size: 436 bytes --]

On Tue, 2021-03-23 at 10:05 +0100, Lars-Dominik Braun wrote:
> I imported (using the “binary” importer from wip-node-14 and some
> private
> fixes) and built more than 18000 NPM packages with this patchset and
> the
> resulting RStudio is working fine, so this is a welcome improvement
> for
> guix-science.

There's somewhere with 18000+ GNU Guix package definitions for NPM
packages? Please share where.

Thank you


[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 37+ messages in thread

* [bug#47282] [PATCH 00/13] node going forward
  2021-03-25 15:51   ` Léo Le Bouter via Guix-patches via
@ 2021-03-25 16:14     ` Lars-Dominik Braun
  0 siblings, 0 replies; 37+ messages in thread
From: Lars-Dominik Braun @ 2021-03-25 16:14 UTC (permalink / raw)
  To: Léo Le Bouter; +Cc: Jelle Licht, 47282, Lars-Dominik Braun

Hi Léo,

> There's somewhere with 18000+ GNU Guix package definitions for NPM
> packages? Please share where.
sorry, the number is completely wrong, no idea why. It’s “just” 473
packages, which is still an insane amount. They’re part of my efforts to
build RStudio 1.4, see
https://github.com/guix-science/guix-science/blob/rstudio-1.4/guix-science/packages/rstudio-node.scm

Lars





^ permalink raw reply	[flat|nested] 37+ messages in thread

* [bug#47282] [PATCH 00/13] node going forward
  2021-03-20 14:57 [bug#47282] [PATCH 00/13] node going forward Jelle Licht
  2021-03-20 14:59 ` [bug#47282] [PATCH 01/13] build-system: Rewrite node build system Jelle Licht
  2021-03-23  9:05 ` [bug#47282] [PATCH 00/13] node going forward Lars-Dominik Braun
@ 2021-03-30  5:24 ` Timothy Sample
  2021-03-30  5:27   ` [bug#47282] [PATCH v2 01/13] build-system: Rewrite node build system Timothy Sample
                     ` (13 more replies)
  2 siblings, 14 replies; 37+ messages in thread
From: Timothy Sample @ 2021-03-30  5:24 UTC (permalink / raw)
  To: Jelle Licht; +Cc: 47282

Hi Jelle,

Jelle Licht <jlicht@fsfe.org> writes:

> So, some people seem to be interested in this one; please review and test.

Now that I’ve finally taken the time to dig into what you’ve done here –
I must say it’s very impressive!

I’ve taken the presumptuous step of re-rolling the series.  The reason
is that all the “(delete 'build)” bits were bothering me.  I decided to
have the build system check the “package.json” file for a build script
before trying to run it.  Since that change required changing all the
other patches, I thought it would be easier to just post the updated
patches.  Also, I’m hoping to spare you some trouble (since you’ve
already gone to a lot!).

Of course, this approach gave me free reign to pick nits.  :)  Below is
a list of bigger things that I changed, but I also adjusted some commit
messages, indentation, descriptions, and other minor things.

    • Add the check for a “build” script as explained above, and adjust
      the “npm-build-system” packages accordingly.

    • Rename “libuv-node” to “libuv-for-node”, as this style is used for
      similar packages.  I also changed the name to just “libuv” and
      marked it hidden.

    • Change the “Fix incorrect import semantics” comments to “Fix
      imports for esbuild”.  To me, if TypeScript’s tsc likes the
      imports, they are correct TypeScript (despite the esbuild bug
      report).

    • Set the llhttp version to 2.1.3, and add a patch to fix
      CVE-2020-8287.  The resulting C source files are identical to the
      ones shipped with Node.js 14.16.0.  This makes the tests a little
      simpler, allowing the removal of the HTTP method superset change
      and fixing the reading one byte failure.

    • Fix the SIGXFSZ failure by fixing a “/bin/sh” in the test.

The final result is still a little messy, but I don’t think we should
hold this back any longer.  It’s a significant step forward, and it puts
us in better shape to improve things incrementally.

WDYT?  Let me know if I made anything worse!  :)  If the altered patches
look good to you, I suggest you go ahead and push them.


-- Tim




^ permalink raw reply	[flat|nested] 37+ messages in thread

* [bug#47282] [PATCH v2 01/13] build-system: Rewrite node build system.
  2021-03-30  5:24 ` Timothy Sample
@ 2021-03-30  5:27   ` Timothy Sample
  2021-03-30  5:27   ` [bug#47282] [PATCH v2 02/13] gnu: Add libuv-for-node Timothy Sample
                     ` (12 subsequent siblings)
  13 siblings, 0 replies; 37+ messages in thread
From: Timothy Sample @ 2021-03-30  5:27 UTC (permalink / raw)
  To: 47282; +Cc: Timothy Sample, Jelle Licht

From: Jelle Licht <jlicht@fsfe.org>

* guix/build/node-build-system.scm: Rewrite it.
* guix/build-system/node.scm: Adjust accordingly.
* gnu/packages/node-xyz.scm (node-semver): Likewise.

Co-authored-by: Timothy Sample <samplet@ngyro.com>
---
 gnu/packages/node-xyz.scm        |   6 +-
 guix/build-system/node.scm       |  27 ++--
 guix/build/node-build-system.scm | 207 +++++++++++++++----------------
 3 files changed, 110 insertions(+), 130 deletions(-)

diff --git a/gnu/packages/node-xyz.scm b/gnu/packages/node-xyz.scm
index b1d6d4ce59..60cc005ea4 100644
--- a/gnu/packages/node-xyz.scm
+++ b/gnu/packages/node-xyz.scm
@@ -261,7 +261,11 @@ function with browser support.")
                 "06biknqb05r9xsmcflm3ygh50pjvdk84x6r79w43kmck4fn3qn5p"))))
     (build-system node-build-system)
     (arguments
-     `(#:tests? #f)) ;; FIXME: Tests depend on node-tap
+     '(#:tests? #f ; FIXME: Tests depend on node-tap
+       #:phases
+       (modify-phases %standard-phases
+         ;; The only dependency to check for is tap, which we don't have.
+         (delete 'configure))))
     (home-page "https://github.com/npm/node-semver")
     (synopsis "Parses semantic versions strings")
     (description
diff --git a/guix/build-system/node.scm b/guix/build-system/node.scm
index a8c5eed09b..4991ed53a5 100644
--- a/guix/build-system/node.scm
+++ b/guix/build-system/node.scm
@@ -1,5 +1,6 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2016 Jelle Licht <jlicht@fsfe.org>
+;;; Copyright © 2019 Timothy Sample <samplet@ngyro.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -17,7 +18,6 @@
 ;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
 
 (define-module (guix build-system node)
-  #:use-module (guix store)
   #:use-module (guix utils)
   #:use-module (guix packages)
   #:use-module (guix derivations)
@@ -25,22 +25,15 @@
   #:use-module (guix build-system)
   #:use-module (guix build-system gnu)
   #:use-module (ice-9 match)
-  #:export (npm-meta-uri
-            %node-build-system-modules
+  #:export (%node-build-system-modules
             node-build
             node-build-system))
 
-(define (npm-meta-uri name)
-  "Return a URI string for the metadata of node module NAME found in the npm
-registry."
-  (string-append "https://registry.npmjs.org/" name))
-
 (define %node-build-system-modules
   ;; Build-side modules imported by default.
   `((guix build node-build-system)
     (guix build json)
-    (guix build union)
-    ,@%gnu-build-system-modules)) ;; TODO: Might be not needed
+    ,@%gnu-build-system-modules))
 
 (define (default-node)
   "Return the default Node package."
@@ -76,7 +69,7 @@ registry."
 
 (define* (node-build store name inputs
                      #:key
-                     (npm-flags ''())
+                     (test-target "test")
                      (tests? #t)
                      (phases '(@ (guix build node-build-system)
                                  %standard-phases))
@@ -86,8 +79,6 @@ registry."
                      (guile #f)
                      (imported-modules %node-build-system-modules)
                      (modules '((guix build node-build-system)
-				(guix build json)
-				(guix build union)
                                 (guix build utils))))
   "Build SOURCE using NODE and INPUTS."
   (define builder
@@ -97,12 +88,10 @@ registry."
                    #:source ,(match (assoc-ref inputs "source")
                                (((? derivation? source))
                                 (derivation->output-path source))
-                               ((source)
-                                source)
-                               (source
-                                source))
+                               ((source) source)
+                               (source source))
                    #:system ,system
-                   #:npm-flags ,npm-flags
+                   #:test-target ,test-target
                    #:tests? ,tests?
                    #:phases ,phases
                    #:outputs %outputs
@@ -129,5 +118,5 @@ registry."
 (define node-build-system
   (build-system
     (name 'node)
-    (description "The standard Node build system")
+    (description "The Node build system")
     (lower lower)))
diff --git a/guix/build/node-build-system.scm b/guix/build/node-build-system.scm
index 7799f03595..a55cab237c 100644
--- a/guix/build/node-build-system.scm
+++ b/guix/build/node-build-system.scm
@@ -1,6 +1,7 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2015 David Thompson <davet@gnu.org>
-;;; Copyright © 2016 Jelle Licht <jlicht@fsfe.org>
+;;; Copyright © 2016, 2020 Jelle Licht <jlicht@fsfe.org>
+;;; Copyright © 2019, 2021 Timothy Sample <samplet@ngyro.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -19,144 +20,130 @@
 
 (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 (guix build json)
+  #:use-module (ice-9 ftw)
   #:use-module (ice-9 match)
-  #:use-module (ice-9 popen)
-  #:use-module (ice-9 regex)
   #:use-module (srfi srfi-1)
-  #:use-module (srfi srfi-26)
   #:export (%standard-phases
             node-build))
 
 ;; Commentary:
 ;;
-;; Builder-side code of the standard Node/npm package build procedure.
+;; Builder-side code of the standard Node/NPM package install procedure.
 ;;
 ;; Code:
 
-(define* (read-package-data #:key (filename "package.json"))
-  (call-with-input-file filename
-    (lambda (port)
-      (read-json port))))
+(define (set-home . _)
+  (with-directory-excursion ".."
+    (let loop ((i 0))
+      (let ((dir (string-append "npm-home-" (number->string i))))
+        (if (directory-exists? dir)
+            (loop (1+ i))
+            (begin
+              (mkdir dir)
+              (setenv "HOME" (string-append (getcwd) "/" dir))
+              (format #t "set HOME to ~s~%" (getenv "HOME")))))))
+  #t)
 
-(define* (build #:key inputs #:allow-other-keys)
-  (define (build-from-package-json? package-file)
-    (let* ((package-data (read-package-data #:filename package-file))
-           (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
-  (cond ((file-exists? "gulpfile.js")
-         (invoke "gulp"))
-        ((file-exists? "gruntfile.js")
-         (invoke "grunt"))
-        ((file-exists? "Makefile")
-         (invoke "make"))
-        ((and (file-exists? "package.json")
-              (build-from-package-json? "package.json"))
-         (invoke "npm" "run" "build")))
+(define (module-name module)
+  (let* ((package.json (string-append module "/package.json"))
+         (package-meta (call-with-input-file package.json read-json)))
+    (assoc-ref package-meta "name")))
+
+(define (index-modules input-paths)
+  (define (list-modules directory)
+    (append-map (lambda (x)
+                  (if (string-prefix? "@" x)
+                      (list-modules (string-append directory "/" x))
+                      (list (string-append directory "/" x))))
+                (filter (lambda (x)
+                          (not (member x '("." ".."))))
+                        (or (scandir directory) '()))))
+  (let ((index (make-hash-table (* 2 (length input-paths)))))
+    (for-each (lambda (dir)
+                (let ((nm (string-append dir "/lib/node_modules")))
+                  (for-each (lambda (module)
+                              (hash-set! index (module-name module) module))
+                            (list-modules nm))))
+              input-paths)
+    index))
+
+(define* (patch-dependencies #:key inputs #:allow-other-keys)
+
+  (define index (index-modules (map cdr inputs)))
+
+  (define (resolve-dependencies package-meta meta-key)
+    (fold (lambda (key+value acc)
+            (match key+value
+              ('@ acc)
+              ((key . value) (acons key (hash-ref index key value) acc))))
+          '()
+          (or (assoc-ref package-meta meta-key) '())))
+
+  (with-atomic-file-replacement "package.json"
+    (lambda (in out)
+      (let ((package-meta (read-json in)))
+        (assoc-set! package-meta "dependencies"
+                    (append
+                     '(@)
+                     (resolve-dependencies package-meta "dependencies")
+                     (resolve-dependencies package-meta "peerDependencies")))
+        (assoc-set! package-meta "devDependencies"
+                    (append
+                     '(@)
+                     (resolve-dependencies package-meta "devDependencies")))
+        (write-json package-meta out))))
   #t)
 
-(define* (link-npm-dependencies #:key inputs #:allow-other-keys)
-  (define (inputs->node-inputs inputs)
-    "Filter the directory part from INPUTS."
-    (filter (lambda (input)
-              (match input
-                ((name . _) (node-package? name))))
-            inputs))
-  (define (inputs->directories inputs)
-    "Extract the directory part from INPUTS."
-    (match inputs
-      (((names . directories) ...)
-       directories)))
-  (define (make-node-path root)
-    (string-append root "/lib/node_modules/"))
-
-  (let ((input-node-directories (inputs->directories
-                                 (inputs->node-inputs inputs))))
-    (union-build "node_modules"
-                 (map make-node-path input-node-directories))
+(define* (configure #:key outputs inputs #:allow-other-keys)
+  (let ((npm (string-append (assoc-ref inputs "node") "/bin/npm")))
+    (invoke npm "--offline" "--ignore-scripts" "install")
     #t))
 
-(define configure link-npm-dependencies)
+(define* (build #:key inputs #:allow-other-keys)
+  (let ((package-meta (call-with-input-file "package.json" read-json)))
+    (if (and=> (assoc-ref package-meta "scripts")
+               (lambda (scripts)
+                 (assoc-ref scripts "build")))
+        (let ((npm (string-append (assoc-ref inputs "node") "/bin/npm")))
+          (invoke npm "run" "build"))
+        (format #t "there is no build script to run~%"))
+    #t))
 
-(define* (check #:key tests? #:allow-other-keys)
+(define* (check #:key tests? inputs #:allow-other-keys)
   "Run 'npm test' if TESTS?"
   (if tests?
-      ;; Should only be enabled once we know that there are tests
-      (invoke "npm" "test"))
+      (let ((npm (string-append (assoc-ref inputs "node") "/bin/npm")))
+        (invoke npm "test"))
+      (format #t "test suite not run~%"))
   #t)
 
-(define (node-package? name)
-  "Check if NAME correspond to the name of an Node package."
-  (string-prefix? "node-" name))
+(define* (repack #:key inputs #:allow-other-keys)
+  (invoke "tar" "-czf" "../package.tgz" ".")
+  #t)
 
 (define* (install #:key outputs inputs #:allow-other-keys)
-  "Install the node module to the output store item. The module itself is
-installed in a subdirectory of @file{node_modules} and its runtime dependencies
-as defined by @file{package.json} are symlinked into a @file{node_modules}
-subdirectory of the module's directory. Additionally, binaries are installed in
-the @file{bin} directory."
-  (let* ((out                  (assoc-ref outputs "out"))
-         (target               (string-append out "/lib"))
-         (binaries             (string-append out "/bin"))
-         (data                 (read-package-data))
-         (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))
-    ;; Remove references to dependencies
-    (delete-file-recursively
-      (string-append target "/node_modules/" modulename "/node_modules"))
-    (cond
-      ((string? binary-configuration)
-       (begin
-         (mkdir-p binaries)
-         (symlink (string-append target "/node_modules/" modulename "/"
-				 binary-configuration)
-                  (string-append binaries "/" modulename))))
-      ((list? binary-configuration)
-       (for-each
-         (lambda (conf)
-           (match conf
-             ((key . value)
-              (begin
-                (mkdir-p (dirname (string-append binaries "/" key)))
-                (symlink (string-append target "/node_modules/" modulename "/"
-					value)
-                         (string-append binaries "/" key))))))
-         binary-configuration)))
-    (when dependencies
-      (mkdir-p
-        (string-append target "/node_modules/" modulename "/node_modules"))
-      (for-each
-        (lambda (dependency)
-          (let ((dependency (car dependency)))
-            (symlink
-              (string-append (assoc-ref inputs (string-append "node-" dependency))
-                             "/lib/node_modules/" dependency)
-              (string-append target "/node_modules/" modulename
-                             "/node_modules/" dependency))))
-        dependencies))
+  "Install the node module to the output store item."
+  (let ((out (assoc-ref outputs "out"))
+        (npm (string-append (assoc-ref inputs "node") "/bin/npm")))
+    (invoke npm "--prefix" out
+            "--global"
+            "--offline"
+            "--loglevel" "info"
+            "--production"
+            "install" "../package.tgz")
     #t))
 
-
 (define %standard-phases
   (modify-phases gnu:%standard-phases
+    (add-after 'unpack 'set-home set-home)
+    (add-before 'configure 'patch-dependencies patch-dependencies)
     (replace 'configure configure)
     (replace 'build build)
-    (replace 'install install)
-    (delete 'check)
-    (add-after 'install 'check check)
-    (delete 'strip)))
+    (replace 'check check)
+    (add-before 'install 'repack repack)
+    (replace 'install install)))
 
 (define* (node-build #:key inputs (phases %standard-phases)
                      #:allow-other-keys #:rest args)
-- 
2.31.0





^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [bug#47282] [PATCH v2 02/13] gnu: Add libuv-for-node
  2021-03-30  5:24 ` Timothy Sample
  2021-03-30  5:27   ` [bug#47282] [PATCH v2 01/13] build-system: Rewrite node build system Timothy Sample
@ 2021-03-30  5:27   ` Timothy Sample
  2021-03-30  5:27   ` [bug#47282] [PATCH v2 03/13] gnu: node: Use license prefix Timothy Sample
                     ` (11 subsequent siblings)
  13 siblings, 0 replies; 37+ messages in thread
From: Timothy Sample @ 2021-03-30  5:27 UTC (permalink / raw)
  To: 47282; +Cc: Jelle Licht

From: Jelle Licht <jlicht@fsfe.org>

* gnu/packages/libevent.scm (libuv-for-node): New variable.
---
 gnu/packages/libevent.scm | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/gnu/packages/libevent.scm b/gnu/packages/libevent.scm
index 7109d9a88d..0e683570d3 100644
--- a/gnu/packages/libevent.scm
+++ b/gnu/packages/libevent.scm
@@ -134,6 +134,22 @@ resolution, asynchronous file system operations, and threading primitives.")
     ;; details.  Documentation is CC-BY 4.0 as of 1.12.0; see 'LICENSE-docs'.
     (license (list expat cc-by4.0))))
 
+(define-public libuv-for-node
+  ;; When upgrading Node, also upgrade this. Get the version from
+  ;; https://github.com/nodejs/node/blob/master/deps/uv/include/uv/version.h
+  (package
+    (inherit libuv)
+    (name "libuv")
+    (version "1.40.0")
+    (source (origin
+              (method url-fetch)
+              (uri (string-append "https://dist.libuv.org/dist/v" version
+                                  "/libuv-v" version ".tar.gz"))
+              (sha256
+               (base32
+                "1551k3ab27vbg9517l9b4iqbramwxdkwgpf53knas05cbfwhvab1"))))
+    (properties '((hidden? . #t)))))
+
 (define-public perl-anyevent
   (package
     (name "perl-anyevent")
-- 
2.31.0





^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [bug#47282] [PATCH v2 03/13] gnu: node: Use license prefix.
  2021-03-30  5:24 ` Timothy Sample
  2021-03-30  5:27   ` [bug#47282] [PATCH v2 01/13] build-system: Rewrite node build system Timothy Sample
  2021-03-30  5:27   ` [bug#47282] [PATCH v2 02/13] gnu: Add libuv-for-node Timothy Sample
@ 2021-03-30  5:27   ` Timothy Sample
  2021-03-30  5:27   ` [bug#47282] [PATCH v2 04/13] gnu: Add node-bootstrap Timothy Sample
                     ` (10 subsequent siblings)
  13 siblings, 0 replies; 37+ messages in thread
From: Timothy Sample @ 2021-03-30  5:27 UTC (permalink / raw)
  To: 47282; +Cc: Jelle Licht

From: Jelle Licht <jlicht@fsfe.org>

* gnu/packages/node.scm (node)[license]: Use prefix for license.
---
 gnu/packages/node.scm | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gnu/packages/node.scm b/gnu/packages/node.scm
index a0df3d2cad..82a2ca7ce0 100644
--- a/gnu/packages/node.scm
+++ b/gnu/packages/node.scm
@@ -26,7 +26,7 @@
 ;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
 
 (define-module (gnu packages node)
-  #:use-module ((guix licenses) #:select (expat))
+  #:use-module ((guix licenses) #:prefix license:)
   #:use-module ((guix build utils) #:select (alist-replace))
   #:use-module (guix packages)
   #:use-module (guix derivations)
@@ -207,7 +207,7 @@ event-driven, non-blocking I/O model that makes it lightweight and efficient,
 perfect for data-intensive real-time applications that run across distributed
 devices.")
     (home-page "https://nodejs.org/")
-    (license expat)
+    (license license:expat)
     (properties '((max-silent-time . 7200)     ;2h, needed on ARM
                   (timeout . 21600)))))        ;6h
 
-- 
2.31.0





^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [bug#47282] [PATCH v2 04/13] gnu: Add node-bootstrap.
  2021-03-30  5:24 ` Timothy Sample
                     ` (2 preceding siblings ...)
  2021-03-30  5:27   ` [bug#47282] [PATCH v2 03/13] gnu: node: Use license prefix Timothy Sample
@ 2021-03-30  5:27   ` Timothy Sample
  2021-03-30  5:27   ` [bug#47282] [PATCH v2 05/13] gnu: Add node-semver-bootstrap Timothy Sample
                     ` (9 subsequent siblings)
  13 siblings, 0 replies; 37+ messages in thread
From: Timothy Sample @ 2021-03-30  5:27 UTC (permalink / raw)
  To: 47282; +Cc: Jelle Licht

From: Jelle Licht <jlicht@fsfe.org>

* gnu/packages/node (node-bootstrap): Add hidden alias for node.
---
 gnu/packages/node.scm | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/gnu/packages/node.scm b/gnu/packages/node.scm
index 82a2ca7ce0..73d022d87f 100644
--- a/gnu/packages/node.scm
+++ b/gnu/packages/node.scm
@@ -211,6 +211,11 @@ devices.")
     (properties '((max-silent-time . 7200)     ;2h, needed on ARM
                   (timeout . 21600)))))        ;6h
 
+;; This should be the latest version of node that still builds without
+;; depending on llhttp.
+(define-public node-bootstrap
+  (hidden-package node))
+
 (define-public libnode
   (package/inherit node
     (name "libnode")
-- 
2.31.0





^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [bug#47282] [PATCH v2 05/13] gnu: Add node-semver-bootstrap.
  2021-03-30  5:24 ` Timothy Sample
                     ` (3 preceding siblings ...)
  2021-03-30  5:27   ` [bug#47282] [PATCH v2 04/13] gnu: Add node-bootstrap Timothy Sample
@ 2021-03-30  5:27   ` Timothy Sample
  2021-03-30  5:27   ` [bug#47282] [PATCH v2 06/13] gnu: Add node-ms-bootstrap Timothy Sample
                     ` (8 subsequent siblings)
  13 siblings, 0 replies; 37+ messages in thread
From: Timothy Sample @ 2021-03-30  5:27 UTC (permalink / raw)
  To: 47282; +Cc: Jelle Licht

From: Jelle Licht <jlicht@fsfe.org>

* gnu/packages/node.scm (node-semver-bootstrap): New variable.
---
 gnu/packages/node.scm | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/gnu/packages/node.scm b/gnu/packages/node.scm
index 73d022d87f..773cef3716 100644
--- a/gnu/packages/node.scm
+++ b/gnu/packages/node.scm
@@ -41,6 +41,7 @@
   #:use-module (gnu packages icu4c)
   #:use-module (gnu packages libevent)
   #:use-module (gnu packages linux)
+  #:use-module (gnu packages node-xyz)
   #:use-module (gnu packages perl)
   #:use-module (gnu packages pkg-config)
   #:use-module (gnu packages python)
@@ -216,6 +217,35 @@ devices.")
 (define-public node-bootstrap
   (hidden-package node))
 
+;; Duplicate of node-semver
+(define-public node-semver-bootstrap
+  (package
+    (name "node-semver")
+    (version "7.2.1")
+    (source (origin
+              (method git-fetch)
+              (uri (git-reference
+                    (url "https://github.com/npm/node-semver")
+                    (commit (string-append "v" version))))
+              (file-name (git-file-name name version))
+              (sha256
+               (base32
+                "06biknqb05r9xsmcflm3ygh50pjvdk84x6r79w43kmck4fn3qn5p"))))
+    (build-system node-build-system)
+    (arguments
+     `(#:node ,node-bootstrap
+       #:tests? #f
+       #:phases
+       (modify-phases %standard-phases
+         (delete 'configure))))
+    (home-page "https://github.com/npm/node-semver")
+    (properties '((hidden? . #t)))
+    (synopsis "Parses semantic versions strings")
+    (description
+     "@code{node-semver} is a JavaScript implementation of the
+@uref{https://semver.org/, SemVer.org} specification.")
+    (license license:isc)))
+
 (define-public libnode
   (package/inherit node
     (name "libnode")
-- 
2.31.0





^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [bug#47282] [PATCH v2 06/13] gnu: Add node-ms-bootstrap.
  2021-03-30  5:24 ` Timothy Sample
                     ` (4 preceding siblings ...)
  2021-03-30  5:27   ` [bug#47282] [PATCH v2 05/13] gnu: Add node-semver-bootstrap Timothy Sample
@ 2021-03-30  5:27   ` Timothy Sample
  2021-03-30  5:27   ` [bug#47282] [PATCH v2 07/13] gnu: Add node-binary-search-bootstrap Timothy Sample
                     ` (7 subsequent siblings)
  13 siblings, 0 replies; 37+ messages in thread
From: Timothy Sample @ 2021-03-30  5:27 UTC (permalink / raw)
  To: 47282; +Cc: Jelle Licht

From: Jelle Licht <jlicht@fsfe.org>

* gnu/packages/node.scm (node-ms-bootstrap): New variable.
---
 gnu/packages/node.scm | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/gnu/packages/node.scm b/gnu/packages/node.scm
index 773cef3716..1d17502df7 100644
--- a/gnu/packages/node.scm
+++ b/gnu/packages/node.scm
@@ -31,8 +31,10 @@
   #:use-module (guix packages)
   #:use-module (guix derivations)
   #:use-module (guix download)
+  #:use-module (guix git-download)
   #:use-module (guix utils)
   #:use-module (guix build-system gnu)
+  #:use-module (guix build-system node)
   #:use-module (gnu packages)
   #:use-module (gnu packages adns)
   #:use-module (gnu packages base)
@@ -246,6 +248,34 @@ devices.")
 @uref{https://semver.org/, SemVer.org} specification.")
     (license license:isc)))
 
+(define-public node-ms-bootstrap
+  (package
+    (name "node-ms")
+    (version "2.1.2")
+    (source
+     (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://github.com/vercel/ms.git")
+             (commit version)))
+       (file-name (git-file-name name version))
+       (sha256
+        (base32
+         "1pjxzbi4j8pinlsc7yxvfrh0b47kb2dc4lfc2rjq4wx5bdwl33fj"))))
+    (build-system node-build-system)
+    (arguments
+     `(#:node ,node-bootstrap
+       #:tests? #f
+       #:phases
+       (modify-phases %standard-phases
+         (delete 'configure))))
+    (home-page "https://github.com/zeit/ms#readme")
+    (properties '((hidden? . #t)))
+    (synopsis "Tiny millisecond conversion utility")
+    (description "Use this package to easily convert various time
+formats to milliseconds.")
+    (license license:expat)))
+
 (define-public libnode
   (package/inherit node
     (name "libnode")
-- 
2.31.0





^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [bug#47282] [PATCH v2 07/13] gnu: Add node-binary-search-bootstrap.
  2021-03-30  5:24 ` Timothy Sample
                     ` (5 preceding siblings ...)
  2021-03-30  5:27   ` [bug#47282] [PATCH v2 06/13] gnu: Add node-ms-bootstrap Timothy Sample
@ 2021-03-30  5:27   ` Timothy Sample
  2021-03-30  5:27   ` [bug#47282] [PATCH v2 08/13] gnu: Add node-debug-bootstrap Timothy Sample
                     ` (6 subsequent siblings)
  13 siblings, 0 replies; 37+ messages in thread
From: Timothy Sample @ 2021-03-30  5:27 UTC (permalink / raw)
  To: 47282; +Cc: Jelle Licht

From: Jelle Licht <jlicht@fsfe.org>

* gnu/packages/node.scm (node-binary-search-bootstrap): New variable.
---
 gnu/packages/node.scm | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/gnu/packages/node.scm b/gnu/packages/node.scm
index 1d17502df7..21d6052c06 100644
--- a/gnu/packages/node.scm
+++ b/gnu/packages/node.scm
@@ -276,6 +276,33 @@ devices.")
 formats to milliseconds.")
     (license license:expat)))
 
+(define-public node-binary-search-bootstrap
+  (package
+    (name "node-binary-search")
+    (version "1.3.6")
+    (source
+     (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://github.com/darkskyapp/binary-search.git")
+             (commit (string-append "v" version))))
+       (file-name (git-file-name name version))
+       (sha256
+        (base32
+         "1xr2msdc143cd3xwgq7n3rhzy7j8wrnaidxl0r6l6b6g3mpbpjig"))))
+    (build-system node-build-system)
+    (arguments
+     `(#:node ,node-bootstrap
+       #:tests? #f
+       #:phases
+       (modify-phases %standard-phases
+         (delete 'configure))))
+    (home-page "https://github.com/darkskyapp/binary-search#readme")
+    (properties '((hidden? . #t)))
+    (synopsis "Tiny binary search function with comparators")
+    (description "This package is a binary search function for Node.js.")
+    (license license:cc0)))
+
 (define-public libnode
   (package/inherit node
     (name "libnode")
-- 
2.31.0





^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [bug#47282] [PATCH v2 08/13] gnu: Add node-debug-bootstrap.
  2021-03-30  5:24 ` Timothy Sample
                     ` (6 preceding siblings ...)
  2021-03-30  5:27   ` [bug#47282] [PATCH v2 07/13] gnu: Add node-binary-search-bootstrap Timothy Sample
@ 2021-03-30  5:27   ` Timothy Sample
  2021-03-30  5:27   ` [bug#47282] [PATCH v2 09/13] gnu: Add node-llparse-builder-bootstrap Timothy Sample
                     ` (5 subsequent siblings)
  13 siblings, 0 replies; 37+ messages in thread
From: Timothy Sample @ 2021-03-30  5:27 UTC (permalink / raw)
  To: 47282; +Cc: Jelle Licht

From: Jelle Licht <jlicht@fsfe.org>

* gnu/packages/node.scm (node-debug-bootstrap): New variable.
---
 gnu/packages/node.scm | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/gnu/packages/node.scm b/gnu/packages/node.scm
index 21d6052c06..6c4c02265d 100644
--- a/gnu/packages/node.scm
+++ b/gnu/packages/node.scm
@@ -303,6 +303,36 @@ formats to milliseconds.")
     (description "This package is a binary search function for Node.js.")
     (license license:cc0)))
 
+(define-public node-debug-bootstrap
+  (package
+    (name "node-debug")
+    (version "4.3.0")
+    (source
+     (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://github.com/visionmedia/debug.git")
+             (commit version)))
+       (file-name (git-file-name name version))
+       (sha256
+        (base32
+         "08g52r1d4yqcsfdfb7n5if33d4cghaq75gx5n9hj6m6fd8jfp2pi"))))
+    (build-system node-build-system)
+    (arguments
+     `(#:node ,node-bootstrap
+       #:tests? #f
+       #:phases
+       (modify-phases %standard-phases
+         (delete 'configure))))
+    (inputs `(("node-ms" ,node-ms-bootstrap)))
+    (home-page "https://github.com/visionmedia/debug#readme")
+    (properties '((hidden? . #t)))
+    (synopsis "Small debugging utility")
+    (description "This package contains a tiny JavaScript debugging
+utility modelled after Node.js core's debugging technique.  It works in
+Node.js and web browsers.")
+    (license license:expat)))
+
 (define-public libnode
   (package/inherit node
     (name "libnode")
-- 
2.31.0





^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [bug#47282] [PATCH v2 09/13] gnu: Add node-llparse-builder-bootstrap.
  2021-03-30  5:24 ` Timothy Sample
                     ` (7 preceding siblings ...)
  2021-03-30  5:27   ` [bug#47282] [PATCH v2 08/13] gnu: Add node-debug-bootstrap Timothy Sample
@ 2021-03-30  5:27   ` Timothy Sample
  2021-03-30  5:27   ` [bug#47282] [PATCH v2 10/13] gnu: Add node-llparse-frontend-bootstrap Timothy Sample
                     ` (4 subsequent siblings)
  13 siblings, 0 replies; 37+ messages in thread
From: Timothy Sample @ 2021-03-30  5:27 UTC (permalink / raw)
  To: 47282; +Cc: Jelle Licht

From: Jelle Licht <jlicht@fsfe.org>

* gnu/packages/node.scm (node-llparse-builder-bootstrap): New variable.
---
 gnu/packages/node.scm | 65 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 65 insertions(+)

diff --git a/gnu/packages/node.scm b/gnu/packages/node.scm
index 6c4c02265d..570d4521ac 100644
--- a/gnu/packages/node.scm
+++ b/gnu/packages/node.scm
@@ -333,6 +333,71 @@ utility modelled after Node.js core's debugging technique.  It works in
 Node.js and web browsers.")
     (license license:expat)))
 
+(define-public node-llparse-builder-bootstrap
+  (package
+    (name "node-llparse-builder")
+    (version "1.5.2")
+    (source
+     (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://github.com/indutny/llparse-builder.git")
+             (commit (string-append "v" version))))
+       (file-name (git-file-name name version))
+       (sha256
+        (base32
+         "0r82iiwqsb73k2fxw7842rjjiixllxpyc6yl9cq4ma6ybkf6xmzm"))
+       (modules '((guix build utils)))
+       (snippet
+        '(begin
+           ;; FIXME: Unneeded runtime dependency.
+           ;; https://github.com/indutny/llparse-builder/pull/2
+           (substitute* "package.json"
+             (("\"@types/debug.*,") ""))
+           ;; Fix imports for esbuild.
+           ;; https://github.com/evanw/esbuild/issues/477
+           (substitute* '("src/node/invoke.ts"
+                          "src/node/base.ts"
+                          "src/node/consume.ts"
+                          "src/node/match.ts"
+                          "src/node/error.ts"
+                          "src/node/pause.ts"
+                          "src/edge.ts"
+                          "src/utils.ts"
+                          "src/loop-checker/index.ts"
+                          "src/loop-checker/lattice.ts"
+                          "src/code/field.ts"
+                          "src/span-allocator.ts")
+             (("\\* as assert") "assert")
+             (("\\* as debugAPI") "debugAPI"))
+           #t))))
+    (build-system node-build-system)
+    (arguments
+     `(#:node ,node-bootstrap
+       #:tests? #f
+       #:phases
+       (modify-phases %standard-phases
+         (delete 'configure)
+         (replace 'build
+           (lambda* (#:key inputs #:allow-other-keys)
+             (let ((esbuild (string-append (assoc-ref inputs "esbuild")
+                                           "/bin/esbuild")))
+               (invoke esbuild
+                       "--platform=node"
+                       "--outfile=lib/builder.js"
+                       "--bundle"
+                       "src/builder.ts")))))))
+    (inputs
+     `(("node-binary-search" ,node-binary-search-bootstrap)
+       ("node-debug" ,node-debug-bootstrap)))
+    (native-inputs
+     `(("esbuild" ,esbuild)))
+    (home-page "https://github.com/indutny/llparse-builder#readme")
+    (properties '((hidden? . #t)))
+    (synopsis "Graph builder for consumption by llparse")
+    (description "This package builds graphs for consumption by llparse.")
+    (license license:expat)))
+
 (define-public libnode
   (package/inherit node
     (name "libnode")
-- 
2.31.0





^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [bug#47282] [PATCH v2 10/13] gnu: Add node-llparse-frontend-bootstrap.
  2021-03-30  5:24 ` Timothy Sample
                     ` (8 preceding siblings ...)
  2021-03-30  5:27   ` [bug#47282] [PATCH v2 09/13] gnu: Add node-llparse-builder-bootstrap Timothy Sample
@ 2021-03-30  5:27   ` Timothy Sample
  2021-03-30  5:27   ` [bug#47282] [PATCH v2 11/13] gnu: Add node-llparse-bootstrap Timothy Sample
                     ` (3 subsequent siblings)
  13 siblings, 0 replies; 37+ messages in thread
From: Timothy Sample @ 2021-03-30  5:27 UTC (permalink / raw)
  To: 47282; +Cc: Jelle Licht

From: Jelle Licht <jlicht@fsfe.org>

* gnu/packages/node.scm (node-llparse-frontend-bootstrap): New variable.
---
 gnu/packages/node.scm | 56 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 56 insertions(+)

diff --git a/gnu/packages/node.scm b/gnu/packages/node.scm
index 570d4521ac..16c3decdd4 100644
--- a/gnu/packages/node.scm
+++ b/gnu/packages/node.scm
@@ -398,6 +398,62 @@ Node.js and web browsers.")
     (description "This package builds graphs for consumption by llparse.")
     (license license:expat)))
 
+(define-public node-llparse-frontend-bootstrap
+  (package
+    (name "node-llparse-frontend")
+    (version "3.0.0")
+    (source
+     (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://github.com/indutny/llparse-frontend.git")
+             (commit (string-append "v" version))))
+       (file-name (git-file-name name version))
+       (sha256
+        (base32 "1rm9g4ifyip30svm5cgnf0gx7d45jgh4mpf2hkd092xhngmfvicc"))
+       (modules '((guix build utils)))
+       (snippet
+        '(begin
+           ;; Fix imports for esbuild.
+           ;; https://github.com/evanw/esbuild/issues/477
+           (substitute* '("src/frontend.ts"
+                          "src/code/field-value.ts"
+                          "src/container/index.ts"
+                          "src/container/wrap.ts"
+                          "src/node/sequence.ts"
+                          "src/node/single.ts"
+                          "src/node/table-lookup.ts"
+                          "src/trie/index.ts")
+             (("\\* as assert") "assert")
+             (("\\* as debugAPI") "debugAPI"))
+           #t))))
+    (build-system node-build-system)
+    (arguments
+     `(#:node ,node-bootstrap
+       #:tests? #f
+       #:phases
+       (modify-phases %standard-phases
+         (delete 'configure)
+         (replace 'build
+           (lambda* (#:key inputs #:allow-other-keys)
+             (let ((esbuild (string-append (assoc-ref inputs "esbuild")
+                                           "/bin/esbuild")))
+               (invoke esbuild
+                       "--platform=node"
+                       "--outfile=lib/frontend.js"
+                       "--bundle"
+                       "src/frontend.ts")))))))
+    (inputs
+     `(("node-debug" ,node-debug-bootstrap)
+       ("node-llparse-builder" ,node-llparse-builder-bootstrap)))
+    (native-inputs
+     `(("esbuild" ,esbuild)))
+    (home-page "https://github.com/indutny/llparse-frontend#readme")
+    (properties '((hidden? . #t)))
+    (synopsis "Frontend for the llparse compiler")
+    (description "This package is a frontend for the llparse compiler.")
+    (license license:expat)))
+
 (define-public libnode
   (package/inherit node
     (name "libnode")
-- 
2.31.0





^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [bug#47282] [PATCH v2 11/13] gnu: Add node-llparse-bootstrap.
  2021-03-30  5:24 ` Timothy Sample
                     ` (9 preceding siblings ...)
  2021-03-30  5:27   ` [bug#47282] [PATCH v2 10/13] gnu: Add node-llparse-frontend-bootstrap Timothy Sample
@ 2021-03-30  5:27   ` Timothy Sample
  2021-03-30  5:27   ` [bug#47282] [PATCH v2 12/13] gnu: Add llhttp-bootstrap Timothy Sample
                     ` (2 subsequent siblings)
  13 siblings, 0 replies; 37+ messages in thread
From: Timothy Sample @ 2021-03-30  5:27 UTC (permalink / raw)
  To: 47282; +Cc: Jelle Licht

From: Jelle Licht <jlicht@fsfe.org>

* gnu/packages/node.scm (node-llparse-bootstrap): New variable.
---
 gnu/packages/node.scm | 56 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 56 insertions(+)

diff --git a/gnu/packages/node.scm b/gnu/packages/node.scm
index 16c3decdd4..5336012e43 100644
--- a/gnu/packages/node.scm
+++ b/gnu/packages/node.scm
@@ -454,6 +454,62 @@ Node.js and web browsers.")
     (description "This package is a frontend for the llparse compiler.")
     (license license:expat)))
 
+(define-public node-llparse-bootstrap
+  (package
+    (name "node-llparse")
+    (version "7.1.0")
+    (source
+     (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://github.com/indutny/llparse.git")
+             (commit (string-append "v" version))))
+       (file-name (git-file-name name version))
+       (sha256
+        (base32
+         "10da273iy2if88hp79cwms6c8qpsl1fkgzll6gmqyx5yxv5mkyp6"))
+       (modules '((guix build utils)))
+       (snippet
+        '(begin
+           ;; Fix imports for esbuild.
+           ;; https://github.com/evanw/esbuild/issues/477
+           (substitute* '("src/compiler/index.ts"
+                          "src/implementation/c/node/base.ts"
+                          "src/implementation/c/node/table-lookup.ts"
+                          "src/implementation/c/compilation.ts"
+                          "src/implementation/c/helpers/match-sequence.ts"
+                          "src/implementation/c/code/mul-add.ts")
+             (("\\* as assert") "assert")
+             (("\\* as debugAPI") "debugAPI"))
+           #t))))
+    (build-system node-build-system)
+    (arguments
+     `(#:node ,node-bootstrap
+       #:tests? #f
+       #:phases
+       (modify-phases %standard-phases
+         (delete 'configure)
+         (replace 'build
+           (lambda* (#:key inputs #:allow-other-keys)
+             (let ((esbuild (string-append (assoc-ref inputs "esbuild")
+                                           "/bin/esbuild")))
+               (invoke esbuild
+                       "--platform=node"
+                       "--outfile=lib/api.js"
+                       "--bundle"
+                       "src/api.ts")))))))
+    (inputs
+     `(("node-debug" ,node-debug-bootstrap)
+       ("node-llparse-frontend" ,node-llparse-frontend-bootstrap)))
+    (native-inputs
+     `(("esbuild" ,esbuild)))
+    (home-page "https://github.com/nodejs/llparse#readme")
+    (properties '((hidden? . #t)))
+    (synopsis "Compile incremental parsers to C code")
+    (description "This package offers an API for compiling an incremental
+parser definition into a C output.")
+    (license license:expat)))
+
 (define-public libnode
   (package/inherit node
     (name "libnode")
-- 
2.31.0





^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [bug#47282] [PATCH v2 12/13] gnu: Add llhttp-bootstrap.
  2021-03-30  5:24 ` Timothy Sample
                     ` (10 preceding siblings ...)
  2021-03-30  5:27   ` [bug#47282] [PATCH v2 11/13] gnu: Add node-llparse-bootstrap Timothy Sample
@ 2021-03-30  5:27   ` Timothy Sample
  2021-03-30  6:59     ` Efraim Flashner
  2021-03-30  5:27   ` [bug#47282] [PATCH v2 13/13] gnu: Add node-lts Timothy Sample
  2021-04-02 16:18   ` bug#47282: [PATCH 00/13] node going forward Jelle Licht
  13 siblings, 1 reply; 37+ messages in thread
From: Timothy Sample @ 2021-03-30  5:27 UTC (permalink / raw)
  To: 47282; +Cc: Jelle Licht

From: Jelle Licht <jlicht@fsfe.org>

* gnu/packages/patches/llhttp-bootstrap-CVE-2020-8287.patch: New file.
* gnu/local.mk (dist_patch_DATA): Add it.
* gnu/packages/node.scm (llhttp-bootstrap): New variable.
---
 gnu/local.mk                                  |   1 +
 gnu/packages/node.scm                         |  70 ++++++++++++
 .../llhttp-bootstrap-CVE-2020-8287.patch      | 100 ++++++++++++++++++
 3 files changed, 171 insertions(+)
 create mode 100644 gnu/packages/patches/llhttp-bootstrap-CVE-2020-8287.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index 52a021c2a3..5959a563d1 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1366,6 +1366,7 @@ dist_patch_DATA =						\
   %D%/packages/patches/linux-pam-no-setfsuid.patch		\
   %D%/packages/patches/lirc-localstatedir.patch			\
   %D%/packages/patches/lirc-reproducible-build.patch		\
+  %D%/packages/patches/llhttp-bootstrap-CVE-2020-8287.patch	\
   %D%/packages/patches/llvm-3.5-fix-clang-build-with-gcc5.patch	\
   %D%/packages/patches/llvm-9-fix-bitcast-miscompilation.patch	\
   %D%/packages/patches/llvm-9-fix-lpad-miscompilation.patch	\
diff --git a/gnu/packages/node.scm b/gnu/packages/node.scm
index 5336012e43..45e5f8feca 100644
--- a/gnu/packages/node.scm
+++ b/gnu/packages/node.scm
@@ -510,6 +510,76 @@ Node.js and web browsers.")
 parser definition into a C output.")
     (license license:expat)))
 
+(define-public llhttp-bootstrap
+  (package
+    (name "llhttp")
+    (version "2.1.3")
+    (source (origin
+              (method git-fetch)
+              (uri (git-reference
+                    (url "https://github.com/nodejs/llhttp.git")
+                    (commit (string-append "v" version))))
+              (file-name (git-file-name name version))
+              (sha256
+               (base32
+                "0pqj7kyyzr1zs4h9yzn5rdxnxspm3wqgsv00765dd42fszlmrmk8"))
+              (patches (search-patches "llhttp-bootstrap-CVE-2020-8287.patch"))
+              (modules '((guix build utils)))
+              (snippet
+               '(begin
+                  ;; Fix imports for esbuild.
+                  ;; https://github.com/evanw/esbuild/issues/477
+                  (substitute* "src/llhttp/http.ts"
+                    (("\\* as assert") "assert"))
+                  (substitute* "Makefile"
+                    (("npx ts-node bin/generate.ts")
+                     "node bin/generate.js"))
+                  #t))))
+    (build-system gnu-build-system)
+    (arguments
+     `(#:tests? #f                      ; no tests
+       #:make-flags (list "CLANG=gcc"
+                          (string-append "DESTDIR=" (assoc-ref %outputs "out"))
+                          "PREFIX=")
+       #:phases
+       (modify-phases %standard-phases
+         (replace 'configure
+           (lambda* (#:key inputs #:allow-other-keys)
+             (let ((esbuild (string-append (assoc-ref inputs "esbuild")
+                                           "/bin/esbuild")))
+               (invoke esbuild
+                       "--platform=node"
+                       "--outfile=bin/generate.js"
+                       "--bundle" "bin/generate.ts"))))
+         (add-before 'install 'create-install-directories
+           (lambda* (#:key outputs #:allow-other-keys)
+             (let ((out (assoc-ref outputs "out")))
+               (for-each (lambda (dir)
+                           (mkdir-p (string-append out dir)))
+                         (list "/lib" "/include" "/src"))
+               #t)))
+         (add-after 'install 'install-src
+           (lambda* (#:key outputs #:allow-other-keys)
+             (let* ((out (assoc-ref outputs "out"))
+                    (src-dir (string-append out "/src")))
+               (install-file "build/c/llhttp.c" src-dir)
+               (install-file "src/native/api.c" src-dir)
+               (install-file "src/native/http.c" src-dir)
+               #t))))))
+    (native-inputs
+     `(("esbuild" ,esbuild)
+       ("node" ,node-bootstrap)
+       ("node-semver" ,node-semver-bootstrap)
+       ("node-llparse-bootstrap" ,node-llparse-bootstrap)))
+    (home-page "https://github.com/nodejs/llhttp")
+    (properties '((hidden? . #t)))
+    (synopsis "Parser for HTTP messages")
+    (description "This is a rewrite of
+@url{https://github.com/nodejs/http-parser, http-parser} using
+@url{https://github.com/nodejs/llparse, llparse} to generate the C
+source files.")
+    (license license:expat)))
+
 (define-public libnode
   (package/inherit node
     (name "libnode")
diff --git a/gnu/packages/patches/llhttp-bootstrap-CVE-2020-8287.patch b/gnu/packages/patches/llhttp-bootstrap-CVE-2020-8287.patch
new file mode 100644
index 0000000000..215c920e53
--- /dev/null
+++ b/gnu/packages/patches/llhttp-bootstrap-CVE-2020-8287.patch
@@ -0,0 +1,100 @@
+This patch comes from upstream.  It corresponds to a patch applied to
+the generated C source code for llhttp included in Node.js 14.16.0
+(see commit 641f786bb1a1f6eb1ff8750782ed939780f2b31a).  That commit
+fixes CVE-2020-8287.  With this patch, the output of our
+llhttp-bootstrap package matches the files included in Node.js 14.16.0
+exactly.
+
+commit e9b36ea64709c35ca66094d5cf3787f444029601
+Author: Fedor Indutny <fedor@indutny.com>
+Date:   Sat Oct 10 19:56:01 2020 -0700
+
+    http: unset `F_CHUNKED` on new `Transfer-Encoding`
+    
+    Duplicate `Transfer-Encoding` header should be a treated as a single,
+    but with original header values concatenated with a comma separator. In
+    the light of this, even if the past `Transfer-Encoding` ended with
+    `chunked`, we should be not let the `F_CHUNKED` to leak into the next
+    header, because mere presence of another header indicates that `chunked`
+    is not the last transfer-encoding token.
+
+diff --git a/src/llhttp/http.ts b/src/llhttp/http.ts
+index f4f1a6e..0a0c365 100644
+--- a/src/llhttp/http.ts
++++ b/src/llhttp/http.ts
+@@ -460,11 +460,19 @@ export class HTTP {
+       .match([ ' ', '\t' ], n('header_value_discard_ws'))
+       .otherwise(checkContentLengthEmptiness);
+ 
++    // Multiple `Transfer-Encoding` headers should be treated as one, but with
++    // values separate by a comma.
++    //
++    // See: https://tools.ietf.org/html/rfc7230#section-3.2.2
++    const toTransferEncoding = this.unsetFlag(
++      FLAGS.CHUNKED,
++      'header_value_te_chunked');
++
+     n('header_value_start')
+       .otherwise(this.load('header_state', {
+         [HEADER_STATE.UPGRADE]: this.setFlag(FLAGS.UPGRADE, fallback),
+         [HEADER_STATE.TRANSFER_ENCODING]: this.setFlag(
+-          FLAGS.TRANSFER_ENCODING, 'header_value_te_chunked'),
++          FLAGS.TRANSFER_ENCODING, toTransferEncoding),
+         [HEADER_STATE.CONTENT_LENGTH]: n('header_value_content_length_once'),
+         [HEADER_STATE.CONNECTION]: n('header_value_connection'),
+       }, 'header_value'));
+@@ -847,6 +855,11 @@ export class HTTP {
+     return span.start(span.end(this.node(next)));
+   }
+ 
++  private unsetFlag(flag: FLAGS, next: string | Node): Node {
++    const p = this.llparse;
++    return p.invoke(p.code.and('flags', ~flag), this.node(next));
++  }
++
+   private setFlag(flag: FLAGS, next: string | Node): Node {
+     const p = this.llparse;
+     return p.invoke(p.code.or('flags', flag), this.node(next));
+diff --git a/test/request/transfer-encoding.md b/test/request/transfer-encoding.md
+index a7d1681..b0891d6 100644
+--- a/test/request/transfer-encoding.md
++++ b/test/request/transfer-encoding.md
+@@ -353,6 +353,38 @@ off=106 headers complete method=3 v=1/1 flags=200 content_length=0
+ off=106 error code=15 reason="Request has invalid `Transfer-Encoding`"
+ ```
+ 
++## POST with `chunked` and duplicate transfer-encoding
++
++<!-- meta={"type": "request", "noScan": true} -->
++```http
++POST /post_identity_body_world?q=search#hey HTTP/1.1
++Accept: */*
++Transfer-Encoding: chunked
++Transfer-Encoding: deflate
++
++World
++```
++
++```log
++off=0 message begin
++off=5 len=38 span[url]="/post_identity_body_world?q=search#hey"
++off=44 url complete
++off=54 len=6 span[header_field]="Accept"
++off=61 header_field complete
++off=62 len=3 span[header_value]="*/*"
++off=67 header_value complete
++off=67 len=17 span[header_field]="Transfer-Encoding"
++off=85 header_field complete
++off=86 len=7 span[header_value]="chunked"
++off=95 header_value complete
++off=95 len=17 span[header_field]="Transfer-Encoding"
++off=113 header_field complete
++off=114 len=7 span[header_value]="deflate"
++off=123 header_value complete
++off=125 headers complete method=3 v=1/1 flags=200 content_length=0
++off=125 error code=15 reason="Request has invalid `Transfer-Encoding`"
++```
++
+ ## POST with `chunked` before other transfer-coding (lenient)
+ 
+ TODO(indutny): should we allow it even in lenient mode? (Consider disabling
-- 
2.31.0





^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [bug#47282] [PATCH v2 13/13] gnu: Add node-lts.
  2021-03-30  5:24 ` Timothy Sample
                     ` (11 preceding siblings ...)
  2021-03-30  5:27   ` [bug#47282] [PATCH v2 12/13] gnu: Add llhttp-bootstrap Timothy Sample
@ 2021-03-30  5:27   ` Timothy Sample
  2021-03-30  7:04     ` Efraim Flashner
  2021-04-02 16:18   ` bug#47282: [PATCH 00/13] node going forward Jelle Licht
  13 siblings, 1 reply; 37+ messages in thread
From: Timothy Sample @ 2021-03-30  5:27 UTC (permalink / raw)
  To: 47282; +Cc: Jelle Licht

From: Jelle Licht <jlicht@fsfe.org>

* gnu/packages/node.scm (node-lts): New variable.
* guix/build-system/node.scm (default-node): Use it.
---
 gnu/packages/node.scm      | 135 +++++++++++++++++++++++++++++++++++++
 guix/build-system/node.scm |   2 +-
 2 files changed, 136 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/node.scm b/gnu/packages/node.scm
index 45e5f8feca..249241f110 100644
--- a/gnu/packages/node.scm
+++ b/gnu/packages/node.scm
@@ -580,6 +580,141 @@ parser definition into a C output.")
 source files.")
     (license license:expat)))
 
+(define-public node-lts
+  (package
+    (inherit node)
+    (version "14.16.0")
+    (source (origin
+              (method url-fetch)
+              (uri (string-append "https://nodejs.org/dist/v" version
+                                  "/node-v" version ".tar.xz"))
+              (sha256
+               (base32
+                "19nz2mhmn6ikahxqyna1dn25pb5v3z9vsz9zb2flb6zp2yk4hxjf"))
+              (modules '((guix build utils)))
+              (snippet
+               `(begin
+                  ;; Remove bundled software, where possible
+                  (for-each delete-file-recursively
+                            '("deps/cares"
+                              "deps/icu-small"
+                              "deps/nghttp2"
+                              "deps/openssl"
+                              "deps/zlib"))
+                  (substitute* "Makefile"
+                    ;; Remove references to bundled software.
+                    (("deps/uv/uv.gyp") "")
+                    (("deps/zlib/zlib.gyp") ""))
+                  #t))))
+    (arguments
+     (substitute-keyword-arguments (package-arguments node)
+       ((#:configure-flags configure-flags)
+        ''("--shared-cares"
+           "--shared-libuv"
+           "--shared-nghttp2"
+           "--shared-openssl"
+           "--shared-zlib"
+           "--shared-brotli"
+           "--with-intl=system-icu"))
+       ((#:phases phases)
+        `(modify-phases ,phases
+           (replace 'configure
+             ;; Node's configure script is actually a python script, so we can't
+             ;; run it with bash.
+             (lambda* (#:key outputs (configure-flags '()) inputs
+                       #:allow-other-keys)
+               (let* ((prefix (assoc-ref outputs "out"))
+                      (flags (cons (string-append "--prefix=" prefix)
+                                   configure-flags)))
+                 (format #t "build directory: ~s~%" (getcwd))
+                 (format #t "configure flags: ~s~%" flags)
+                 ;; Node's configure script expects the CC environment variable to
+                 ;; be set.
+                 (setenv "CC" (string-append (assoc-ref inputs "gcc") "/bin/gcc"))
+                 (apply invoke
+                        (string-append (assoc-ref inputs "python")
+                                       "/bin/python3")
+                        "configure" flags))))
+           (replace 'patch-files
+             (lambda* (#:key inputs #:allow-other-keys)
+               ;; Fix hardcoded /bin/sh references.
+               (substitute* '("lib/child_process.js"
+                              "lib/internal/v8_prof_polyfill.js"
+                              "test/parallel/test-child-process-spawnsync-shell.js"
+                              "test/parallel/test-fs-write-sigxfsz.js"
+                              "test/parallel/test-stdio-closed.js"
+                              "test/sequential/test-child-process-emfile.js")
+                 (("'/bin/sh'")
+                  (string-append "'" (which "sh") "'")))
+
+               ;; Fix hardcoded /usr/bin/env references.
+               (substitute* '("test/parallel/test-child-process-default-options.js"
+                              "test/parallel/test-child-process-env.js"
+                              "test/parallel/test-child-process-exec-env.js")
+                 (("'/usr/bin/env'")
+                  (string-append "'" (which "env") "'")))
+
+               ;; FIXME: These tests fail in the build container, but they don't
+               ;; seem to be indicative of real problems in practice.
+               (for-each delete-file
+                         '("test/parallel/test-cluster-master-error.js"
+                           "test/parallel/test-cluster-master-kill.js"))
+
+               ;; These require a DNS resolver.
+               (for-each delete-file
+                         '("test/parallel/test-dns.js"
+                           "test/parallel/test-dns-lookupService-promises.js"))
+
+               ;; FIXME: This test fails randomly:
+               ;; https://github.com/nodejs/node/issues/31213
+               (delete-file "test/parallel/test-net-listen-after-destroying-stdin.js")
+
+               ;; FIXME: These tests fail on armhf-linux:
+               ;; https://github.com/nodejs/node/issues/31970
+               ,@(if (string-prefix? "arm" (%current-system))
+                     '((for-each delete-file
+                                 '("test/parallel/test-zlib.js"
+                                   "test/parallel/test-zlib-brotli.js"
+                                   "test/parallel/test-zlib-brotli-flush.js"
+                                   "test/parallel/test-zlib-brotli-from-brotli.js"
+                                   "test/parallel/test-zlib-brotli-from-string.js"
+                                   "test/parallel/test-zlib-convenience-methods.js"
+                                   "test/parallel/test-zlib-random-byte-pipes.js"
+                                   "test/parallel/test-zlib-write-after-flush.js")))
+                     '())
+
+               ;; These tests have an expiry date: they depend on the validity of
+               ;; TLS certificates that are bundled with the source.  We want this
+               ;; package to be reproducible forever, so remove those.
+               ;; TODO: Regenerate certs instead.
+               (for-each delete-file
+                         '("test/parallel/test-tls-passphrase.js"
+                           "test/parallel/test-tls-server-verify.js"))
+
+               ;; Replace pre-generated llhttp sources
+               (let ((llhttp (assoc-ref inputs "llhttp")))
+                 (copy-file (string-append llhttp "/src/llhttp.c")
+                            "deps/llhttp/src/llhttp.c")
+                 (copy-file (string-append llhttp "/src/api.c")
+                            "deps/llhttp/src/api.c")
+                 (copy-file (string-append llhttp "/src/http.c")
+                            "deps/llhttp/src/http.c")
+                 (copy-file (string-append llhttp "/include/llhttp.h")
+                            "deps/llhttp/include/llhttp.h"))
+               #t))))))
+    (inputs
+     `(("c-ares" ,c-ares)
+       ("icu4c" ,icu4c-67)
+       ("libuv" ,libuv-for-node)
+       ("llhttp" ,llhttp-bootstrap)
+       ("google-brotli" ,google-brotli)
+       ("nghttp2" ,nghttp2 "lib")
+       ("openssl" ,openssl)
+       ("zlib" ,zlib)))
+    (native-inputs
+     (alist-replace "python" (list python-3)
+                    (package-native-inputs node)))))
+
 (define-public libnode
   (package/inherit node
     (name "libnode")
diff --git a/guix/build-system/node.scm b/guix/build-system/node.scm
index 4991ed53a5..98f63f87ef 100644
--- a/guix/build-system/node.scm
+++ b/guix/build-system/node.scm
@@ -39,7 +39,7 @@
   "Return the default Node package."
   ;; Lazily resolve the binding to avoid a circular dependency.
   (let ((node (resolve-interface '(gnu packages node))))
-    (module-ref node 'node)))
+    (module-ref node 'node-lts)))
 
 (define* (lower name
                 #:key source inputs native-inputs outputs system target
-- 
2.31.0





^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [bug#47282] [PATCH v2 12/13] gnu: Add llhttp-bootstrap.
  2021-03-30  5:27   ` [bug#47282] [PATCH v2 12/13] gnu: Add llhttp-bootstrap Timothy Sample
@ 2021-03-30  6:59     ` Efraim Flashner
  2021-04-02 13:17       ` Jelle Licht
  0 siblings, 1 reply; 37+ messages in thread
From: Efraim Flashner @ 2021-03-30  6:59 UTC (permalink / raw)
  To: Timothy Sample; +Cc: Jelle Licht, 47282

[-- Attachment #1: Type: text/plain, Size: 9902 bytes --]

On Tue, Mar 30, 2021 at 01:27:42AM -0400, Timothy Sample wrote:
> From: Jelle Licht <jlicht@fsfe.org>
> 
> * gnu/packages/patches/llhttp-bootstrap-CVE-2020-8287.patch: New file.
> * gnu/local.mk (dist_patch_DATA): Add it.
> * gnu/packages/node.scm (llhttp-bootstrap): New variable.
> ---
>  gnu/local.mk                                  |   1 +
>  gnu/packages/node.scm                         |  70 ++++++++++++
>  .../llhttp-bootstrap-CVE-2020-8287.patch      | 100 ++++++++++++++++++
>  3 files changed, 171 insertions(+)
>  create mode 100644 gnu/packages/patches/llhttp-bootstrap-CVE-2020-8287.patch
> 
> diff --git a/gnu/local.mk b/gnu/local.mk
> index 52a021c2a3..5959a563d1 100644
> --- a/gnu/local.mk
> +++ b/gnu/local.mk
> @@ -1366,6 +1366,7 @@ dist_patch_DATA =						\
>    %D%/packages/patches/linux-pam-no-setfsuid.patch		\
>    %D%/packages/patches/lirc-localstatedir.patch			\
>    %D%/packages/patches/lirc-reproducible-build.patch		\
> +  %D%/packages/patches/llhttp-bootstrap-CVE-2020-8287.patch	\
>    %D%/packages/patches/llvm-3.5-fix-clang-build-with-gcc5.patch	\
>    %D%/packages/patches/llvm-9-fix-bitcast-miscompilation.patch	\
>    %D%/packages/patches/llvm-9-fix-lpad-miscompilation.patch	\
> diff --git a/gnu/packages/node.scm b/gnu/packages/node.scm
> index 5336012e43..45e5f8feca 100644
> --- a/gnu/packages/node.scm
> +++ b/gnu/packages/node.scm
> @@ -510,6 +510,76 @@ Node.js and web browsers.")
>  parser definition into a C output.")
>      (license license:expat)))
>  
> +(define-public llhttp-bootstrap
> +  (package
> +    (name "llhttp")
> +    (version "2.1.3")
> +    (source (origin
> +              (method git-fetch)
> +              (uri (git-reference
> +                    (url "https://github.com/nodejs/llhttp.git")
> +                    (commit (string-append "v" version))))
> +              (file-name (git-file-name name version))
> +              (sha256
> +               (base32
> +                "0pqj7kyyzr1zs4h9yzn5rdxnxspm3wqgsv00765dd42fszlmrmk8"))
> +              (patches (search-patches "llhttp-bootstrap-CVE-2020-8287.patch"))
> +              (modules '((guix build utils)))
> +              (snippet
> +               '(begin
> +                  ;; Fix imports for esbuild.
> +                  ;; https://github.com/evanw/esbuild/issues/477
> +                  (substitute* "src/llhttp/http.ts"
> +                    (("\\* as assert") "assert"))
> +                  (substitute* "Makefile"
> +                    (("npx ts-node bin/generate.ts")
> +                     "node bin/generate.js"))
> +                  #t))))
> +    (build-system gnu-build-system)
> +    (arguments
> +     `(#:tests? #f                      ; no tests
> +       #:make-flags (list "CLANG=gcc"

This should probably be cc-for-target

> +                          (string-append "DESTDIR=" (assoc-ref %outputs "out"))
> +                          "PREFIX=")

And normally DESTDIR is empty and PREFIX is %out. Does it need to be
switched here?

> +       #:phases
> +       (modify-phases %standard-phases
> +         (replace 'configure
> +           (lambda* (#:key inputs #:allow-other-keys)
> +             (let ((esbuild (string-append (assoc-ref inputs "esbuild")
> +                                           "/bin/esbuild")))
> +               (invoke esbuild
> +                       "--platform=node"
> +                       "--outfile=bin/generate.js"
> +                       "--bundle" "bin/generate.ts"))))
> +         (add-before 'install 'create-install-directories
> +           (lambda* (#:key outputs #:allow-other-keys)
> +             (let ((out (assoc-ref outputs "out")))
> +               (for-each (lambda (dir)
> +                           (mkdir-p (string-append out dir)))
> +                         (list "/lib" "/include" "/src"))
> +               #t)))
> +         (add-after 'install 'install-src
> +           (lambda* (#:key outputs #:allow-other-keys)
> +             (let* ((out (assoc-ref outputs "out"))
> +                    (src-dir (string-append out "/src")))
> +               (install-file "build/c/llhttp.c" src-dir)
> +               (install-file "src/native/api.c" src-dir)
> +               (install-file "src/native/http.c" src-dir)
> +               #t))))))
> +    (native-inputs
> +     `(("esbuild" ,esbuild)
> +       ("node" ,node-bootstrap)
> +       ("node-semver" ,node-semver-bootstrap)
> +       ("node-llparse-bootstrap" ,node-llparse-bootstrap)))
> +    (home-page "https://github.com/nodejs/llhttp")
> +    (properties '((hidden? . #t)))
> +    (synopsis "Parser for HTTP messages")
> +    (description "This is a rewrite of
> +@url{https://github.com/nodejs/http-parser, http-parser} using
> +@url{https://github.com/nodejs/llparse, llparse} to generate the C
> +source files.")
> +    (license license:expat)))
> +
>  (define-public libnode
>    (package/inherit node
>      (name "libnode")
> diff --git a/gnu/packages/patches/llhttp-bootstrap-CVE-2020-8287.patch b/gnu/packages/patches/llhttp-bootstrap-CVE-2020-8287.patch
> new file mode 100644
> index 0000000000..215c920e53
> --- /dev/null
> +++ b/gnu/packages/patches/llhttp-bootstrap-CVE-2020-8287.patch
> @@ -0,0 +1,100 @@
> +This patch comes from upstream.  It corresponds to a patch applied to
> +the generated C source code for llhttp included in Node.js 14.16.0
> +(see commit 641f786bb1a1f6eb1ff8750782ed939780f2b31a).  That commit
> +fixes CVE-2020-8287.  With this patch, the output of our
> +llhttp-bootstrap package matches the files included in Node.js 14.16.0
> +exactly.
> +
> +commit e9b36ea64709c35ca66094d5cf3787f444029601
> +Author: Fedor Indutny <fedor@indutny.com>
> +Date:   Sat Oct 10 19:56:01 2020 -0700
> +
> +    http: unset `F_CHUNKED` on new `Transfer-Encoding`
> +    
> +    Duplicate `Transfer-Encoding` header should be a treated as a single,
> +    but with original header values concatenated with a comma separator. In
> +    the light of this, even if the past `Transfer-Encoding` ended with
> +    `chunked`, we should be not let the `F_CHUNKED` to leak into the next
> +    header, because mere presence of another header indicates that `chunked`
> +    is not the last transfer-encoding token.
> +
> +diff --git a/src/llhttp/http.ts b/src/llhttp/http.ts
> +index f4f1a6e..0a0c365 100644
> +--- a/src/llhttp/http.ts
> ++++ b/src/llhttp/http.ts
> +@@ -460,11 +460,19 @@ export class HTTP {
> +       .match([ ' ', '\t' ], n('header_value_discard_ws'))
> +       .otherwise(checkContentLengthEmptiness);
> + 
> ++    // Multiple `Transfer-Encoding` headers should be treated as one, but with
> ++    // values separate by a comma.
> ++    //
> ++    // See: https://tools.ietf.org/html/rfc7230#section-3.2.2
> ++    const toTransferEncoding = this.unsetFlag(
> ++      FLAGS.CHUNKED,
> ++      'header_value_te_chunked');
> ++
> +     n('header_value_start')
> +       .otherwise(this.load('header_state', {
> +         [HEADER_STATE.UPGRADE]: this.setFlag(FLAGS.UPGRADE, fallback),
> +         [HEADER_STATE.TRANSFER_ENCODING]: this.setFlag(
> +-          FLAGS.TRANSFER_ENCODING, 'header_value_te_chunked'),
> ++          FLAGS.TRANSFER_ENCODING, toTransferEncoding),
> +         [HEADER_STATE.CONTENT_LENGTH]: n('header_value_content_length_once'),
> +         [HEADER_STATE.CONNECTION]: n('header_value_connection'),
> +       }, 'header_value'));
> +@@ -847,6 +855,11 @@ export class HTTP {
> +     return span.start(span.end(this.node(next)));
> +   }
> + 
> ++  private unsetFlag(flag: FLAGS, next: string | Node): Node {
> ++    const p = this.llparse;
> ++    return p.invoke(p.code.and('flags', ~flag), this.node(next));
> ++  }
> ++
> +   private setFlag(flag: FLAGS, next: string | Node): Node {
> +     const p = this.llparse;
> +     return p.invoke(p.code.or('flags', flag), this.node(next));
> +diff --git a/test/request/transfer-encoding.md b/test/request/transfer-encoding.md
> +index a7d1681..b0891d6 100644
> +--- a/test/request/transfer-encoding.md
> ++++ b/test/request/transfer-encoding.md
> +@@ -353,6 +353,38 @@ off=106 headers complete method=3 v=1/1 flags=200 content_length=0
> + off=106 error code=15 reason="Request has invalid `Transfer-Encoding`"
> + ```
> + 
> ++## POST with `chunked` and duplicate transfer-encoding
> ++
> ++<!-- meta={"type": "request", "noScan": true} -->
> ++```http
> ++POST /post_identity_body_world?q=search#hey HTTP/1.1
> ++Accept: */*
> ++Transfer-Encoding: chunked
> ++Transfer-Encoding: deflate
> ++
> ++World
> ++```
> ++
> ++```log
> ++off=0 message begin
> ++off=5 len=38 span[url]="/post_identity_body_world?q=search#hey"
> ++off=44 url complete
> ++off=54 len=6 span[header_field]="Accept"
> ++off=61 header_field complete
> ++off=62 len=3 span[header_value]="*/*"
> ++off=67 header_value complete
> ++off=67 len=17 span[header_field]="Transfer-Encoding"
> ++off=85 header_field complete
> ++off=86 len=7 span[header_value]="chunked"
> ++off=95 header_value complete
> ++off=95 len=17 span[header_field]="Transfer-Encoding"
> ++off=113 header_field complete
> ++off=114 len=7 span[header_value]="deflate"
> ++off=123 header_value complete
> ++off=125 headers complete method=3 v=1/1 flags=200 content_length=0
> ++off=125 error code=15 reason="Request has invalid `Transfer-Encoding`"
> ++```
> ++
> + ## POST with `chunked` before other transfer-coding (lenient)
> + 
> + TODO(indutny): should we allow it even in lenient mode? (Consider disabling
> -- 
> 2.31.0
> 
> 
> 
> 

-- 
Efraim Flashner   <efraim@flashner.co.il>   אפרים פלשנר
GPG key = A28B F40C 3E55 1372 662D  14F7 41AA E7DC CA3D 8351
Confidentiality cannot be guaranteed on emails sent or received unencrypted

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 37+ messages in thread

* [bug#47282] [PATCH v2 13/13] gnu: Add node-lts.
  2021-03-30  5:27   ` [bug#47282] [PATCH v2 13/13] gnu: Add node-lts Timothy Sample
@ 2021-03-30  7:04     ` Efraim Flashner
  2021-04-02 13:20       ` Jelle Licht
  0 siblings, 1 reply; 37+ messages in thread
From: Efraim Flashner @ 2021-03-30  7:04 UTC (permalink / raw)
  To: Timothy Sample; +Cc: Jelle Licht, 47282

[-- Attachment #1: Type: text/plain, Size: 8701 bytes --]

On Tue, Mar 30, 2021 at 01:27:43AM -0400, Timothy Sample wrote:
> From: Jelle Licht <jlicht@fsfe.org>
> 
> * gnu/packages/node.scm (node-lts): New variable.
> * guix/build-system/node.scm (default-node): Use it.
> ---
>  gnu/packages/node.scm      | 135 +++++++++++++++++++++++++++++++++++++
>  guix/build-system/node.scm |   2 +-
>  2 files changed, 136 insertions(+), 1 deletion(-)
> 
> diff --git a/gnu/packages/node.scm b/gnu/packages/node.scm
> index 45e5f8feca..249241f110 100644
> --- a/gnu/packages/node.scm
> +++ b/gnu/packages/node.scm
> @@ -580,6 +580,141 @@ parser definition into a C output.")
>  source files.")
>      (license license:expat)))
>  
> +(define-public node-lts
> +  (package
> +    (inherit node)
> +    (version "14.16.0")
> +    (source (origin
> +              (method url-fetch)
> +              (uri (string-append "https://nodejs.org/dist/v" version
> +                                  "/node-v" version ".tar.xz"))
> +              (sha256
> +               (base32
> +                "19nz2mhmn6ikahxqyna1dn25pb5v3z9vsz9zb2flb6zp2yk4hxjf"))
> +              (modules '((guix build utils)))
> +              (snippet
> +               `(begin
> +                  ;; Remove bundled software, where possible
> +                  (for-each delete-file-recursively
> +                            '("deps/cares"
> +                              "deps/icu-small"
> +                              "deps/nghttp2"
> +                              "deps/openssl"
> +                              "deps/zlib"))
> +                  (substitute* "Makefile"
> +                    ;; Remove references to bundled software.
> +                    (("deps/uv/uv.gyp") "")
> +                    (("deps/zlib/zlib.gyp") ""))
> +                  #t))))
> +    (arguments
> +     (substitute-keyword-arguments (package-arguments node)
> +       ((#:configure-flags configure-flags)
> +        ''("--shared-cares"
> +           "--shared-libuv"
> +           "--shared-nghttp2"
> +           "--shared-openssl"
> +           "--shared-zlib"
> +           "--shared-brotli"
> +           "--with-intl=system-icu"))
> +       ((#:phases phases)
> +        `(modify-phases ,phases
> +           (replace 'configure
> +             ;; Node's configure script is actually a python script, so we can't
> +             ;; run it with bash.
> +             (lambda* (#:key outputs (configure-flags '()) inputs
> +                       #:allow-other-keys)
> +               (let* ((prefix (assoc-ref outputs "out"))
> +                      (flags (cons (string-append "--prefix=" prefix)
> +                                   configure-flags)))
> +                 (format #t "build directory: ~s~%" (getcwd))
> +                 (format #t "configure flags: ~s~%" flags)
> +                 ;; Node's configure script expects the CC environment variable to
> +                 ;; be set.
> +                 (setenv "CC" (string-append (assoc-ref inputs "gcc") "/bin/gcc"))

again cc-for-target

> +                 (apply invoke
> +                        (string-append (assoc-ref inputs "python")
> +                                       "/bin/python3")
> +                        "configure" flags))))
> +           (replace 'patch-files
> +             (lambda* (#:key inputs #:allow-other-keys)
> +               ;; Fix hardcoded /bin/sh references.
> +               (substitute* '("lib/child_process.js"
> +                              "lib/internal/v8_prof_polyfill.js"
> +                              "test/parallel/test-child-process-spawnsync-shell.js"
> +                              "test/parallel/test-fs-write-sigxfsz.js"
> +                              "test/parallel/test-stdio-closed.js"
> +                              "test/sequential/test-child-process-emfile.js")
> +                 (("'/bin/sh'")
> +                  (string-append "'" (which "sh") "'")))
> +
> +               ;; Fix hardcoded /usr/bin/env references.
> +               (substitute* '("test/parallel/test-child-process-default-options.js"
> +                              "test/parallel/test-child-process-env.js"
> +                              "test/parallel/test-child-process-exec-env.js")
> +                 (("'/usr/bin/env'")
> +                  (string-append "'" (which "env") "'")))
> +
> +               ;; FIXME: These tests fail in the build container, but they don't
> +               ;; seem to be indicative of real problems in practice.
> +               (for-each delete-file
> +                         '("test/parallel/test-cluster-master-error.js"
> +                           "test/parallel/test-cluster-master-kill.js"))
> +
> +               ;; These require a DNS resolver.
> +               (for-each delete-file
> +                         '("test/parallel/test-dns.js"
> +                           "test/parallel/test-dns-lookupService-promises.js"))
> +
> +               ;; FIXME: This test fails randomly:
> +               ;; https://github.com/nodejs/node/issues/31213
> +               (delete-file "test/parallel/test-net-listen-after-destroying-stdin.js")
> +
> +               ;; FIXME: These tests fail on armhf-linux:
> +               ;; https://github.com/nodejs/node/issues/31970
> +               ,@(if (string-prefix? "arm" (%current-system))

This could probably be changed to ,@(when (target-arm32?)

> +                     '((for-each delete-file
> +                                 '("test/parallel/test-zlib.js"
> +                                   "test/parallel/test-zlib-brotli.js"
> +                                   "test/parallel/test-zlib-brotli-flush.js"
> +                                   "test/parallel/test-zlib-brotli-from-brotli.js"
> +                                   "test/parallel/test-zlib-brotli-from-string.js"
> +                                   "test/parallel/test-zlib-convenience-methods.js"
> +                                   "test/parallel/test-zlib-random-byte-pipes.js"
> +                                   "test/parallel/test-zlib-write-after-flush.js")))
> +                     '())
> +
> +               ;; These tests have an expiry date: they depend on the validity of
> +               ;; TLS certificates that are bundled with the source.  We want this
> +               ;; package to be reproducible forever, so remove those.
> +               ;; TODO: Regenerate certs instead.
> +               (for-each delete-file
> +                         '("test/parallel/test-tls-passphrase.js"
> +                           "test/parallel/test-tls-server-verify.js"))
> +
> +               ;; Replace pre-generated llhttp sources
> +               (let ((llhttp (assoc-ref inputs "llhttp")))
> +                 (copy-file (string-append llhttp "/src/llhttp.c")
> +                            "deps/llhttp/src/llhttp.c")
> +                 (copy-file (string-append llhttp "/src/api.c")
> +                            "deps/llhttp/src/api.c")
> +                 (copy-file (string-append llhttp "/src/http.c")
> +                            "deps/llhttp/src/http.c")
> +                 (copy-file (string-append llhttp "/include/llhttp.h")
> +                            "deps/llhttp/include/llhttp.h"))
> +               #t))))))
> +    (inputs
> +     `(("c-ares" ,c-ares)
> +       ("icu4c" ,icu4c-67)
> +       ("libuv" ,libuv-for-node)
> +       ("llhttp" ,llhttp-bootstrap)
> +       ("google-brotli" ,google-brotli)
> +       ("nghttp2" ,nghttp2 "lib")
> +       ("openssl" ,openssl)
> +       ("zlib" ,zlib)))
> +    (native-inputs
> +     (alist-replace "python" (list python-3)
> +                    (package-native-inputs node)))))
> +
>  (define-public libnode
>    (package/inherit node
>      (name "libnode")
> diff --git a/guix/build-system/node.scm b/guix/build-system/node.scm
> index 4991ed53a5..98f63f87ef 100644
> --- a/guix/build-system/node.scm
> +++ b/guix/build-system/node.scm
> @@ -39,7 +39,7 @@
>    "Return the default Node package."
>    ;; Lazily resolve the binding to avoid a circular dependency.
>    (let ((node (resolve-interface '(gnu packages node))))
> -    (module-ref node 'node)))
> +    (module-ref node 'node-lts)))
>  
>  (define* (lower name
>                  #:key source inputs native-inputs outputs system target
> -- 
> 2.31.0
> 
> 
> 
> 

-- 
Efraim Flashner   <efraim@flashner.co.il>   אפרים פלשנר
GPG key = A28B F40C 3E55 1372 662D  14F7 41AA E7DC CA3D 8351
Confidentiality cannot be guaranteed on emails sent or received unencrypted

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 37+ messages in thread

* [bug#47282] [PATCH v2 12/13] gnu: Add llhttp-bootstrap.
  2021-03-30  6:59     ` Efraim Flashner
@ 2021-04-02 13:17       ` Jelle Licht
  0 siblings, 0 replies; 37+ messages in thread
From: Jelle Licht @ 2021-04-02 13:17 UTC (permalink / raw)
  To: Efraim Flashner, Timothy Sample; +Cc: 47282

Efraim Flashner <efraim@flashner.co.il> writes:

> On Tue, Mar 30, 2021 at 01:27:42AM -0400, Timothy Sample wrote:
>> +    (build-system gnu-build-system)
>> +    (arguments
>> +     `(#:tests? #f                      ; no tests
>> +       #:make-flags (list "CLANG=gcc"
>
> This should probably be cc-for-target

Fixed in my local version, thanks.

>> +                          (string-append "DESTDIR=" (assoc-ref %outputs "out"))
>> +                          "PREFIX=")
>
> And normally DESTDIR is empty and PREFIX is %out. Does it need to be
> switched here?

It does.

 - Jelle




^ permalink raw reply	[flat|nested] 37+ messages in thread

* [bug#47282] [PATCH v2 13/13] gnu: Add node-lts.
  2021-03-30  7:04     ` Efraim Flashner
@ 2021-04-02 13:20       ` Jelle Licht
  0 siblings, 0 replies; 37+ messages in thread
From: Jelle Licht @ 2021-04-02 13:20 UTC (permalink / raw)
  To: Efraim Flashner, Timothy Sample; +Cc: 47282

Efraim Flashner <efraim@flashner.co.il> writes:

> On Tue, Mar 30, 2021 at 01:27:43AM -0400, Timothy Sample wrote:
>> +    (arguments
>> +     (substitute-keyword-arguments (package-arguments node)
>> +       ((#:configure-flags configure-flags)
>> +        ''("--shared-cares"
>> +           "--shared-libuv"
>> +           "--shared-nghttp2"
>> +           "--shared-openssl"
>> +           "--shared-zlib"
>> +           "--shared-brotli"
>> +           "--with-intl=system-icu"))
>> +       ((#:phases phases)
>> +        `(modify-phases ,phases
>> +           (replace 'configure
>> +             ;; Node's configure script is actually a python script, so we can't
>> +             ;; run it with bash.
>> +             (lambda* (#:key outputs (configure-flags '()) inputs
>> +                       #:allow-other-keys)
>> +               (let* ((prefix (assoc-ref outputs "out"))
>> +                      (flags (cons (string-append "--prefix=" prefix)
>> +                                   configure-flags)))
>> +                 (format #t "build directory: ~s~%" (getcwd))
>> +                 (format #t "configure flags: ~s~%" flags)
>> +                 ;; Node's configure script expects the CC environment variable to
>> +                 ;; be set.
>> +                 (setenv "CC" (string-append (assoc-ref inputs "gcc") "/bin/gcc"))
>
> again cc-for-target

Ack.

>> [snip]
>> +               ;; FIXME: These tests fail on armhf-linux:
>> +               ;; https://github.com/nodejs/node/issues/31970
>> +               ,@(if (string-prefix? "arm" (%current-system))
>
> This could probably be changed to ,@(when (target-arm32?)

I changed it to ,@(if (target-arm32?), as otherwise the #f-branch
spliced #unspecified into the list.




^ permalink raw reply	[flat|nested] 37+ messages in thread

* bug#47282: [PATCH 00/13] node going forward
  2021-03-30  5:24 ` Timothy Sample
                     ` (12 preceding siblings ...)
  2021-03-30  5:27   ` [bug#47282] [PATCH v2 13/13] gnu: Add node-lts Timothy Sample
@ 2021-04-02 16:18   ` Jelle Licht
  2021-04-03  1:19     ` [bug#47282] " Timothy Sample
  13 siblings, 1 reply; 37+ messages in thread
From: Jelle Licht @ 2021-04-02 16:18 UTC (permalink / raw)
  To: Timothy Sample; +Cc: 47282-done

Timothy,

Timothy Sample <samplet@ngyro.com> writes:

> Hi Jelle,
>
> Jelle Licht <jlicht@fsfe.org> writes:
>
>> So, some people seem to be interested in this one; please review and test.
>
> Now that I’ve finally taken the time to dig into what you’ve done here –
> I must say it’s very impressive!

If you bang your head against a wall often enough, it will crack
eventually. Head or wall, either way works in this metaphor ;-).

> I’ve taken the presumptuous step of re-rolling the series.  The reason
> is that all the “(delete 'build)” bits were bothering me.  I decided to
> have the build system check the “package.json” file for a build script
> before trying to run it.  Since that change required changing all the
> other patches, I thought it would be easier to just post the updated
> patches.  Also, I’m hoping to spare you some trouble (since you’ve
> already gone to a lot!).

Makes sense, thanks! Please be presumptuous as often as you'd like.

>
>     • Change the “Fix incorrect import semantics” comments to “Fix
>       imports for esbuild”.  To me, if TypeScript’s tsc likes the
>       imports, they are correct TypeScript (despite the esbuild bug
>       report).

"Something a native speaker of English can make sense of" != "Proper
English", and in that same vein I don't think a commmon mistake with
workaround in place is not a mistake.

I really don't care about what ends up in the codebase though, as long
as it is clear why we do what we do, which works out just fine with your
comment.

> The final result is still a little messy, but I don’t think we should
> hold this back any longer.  It’s a significant step forward, and it puts
> us in better shape to improve things incrementally.
>
> WDYT?  Let me know if I made anything worse!  :)  If the altered patches
> look good to you, I suggest you go ahead and push them.

I still adressed some of Efraim's remarks, and pushed it to master just
now.

There are quite some ways to go from here:

* Get the 'binary' importer upstreamable (I will continue with this)

* Properly support cross-compilation of Node and Node-packages

  I had a super quick look at this, but it seems that in building node,
  you build intermediate tools that run on the host. Perhaps some our
  x-compilation gurus can weigh in.

* Make a Rome-based build system, once Rome does more than linting, to
  help untangle the knot that is JavaScript-packaging

But for today (and the upcoming release), modern Node on guix \o/

Thanks folks!
 - Jelle




^ permalink raw reply	[flat|nested] 37+ messages in thread

* [bug#47282] [PATCH 00/13] node going forward
  2021-04-02 16:18   ` bug#47282: [PATCH 00/13] node going forward Jelle Licht
@ 2021-04-03  1:19     ` Timothy Sample
  0 siblings, 0 replies; 37+ messages in thread
From: Timothy Sample @ 2021-04-03  1:19 UTC (permalink / raw)
  To: Jelle Licht; +Cc: 47282-done

Hi,

Jelle Licht <jlicht@fsfe.org> writes:

> Timothy Sample <samplet@ngyro.com> writes:
>
>>     • Change the “Fix incorrect import semantics” comments to “Fix
>>       imports for esbuild”.  To me, if TypeScript’s tsc likes the
>>       imports, they are correct TypeScript (despite the esbuild bug
>>       report).
>
> "Something a native speaker of English can make sense of" != "Proper
> English", and in that same vein I don't think a commmon mistake with
> workaround in place is not a mistake.
>
> I really don't care about what ends up in the codebase though, as long
> as it is clear why we do what we do, which works out just fine with your
> comment.

Heh.  You’re right: it’s not a big deal.  Thanks for humouring me.  :)

>> The final result is still a little messy, but I don’t think we should
>> hold this back any longer.  It’s a significant step forward, and it puts
>> us in better shape to improve things incrementally.
>>
>> WDYT?  Let me know if I made anything worse!  :)  If the altered patches
>> look good to you, I suggest you go ahead and push them.
>
> I still adressed some of Efraim's remarks, and pushed it to master just
> now.

Nice!!

> There are quite some ways to go from here:
>
> * Get the 'binary' importer upstreamable (I will continue with this)
>
> * Properly support cross-compilation of Node and Node-packages
>
>   I had a super quick look at this, but it seems that in building node,
>   you build intermediate tools that run on the host. Perhaps some our
>   x-compilation gurus can weigh in.
>
> * Make a Rome-based build system, once Rome does more than linting, to
>   help untangle the knot that is JavaScript-packaging

Sounds pretty exciting!


-- Tim




^ permalink raw reply	[flat|nested] 37+ messages in thread

end of thread, other threads:[~2021-04-03  1:20 UTC | newest]

Thread overview: 37+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-03-20 14:57 [bug#47282] [PATCH 00/13] node going forward Jelle Licht
2021-03-20 14:59 ` [bug#47282] [PATCH 01/13] build-system: Rewrite node build system Jelle Licht
2021-03-20 14:59   ` [bug#47282] [PATCH 02/13] gnu: Add libuv-node Jelle Licht
2021-03-20 14:59   ` [bug#47282] [PATCH 03/13] gnu: node: Use license prefix Jelle Licht
2021-03-20 14:59   ` [bug#47282] [PATCH 04/13] gnu: node: Add node-bootstrap Jelle Licht
2021-03-20 14:59   ` [bug#47282] [PATCH 05/13] gnu: node: Add node-semver-bootstrap Jelle Licht
2021-03-20 14:59   ` [bug#47282] [PATCH 06/13] gnu: node: Add node-ms-bootstrap Jelle Licht
2021-03-20 14:59   ` [bug#47282] [PATCH 07/13] gnu: node: Add node-binary-search-bootstrap Jelle Licht
2021-03-20 14:59   ` [bug#47282] [PATCH 08/13] gnu: node: Add node-debug-bootstrap Jelle Licht
2021-03-20 14:59   ` [bug#47282] [PATCH 09/13] gnu: node: Add node-llparse-builder-bootstrap Jelle Licht
2021-03-20 14:59   ` [bug#47282] [PATCH 10/13] gnu: node: Add node-llparse-frontend-bootstrap Jelle Licht
2021-03-20 14:59   ` [bug#47282] [PATCH 11/13] gnu: node: Add node-llparse-bootstrap Jelle Licht
2021-03-20 14:59   ` [bug#47282] [PATCH 12/13] gnu: node: Add llhttp-bootstrap Jelle Licht
2021-03-20 14:59   ` [bug#47282] [PATCH 13/13] gnu: node: Add node-lts Jelle Licht
2021-03-23  9:05 ` [bug#47282] [PATCH 00/13] node going forward Lars-Dominik Braun
2021-03-25 15:51   ` Léo Le Bouter via Guix-patches via
2021-03-25 16:14     ` Lars-Dominik Braun
2021-03-30  5:24 ` Timothy Sample
2021-03-30  5:27   ` [bug#47282] [PATCH v2 01/13] build-system: Rewrite node build system Timothy Sample
2021-03-30  5:27   ` [bug#47282] [PATCH v2 02/13] gnu: Add libuv-for-node Timothy Sample
2021-03-30  5:27   ` [bug#47282] [PATCH v2 03/13] gnu: node: Use license prefix Timothy Sample
2021-03-30  5:27   ` [bug#47282] [PATCH v2 04/13] gnu: Add node-bootstrap Timothy Sample
2021-03-30  5:27   ` [bug#47282] [PATCH v2 05/13] gnu: Add node-semver-bootstrap Timothy Sample
2021-03-30  5:27   ` [bug#47282] [PATCH v2 06/13] gnu: Add node-ms-bootstrap Timothy Sample
2021-03-30  5:27   ` [bug#47282] [PATCH v2 07/13] gnu: Add node-binary-search-bootstrap Timothy Sample
2021-03-30  5:27   ` [bug#47282] [PATCH v2 08/13] gnu: Add node-debug-bootstrap Timothy Sample
2021-03-30  5:27   ` [bug#47282] [PATCH v2 09/13] gnu: Add node-llparse-builder-bootstrap Timothy Sample
2021-03-30  5:27   ` [bug#47282] [PATCH v2 10/13] gnu: Add node-llparse-frontend-bootstrap Timothy Sample
2021-03-30  5:27   ` [bug#47282] [PATCH v2 11/13] gnu: Add node-llparse-bootstrap Timothy Sample
2021-03-30  5:27   ` [bug#47282] [PATCH v2 12/13] gnu: Add llhttp-bootstrap Timothy Sample
2021-03-30  6:59     ` Efraim Flashner
2021-04-02 13:17       ` Jelle Licht
2021-03-30  5:27   ` [bug#47282] [PATCH v2 13/13] gnu: Add node-lts Timothy Sample
2021-03-30  7:04     ` Efraim Flashner
2021-04-02 13:20       ` Jelle Licht
2021-04-02 16:18   ` bug#47282: [PATCH 00/13] node going forward Jelle Licht
2021-04-03  1:19     ` [bug#47282] " Timothy Sample

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).