diff mbox series

[bug#53414] update Node LTS to 16.13.2

Message ID 14d2b050-5e3c-c923-023f-38584bd726b8@arctype.co
State New
Headers show
Series [bug#53414] update Node LTS to 16.13.2 | expand

Checks

Context Check Description
cbaines/comparison success View comparision
cbaines/git branch success View Git branch
cbaines/applying patch fail View Laminar job
cbaines/issue success View issue

Commit Message

Ryan Sundberg May 2, 2022, 6:10 a.m. UTC
Hello all, here is a revised version of zamfofex's patch that inherits
from node-14. I tried to trim as much fat out as possible in the
inherited node-(16-)lts, but some of the package arguments were
divergent in minor ways. I also bumped the version to 16.5.0 in the
meantime.

--
Sincerely,
Ryan Sundberg

On 2/25/22 9:22 AM, Maxime Devos wrote:
> Pierre Langlois schreef op vr 25-02-2022 om 16:31 [+0000]:
>> If I may shime in, I agree that it's best to have fewer versions of
>> node
>> for Guix's own node packages, however for end-users I think it's a
>> good
>> idea to provide multiple versions they can install.
> 
> I'm not opposed to including multiple LTS versions, as long as they
> are supported upstream, there actual users of the old LTS versions
> and there is some reason to use older versions (perhaps there are
> a few incompatibilities?).
> 
> However, I would prefer the latest version to be standard version
> (with variable name node-lts) so node packages in Guix use the latest
> LTS by default.  Something like
> 
> (define-public node-lts
>   (package
>     (inherit node)
>     (version "16.13.2")
>     [...]))
> 
> ;; Older LTS versions, still maintained upstream and used (see <...>).
> ;; There are some incompatibilities between [...], so allow users
> ;; to choose which node to use.
> (define-public node-14
>   (package
>     (inherit node-lts)
>     (version "14.[...]")
>     [...]))
> 
> Greetings,
> Maxime.

Comments

Pierre Langlois May 15, 2022, 1:45 p.m. UTC | #1
Hi!

Ryan Sundberg via Guix-patches via <guix-patches@gnu.org> writes:

> [[PGP Signed Part:Undecided]]
> Hello all, here is a revised version of zamfofex's patch that inherits
> from node-14. I tried to trim as much fat out as possible in the
> inherited node-(16-)lts, but some of the package arguments were
> divergent in minor ways. I also bumped the version to 16.5.0 in the
> meantime.

The patch LGTM, however when testing it out I wasn't able to build node
packages, I get the following error for example:

--8<---------------cut here---------------start------------->8---
$ ./pre-inst-env guix build node-string-decoder
...
starting phase `install'
npm info using npm@8.5.5
npm info using node@v16.15.0
npm timing npm:load:whichnode Completed in 1ms
npm timing config:load:defaults Completed in 1ms
npm timing config:load:file:/gnu/store/4iqwfsbapa3lhhap1jyg0bry8d1373li-node-16.15.0/lib/node_modules/npm/npmrc Completed in 2ms
npm timing config:load:builtin Completed in 2ms
npm timing config:load:cli Completed in 3ms
npm timing config:load:env Completed in 0ms
npm timing config:load:project Completed in 1ms
npm timing config:load:file:/tmp/guix-build-node-string-decoder-1.3.0.drv-0/npm-home-0/.npmrc Completed in 2ms
npm timing config:load:user Completed in 2ms
npm timing config:load:file:/gnu/store/72cb549aap0inzc8d0v959w6z8qz964m-node-string-decoder-1.3.0/etc/npmrc Completed in 0ms
npm timing config:load:global Completed in 1ms
npm timing config:load:validate Completed in 0ms
npm timing config:load:credentials Completed in 0ms
npm timing config:load:setEnvs Completed in 1ms
npm timing config:load Completed in 11ms
npm timing npm:load:configload Completed in 11ms
npm timing npm:load:setTitle Completed in 0ms
npm timing config:load:flatten Completed in 1ms
npm timing npm:load:display Completed in 5ms
npm timing npm:load:logFile Completed in 4ms
npm timing npm:load:timers Completed in 0ms
npm timing npm:load:configScope Completed in 0ms
npm timing npm:load Completed in 21ms
npm timing arborist:ctor Completed in 1ms
npm timing idealTree:init Completed in 4ms
npm timing idealTree:userRequests Completed in 42ms
npm timing idealTree:#root Completed in 19ms
npm timing idealTree:node_modules/string_decoder Completed in 3ms
npm timing idealTree:node_modules/string_decoder/node_modules/safe-buffer Completed in 0ms
npm timing idealTree:buildDeps Completed in 24ms
npm timing idealTree:fixDepFlags Completed in 0ms
npm timing idealTree Completed in 73ms
npm timing reify:loadTrees Completed in 74ms
npm timing reify:diffTrees Completed in 1ms
npm timing reify:retireShallow Completed in 1ms
npm timing reify:createSparse Completed in 0ms
npm timing reify:trashOmits Completed in 0ms
npm timing reify:loadBundles Completed in 0ms
npm timing reify:audit Completed in 0ms
npm timing reifyNode:node_modules/string_decoder/node_modules/safe-buffer Completed in 8ms
npm timing reifyNode:node_modules/string_decoder Completed in 12ms
npm timing reify:unpack Completed in 13ms
npm timing reify:unretire Completed in 0ms
npm timing build:queue Completed in 1ms
npm timing build:deps Completed in 1ms
npm timing build:queue Completed in 0ms
npm timing build:links Completed in 1ms
npm timing build Completed in 2ms
npm timing reify:build Completed in 2ms
npm timing reify:trash Completed in 0ms
npm timing command:install Completed in 98ms
npm ERR! Cannot set properties of null (setting 'dev')
npm timing npm Completed in 279ms

npm ERR! A complete log of this run can be found in:
npm ERR!     /tmp/guix-build-node-string-decoder-1.3.0.drv-0/npm-home-0/.npm/_logs/2022-05-15T13_47_30_141Z-debug-0.log
error: in phase 'install': uncaught exception:
%exception #<&invoke-error program: "/gnu/store/4iqwfsbapa3lhhap1jyg0bry8d1373li-node-16.15.0/bin/npm" arguments: ("--prefix" "/gnu/store/72cb549aap0inzc8d0v959w6z8qz964m-node-string-decoder-1.3.0" "--global" "--offline" "--loglevel" "info" "--production" "install" "../package.tgz") exit-status: 1 term-signal: #f stop-signal: #f>
phase `install' failed after 0.4 seconds
command "/gnu/store/4iqwfsbapa3lhhap1jyg0bry8d1373li-node-16.15.0/bin/npm" "--prefix" "/gnu/store/72cb549aap0inzc8d0v959w6z8qz964m-node-string-decoder-1.3.0" "--global" "--offline" "--loglevel" "info" "--production" "install" "../package.tgz" failed with status 1
builder for `/gnu/store/6a1vjam7gx0znrr8yngaw2lqld9868l0-node-string-decoder-1.3.0.drv' failed with exit code 1
build of /gnu/store/6a1vjam7gx0znrr8yngaw2lqld9868l0-node-string-decoder-1.3.0.drv failed
View build log at '/var/log/guix/drvs/6a/1vjam7gx0znrr8yngaw2lqld9868l0-node-string-decoder-1.3.0.drv.gz'.
guix build: error: build of `/gnu/store/6a1vjam7gx0znrr8yngaw2lqld9868l0-node-string-decoder-1.3.0.drv' failed
--8<---------------cut here---------------end--------------->8---

I'm a bit clueless as to what's happening, it could be a flavour of this
issue upstream: https://github.com/npm/cli/issues/3847

So hopefully this will be resolved with a new node release, in the
meantime, we could still package node 16 but not make it the default
node for the build-system, WDYT?  I'd suggest to keep the node-lts
pointing to the node-14 version.

Also, as an aside, I'm afraid the patch doesn't allow node to be
cross-compiled, but that's also currently broken on master so we could
fix that as a follow-up IMO.

Thanks for working on this!
Pierre
diff mbox series

Patch

From 14065e4f69eea85503db2af6e6ef38e6ec1a6e28 Mon Sep 17 00:00:00 2001
From: Ryan Sundberg <ryan@arctype.co>
Date: Sun, 1 May 2022 23:00:13 -0700
Subject: [PATCH] gnu: node-lts: Update to 16.15.0

Keeps node-14 available for legacy use cases and graceful migration
purposes.

* gnu/packages/node.scm (node-lts): Update to 16.15.0
* gnu/packages/node.scm (node-14): Export previous LTS version

Co-authored-by: zamfofex <zamfofex@twdb.moe>
---
 gnu/packages/node.scm | 177 +++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 175 insertions(+), 2 deletions(-)

diff --git a/gnu/packages/node.scm b/gnu/packages/node.scm
index ce94557a8c..c0f66ef04b 100644
--- a/gnu/packages/node.scm
+++ b/gnu/packages/node.scm
@@ -11,6 +11,8 @@ 
 ;;; Copyright © 2021 Simon Tournier <zimon.toutoune@gmail.com>
 ;;; Copyright © 2021 Guillaume Le Vaillant <glv@posteo.net>
 ;;; Copyright © 2021, 2022 Philip McGrath <philip@philipmcgrath.com>
+;;; Copyright © 2022 zamfofex <zamfofex@twdb.moe>
+;;; Copyright © 2022 Ryan Sundberg <ryan@arctype.co>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -662,7 +664,7 @@  (define-public node-llparse-bootstrap
 parser definition into a C output.")
     (license license:expat)))
 
-(define-public llhttp-bootstrap
+(define llhttp-2
   (package
     (name "llhttp")
     (version "2.1.4")
@@ -732,7 +734,49 @@  (define-public llhttp-bootstrap
 source files.")
     (license license:expat)))
 
-(define-public node-lts
+(define-public llhttp-bootstrap
+  (package
+    (inherit llhttp-2)
+    (name "llhttp")
+    (version "6.0.6")
+    (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
+                "1c1p39m46frpslm5yx13hj58r7s0cila03yvqp6caip5dbizpfmr"))
+              (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
+     (substitute-keyword-arguments (package-arguments llhttp-2)
+       ((#:phases phases)
+        `(modify-phases ,phases
+           (replace 'install-src
+             (lambda* (#:key outputs #:allow-other-keys)
+               (let* ((out (assoc-ref outputs "out"))
+                      (src-dir (string-append out "/src"))
+                      (src-src-dir (string-append src-dir "/src")))
+                 (install-file "src/llhttp.gyp" src-dir)
+                 (install-file "src/common.gypi" src-dir)
+                 (install-file "build/c/llhttp.c" src-src-dir)
+                 (install-file "src/native/http.c" src-src-dir)
+                 (install-file "src/native/api.c" src-src-dir)
+                 #t)))))))))
+
+(define-public node-14
   (package
     (inherit node)
     (version "14.18.3")
@@ -878,6 +922,135 @@  (define-public node-lts
            c-ares-for-node
            icu4c-67
            libuv-for-node
+           llhttp-2
+           brotli
+           `(,nghttp2 "lib")
+           openssl
+           python-wrapper ;; for node-gyp (supports python3)
+           zlib))))
+
+(define-public node-lts
+  (package
+    (inherit node-14)
+    (version "16.15.0")
+    (source (origin
+              (method url-fetch)
+              (uri (string-append "https://nodejs.org/dist/v" version
+                                  "/node-v" version ".tar.xz"))
+              (sha256
+               (base32
+                "1xx4drj3rc6kin60bm84f3wnnplglih7k588r8g34y1zqkpi5y50"))
+              (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-14)
+       ((#:phases phases)
+        `(modify-phases ,phases
+           (replace 'delete-problematic-tests
+             (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-stdin-from-file-spawn.js"
+                              "test/parallel/test-stdio-closed.js"
+                              "test/sequential/test-child-process-emfile.js")
+                 (("'/bin/sh'")
+                  (string-append "'" (assoc-ref inputs "bash") "/bin/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 "'" (assoc-ref inputs "coreutils")
+                                 "/bin/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-primary-error.js"
+                           "test/parallel/test-cluster-primary-kill.js"))
+
+               ;; These require a DNS resolver.
+               (for-each delete-file
+                         '("test/parallel/test-dns.js"
+                           "test/parallel/test-dns-lookupService-promises.js"))
+
+               ;; These tests require networking.
+               (delete-file "test/parallel/test-https-agent-unref-socket.js")
+
+               ;; This test is timing-sensitive, and fails sporadically on
+               ;; slow, busy, or even very fast machines.
+               (delete-file "test/parallel/test-fs-utimes.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 (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"
+                           "test/parallel/test-https-selfsigned-no-keycertsign-no-crash.js"))))
+           (replace 'replace-llhttp-sources
+             (lambda* (#:key inputs #:allow-other-keys)
+               ;; Replace pre-generated llhttp sources
+               (delete-file-recursively "deps/llhttp")
+               (copy-recursively (string-append (assoc-ref inputs "llhttp") "/src")
+                                 "deps/llhttp")))))))
+    (native-inputs
+     (list ;; Runtime dependencies for binaries used as a bootstrap.
+           c-ares-for-node
+           brotli
+           icu4c
+           libuv-for-node
+           `(,nghttp2 "lib")
+           openssl
+           zlib
+           ;; Regular build-time dependencies.
+           perl
+           pkg-config
+           procps
+           python
+           util-linux))
+    (inputs
+     (list bash-minimal
+           coreutils
+           c-ares-for-node
+           icu4c
+           libuv-for-node
            llhttp-bootstrap
            brotli
            `(,nghttp2 "lib")
-- 
2.34.0