gnu: Add node-ms-bootstrap.
[jackhill/guix/guix.git] / gnu / packages / node.scm
index f04e39b..1d17502 100644 (file)
@@ -7,6 +7,8 @@
 ;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr>
 ;;; Copyright © 2018, 2019, 2020 Marius Bakke <mbakke@fastmail.com>
 ;;; Copyright © 2020 Pierre Langlois <pierre.langlois@gmx.com>
+;;; Copyright © 2020 Ricardo Wurmus <rekado@elephly.net>
+;;; Copyright © 2021 Simon Tournier <zimon.toutoune@gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
 ;;; 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)
   #: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)
@@ -39,6 +43,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)
 (define-public node
   (package
     (name "node")
-    (version "10.20.0")
+    (version "10.24.0")
     (source (origin
               (method url-fetch)
               (uri (string-append "https://nodejs.org/dist/v" version
                                   "/node-v" version ".tar.xz"))
               (sha256
                (base32
-                "0cvjwnl0wkcsyw3kannbdv01s235wrnp11n2s6swzjx95gpichfi"))
+                "1k1srdis23782hnd1ymgczs78x9gqhv77v0am7yb54gqcspp70hm"))
               (modules '((guix build utils)))
               (snippet
                `(begin
                     (target (readlink npm)))
                (with-directory-excursion bindir
                  (patch-shebang target (list bindir))
+                 #t))))
+         (add-after 'install 'patch-node-shebang
+           (lambda* (#:key outputs #:allow-other-keys)
+             (let* ((bindir (string-append (assoc-ref outputs "out")
+                                           "/bin"))
+                    (npx    (readlink (string-append bindir "/npx"))))
+               (with-directory-excursion bindir
+                 (patch-shebang npx (list bindir))
                  #t)))))))
     (native-inputs
      `(("python" ,python-2)
@@ -197,31 +210,74 @@ 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
 
-;; TODO: Make this the default node on core-updates.  This cannot be done on
-;; master since this version of node requires a newer nghttp2 library at link
-;; time.
-(define-public node-10.22
+;; This should be the latest version of node that still builds without
+;; depending on llhttp.
+(define-public node-bootstrap
+  (hidden-package node))
+
+;; Duplicate of node-semver
+(define-public node-semver-bootstrap
   (package
-    (inherit node)
-    (version "10.22.1")
+    (name "node-semver")
+    (version "7.2.1")
     (source (origin
-              (inherit (package-source node))
-              (uri (string-append "https://nodejs.org/dist/v" version
-                                  "/node-v" version ".tar.xz"))
+              (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
-                "0pr569qiabr4m7k38s7rwi3iyzrc5jmx19z2z0k7n4xfvhjlfzzl"))))
-    (inputs
-     (alist-replace "nghttp2" (list nghttp2-1.41 "lib")
-                    (package-inputs node)))))
+                "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
+(define-public node-ms-bootstrap
   (package
-    (inherit node)
+    (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")
     (arguments
      (substitute-keyword-arguments (package-arguments node)
@@ -229,4 +285,5 @@ devices.")
         `(cons* "--shared" "--without-npm" ,flags))
        ((#:phases phases '%standard-phases)
         `(modify-phases ,phases
-           (delete 'patch-npm-shebang)))))))
+           (delete 'patch-npm-shebang)
+           (delete 'patch-node-shebang)))))))