projects/guix·blob librewolf-updates · refs

1008 lines · 43.7 KiB

1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2014 Cyrill Schenkel <[email protected]>
3;;; Copyright © 2015 Andreas Enge <[email protected]>
4;;; Copyright © 2015, 2016 David Thompson <[email protected]>
5;;; Copyright © 2016, 2021 Ludovic Courtès <[email protected]>
6;;; Copyright © 2017 Mike Gerwitz <[email protected]>
7;;; Copyright © 2018 Tobias Geerinckx-Rice <[email protected]>
8;;; Copyright © 2018-2022 Marius Bakke <[email protected]>
9;;; Copyright © 2020, 2021 Pierre Langlois <[email protected]>
10;;; Copyright © 2020, 2023 Ricardo Wurmus <[email protected]>
11;;; Copyright © 2021 Simon Tournier <[email protected]>
12;;; Copyright © 2021 Guillaume Le Vaillant <[email protected]>
13;;; Copyright © 2021, 2022 Philip McGrath <[email protected]>
14;;; Copyright © 2022 Hilton Chain <[email protected]>
15;;; Copyright © 2024 Efraim Flashner <[email protected]>
16;;; Copyright © 2024, 2025 Daniel Khodabakhsh <[email protected]>
17;;;
18;;; This file is part of GNU Guix.
19;;;
20;;; GNU Guix is free software; you can redistribute it and/or modify it
21;;; under the terms of the GNU General Public License as published by
22;;; the Free Software Foundation; either version 3 of the License, or (at
23;;; your option) any later version.
24;;;
25;;; GNU Guix is distributed in the hope that it will be useful, but
26;;; WITHOUT ANY WARRANTY; without even the implied warranty of
27;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28;;; GNU General Public License for more details.
29;;;
30;;; You should have received a copy of the GNU General Public License
31;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
32
33(define-module (gnu packages node)
34 #:use-module ((guix licenses) #:prefix license:)
35 #:use-module ((guix build utils) #:select (alist-replace))
36 #:use-module (guix packages)
37 #:use-module (guix derivations)
38 #:use-module (guix download)
39 #:use-module (guix git-download)
40 #:use-module (guix utils)
41 #:use-module (guix build-system gnu)
42 #:use-module (guix build-system node)
43 #:use-module (gnu packages)
44 #:use-module (gnu packages adns)
45 #:use-module (gnu packages base)
46 #:use-module (gnu packages bash)
47 #:use-module (gnu packages compression)
48 #:use-module (gnu packages gcc)
49 #:use-module (gnu packages icu4c)
50 #:use-module (gnu packages libevent)
51 #:use-module (gnu packages linux)
52 #:use-module (gnu packages networking)
53 #:use-module (gnu packages perl)
54 #:use-module (gnu packages pkg-config)
55 #:use-module (gnu packages python)
56 #:use-module (gnu packages tls)
57 #:use-module (gnu packages web)
58 #:use-module (ice-9 match)
59 #:use-module (srfi srfi-1)
60 #:use-module (srfi srfi-26))
61
62;; This should be the latest version of node that still builds without
63;; depending on llhttp.
64(define-public node-bootstrap
65 (package
66 (name "node")
67 (version "10.24.1")
68 (source (origin
69 (method url-fetch)
70 (uri (string-append "https://nodejs.org/dist/v" version
71 "/node-v" version ".tar.xz"))
72 (sha256
73 (base32
74 "032801kg24j04xmf09m0vxzlcz86sv21s24lv9l4cfv08k1c4byp"))
75 (modules '((guix build utils)))
76 (snippet
77 '(begin
78 ;; Fix process.versions.XXXX assumption of always having
79 ;; a version string of major.minor.patch and not major.minor.
80 (substitute* "test/parallel/test-process-versions.js"
81 (("\\\\d\\+\\\\.\\\\d\\+\\\\.") "(\\d+\\.)+"))
82 ;; Remove bundled software.
83 (for-each delete-file-recursively
84 '("deps/cares"
85 "deps/http_parser"
86 "deps/icu-small"
87 "deps/nghttp2"
88 "deps/openssl"
89 "deps/uv"
90 "deps/zlib"))
91 (substitute* "Makefile"
92 ;; Remove references to bundled software.
93 (("deps/http_parser/http_parser.gyp") "")
94 (("deps/uv/include/\\*.h") "")
95 (("deps/uv/uv.gyp") "")
96 (("deps/zlib/zlib.gyp") ""))))))
97 (build-system gnu-build-system)
98 (arguments
99 `(#:configure-flags '("--shared-cares"
100 "--shared-http-parser"
101 "--shared-libuv"
102 "--shared-nghttp2"
103 "--shared-openssl"
104 "--shared-zlib"
105 "--without-snapshot"
106 "--without-intl")
107 ;; Run only the CI tests. The default test target requires additional
108 ;; add-ons from NPM that are not distributed with the source.
109 #:test-target "test-ci-js"
110 #:modules
111 ((guix build gnu-build-system)
112 (guix build utils)
113 (srfi srfi-1)
114 (ice-9 match))
115 #:phases
116 (modify-phases %standard-phases
117 (add-before 'configure 'patch-hardcoded-program-references
118 (lambda* (#:key inputs #:allow-other-keys)
119
120 ;; Fix hardcoded /bin/sh references.
121 (substitute*
122 (let ((common
123 '("lib/child_process.js"
124 "lib/internal/v8_prof_polyfill.js"
125 "test/parallel/test-child-process-spawnsync-shell.js"
126 "test/parallel/test-stdio-closed.js"
127 "test/sequential/test-child-process-emfile.js"))
128 ;; not in bootstap node:
129 (sigxfsz "test/parallel/test-fs-write-sigxfsz.js"))
130 (if (file-exists? sigxfsz)
131 (cons sigxfsz common)
132 common))
133 (("'/bin/sh'")
134 (string-append "'" (search-input-file inputs "/bin/sh") "'")))
135
136 ;; Fix hardcoded /usr/bin/env references.
137 (substitute* '("test/parallel/test-child-process-default-options.js"
138 "test/parallel/test-child-process-env.js"
139 "test/parallel/test-child-process-exec-env.js")
140 (("'/usr/bin/env'")
141 (string-append "'" (assoc-ref inputs "coreutils")
142 "/bin/env'")))))
143 (add-after 'patch-hardcoded-program-references
144 'delete-problematic-tests
145 (lambda* (#:key inputs #:allow-other-keys)
146
147 ;; FIXME: These tests fail in the build container, but they don't
148 ;; seem to be indicative of real problems in practice.
149 (for-each delete-file
150 '("test/parallel/test-cluster-master-error.js"
151 "test/parallel/test-cluster-master-kill.js"
152 ;; See also <https://github.com/nodejs/node/issues/25903>.
153 "test/sequential/test-performance.js"))
154
155 ;; These tests fail on recent versions of nghttp2
156 (for-each delete-file
157 '("test/parallel/test-http2-methods.js"
158 "test/parallel/test-http2-multiplex.js"))
159
160 ;; This requires a DNS resolver.
161 (delete-file "test/parallel/test-dns.js")
162
163 ;; This test is timing-sensitive, and fails sporadically on
164 ;; slow, busy, or even very fast machines.
165 (delete-file "test/parallel/test-fs-utimes.js")
166
167 ;; FIXME: This test fails randomly:
168 ;; https://github.com/nodejs/node/issues/31213
169 (delete-file "test/parallel/test-net-listen-after-destroying-stdin.js")
170
171 ;; FIXME: These tests fail on armhf-linux:
172 ;; https://github.com/nodejs/node/issues/31970
173 ,@(if (string-prefix? "arm" (%current-system))
174 '((for-each delete-file
175 '("test/parallel/test-zlib.js"
176 "test/parallel/test-zlib-brotli.js"
177 "test/parallel/test-zlib-brotli-flush.js"
178 "test/parallel/test-zlib-brotli-from-brotli.js"
179 "test/parallel/test-zlib-brotli-from-string.js"
180 "test/parallel/test-zlib-convenience-methods.js"
181 "test/parallel/test-zlib-random-byte-pipes.js"
182 "test/parallel/test-zlib-write-after-flush.js")))
183 '())
184
185 ;; These tests have an expiry date: they depend on the validity of
186 ;; TLS certificates that are bundled with the source. We want this
187 ;; package to be reproducible forever, so remove those.
188 ;; TODO: Regenerate certs instead.
189 (for-each delete-file
190 '("test/parallel/test-tls-passphrase.js"
191 "test/parallel/test-tls-server-verify.js"))))
192 (add-before 'configure 'set-bootstrap-host-rpath
193 (lambda* (#:key native-inputs inputs #:allow-other-keys)
194 (let* ((inputs (or native-inputs inputs))
195 (c-ares (assoc-ref inputs "c-ares"))
196 (http-parser (assoc-ref inputs "http-parser"))
197 (nghttp2 (assoc-ref inputs "nghttp2"))
198 (openssl (assoc-ref inputs "openssl"))
199 (libuv (assoc-ref inputs "libuv"))
200 (zlib (assoc-ref inputs "zlib")))
201 (substitute* "deps/v8/gypfiles/v8.gyp"
202 (("'target_name': 'torque'," target)
203 (string-append target
204 "'ldflags': ['-Wl,-rpath="
205 c-ares "/lib:"
206 http-parser "/lib:"
207 nghttp2 "/lib:"
208 openssl "/lib:"
209 libuv "/lib:"
210 zlib "/lib"
211 "'],"))))))
212 (replace 'configure
213 ;; Node's configure script is actually a python script, so we can't
214 ;; run it with bash.
215 (lambda* (#:key outputs (configure-flags '()) native-inputs inputs
216 #:allow-other-keys)
217 (let* ((prefix (assoc-ref outputs "out"))
218 (xflags ,(if (%current-target-system)
219 `'("--cross-compiling"
220 ,(string-append
221 "--dest-cpu="
222 (match (%current-target-system)
223 ((? (cut string-prefix? "arm" <>))
224 "arm")
225 ((? (cut string-prefix? "aarch64" <>))
226 "arm64")
227 ((? (cut string-prefix? "i686" <>))
228 "ia32")
229 ((? (cut string-prefix? "x86_64" <>))
230 "x64")
231 ((? (cut string-prefix? "powerpc64" <>))
232 "ppc64")
233 ((? (cut string-prefix? "riscv64" <>))
234 "riscv64")
235 (_ "unsupported"))))
236 ''()))
237 (flags (cons (string-append "--prefix=" prefix)
238 (append xflags configure-flags))))
239 (format #t "build directory: ~s~%" (getcwd))
240 (format #t "configure flags: ~s~%" flags)
241 ;; Node's configure script expects the CC environment variable to
242 ;; be set.
243 (setenv "CC_host" "gcc")
244 (setenv "CXX_host" "g++")
245 (setenv "CC" ,(cc-for-target))
246 (setenv "CXX" ,(cxx-for-target))
247 (setenv "PKG_CONFIG" ,(pkg-config-for-target))
248 (apply invoke
249 (let ((inpts (or native-inputs inputs)))
250 (with-exception-handler
251 (lambda (e)
252 (if (search-error? e)
253 (search-input-file inpts "/bin/python3")
254 (raise-exception e)))
255 (lambda ()
256 (search-input-file inpts "/bin/python"))
257 #:unwind? #t))
258 "configure"
259 flags))))
260 (add-after 'patch-shebangs 'patch-nested-shebangs
261 (lambda* (#:key inputs outputs #:allow-other-keys)
262 ;; Based on the implementation of patch-shebangs
263 ;; from (guix build gnu-build-system).
264 (let ((path (append-map (match-lambda
265 ((_ . dir)
266 (list (string-append dir "/bin")
267 (string-append dir "/sbin")
268 (string-append dir "/libexec"))))
269 (append outputs inputs))))
270 (for-each
271 (lambda (file)
272 (patch-shebang file path))
273 (find-files (search-input-directory outputs "lib/node_modules")
274 (lambda (file stat)
275 (executable-file? file))
276 #:stat lstat)))))
277 (add-after 'install 'install-npmrc
278 ;; Note: programs like node-gyp only receive these values if
279 ;; they are started via `npm` or `npx`.
280 ;; See: https://github.com/nodejs/node-gyp#npm-configuration
281 (lambda* (#:key outputs #:allow-other-keys)
282 (let* ((out (assoc-ref outputs "out")))
283 (with-output-to-file
284 ;; Use the config file "primarily for distribution
285 ;; maintainers" rather than "{prefix}/etc/npmrc",
286 ;; especially because node-build-system uses --prefix
287 ;; to install things to their store paths:
288 (string-append out "/lib/node_modules/npm/npmrc")
289 (lambda ()
290 ;; Tell npm (mostly node-gyp) where to find our
291 ;; installed headers so it doesn't try to
292 ;; download them from the internet:
293 (format #t "nodedir=~a\n" out)))))))))
294 (native-inputs
295 ;; Runtime dependencies for binaries used as a bootstrap.
296 (list c-ares-for-node-bootstrap
297 http-parser
298 libuv-for-node
299 `(,nghttp2 "lib")
300 openssl-1.1
301 zlib
302 ;; Regular build-time dependencies.
303 gcc-11 ; GCC > 11 produces a broken binary
304 perl
305 pkg-config
306 procps
307 python-2
308 util-linux))
309 (native-search-paths
310 (list (search-path-specification
311 (variable "NODE_PATH")
312 (files '("lib/node_modules")))))
313 (inputs
314 (list bash-minimal
315 coreutils
316 c-ares-for-node-bootstrap
317 http-parser
318 libuv-for-node
319 `(,nghttp2 "lib")
320 openssl
321 python-wrapper ;for node-gyp (supports python3)
322 zlib))
323 (synopsis "Evented I/O for V8 JavaScript")
324 (description
325 "Node.js is a platform built on Chrome's JavaScript runtime
326for easily building fast, scalable network applications. Node.js uses an
327event-driven, non-blocking I/O model that makes it lightweight and efficient,
328perfect for data-intensive real-time applications that run across distributed
329devices.")
330 (supported-systems (fold delete %supported-systems
331 '("powerpc-linux" "riscv64-linux")))
332 (home-page "https://nodejs.org/")
333 (license license:expat)
334 (properties '((max-silent-time . 7200) ;2h, needed on ARM
335 (timeout . 21600) ;6h
336 (cpe-name . "node.js")
337 (hidden? . #t)))))
338
339;; Duplicate of node-semver
340(define-public node-semver-bootstrap
341 (package
342 (name "node-semver")
343 (version "7.2.1")
344 (source (origin
345 (method git-fetch)
346 (uri (git-reference
347 (url "https://github.com/npm/node-semver")
348 (commit (string-append "v" version))))
349 (file-name (git-file-name name version))
350 (sha256
351 (base32
352 "06biknqb05r9xsmcflm3ygh50pjvdk84x6r79w43kmck4fn3qn5p"))))
353 (build-system node-build-system)
354 (arguments
355 `(#:node ,node-bootstrap
356 #:tests? #f
357 #:phases
358 (modify-phases %standard-phases
359 (add-after 'patch-dependencies 'delete-dependencies
360 (lambda args
361 (modify-json (delete-dependencies '("tap"))))))))
362 (home-page "https://github.com/npm/node-semver")
363 (properties '((hidden? . #t)))
364 (synopsis "Parses semantic versions strings")
365 (description
366 "@code{node-semver} is a JavaScript implementation of the
367@uref{https://semver.org/, SemVer.org} specification.")
368 (license license:isc)))
369
370(define-public node-ms-bootstrap
371 (package
372 (name "node-ms")
373 (version "2.1.2")
374 (source
375 (origin
376 (method git-fetch)
377 (uri (git-reference
378 (url "https://github.com/vercel/ms.git")
379 (commit version)))
380 (file-name (git-file-name name version))
381 (sha256
382 (base32
383 "1pjxzbi4j8pinlsc7yxvfrh0b47kb2dc4lfc2rjq4wx5bdwl33fj"))))
384 (build-system node-build-system)
385 (arguments
386 `(#:node ,node-bootstrap
387 #:tests? #f
388 #:phases
389 (modify-phases %standard-phases
390 (add-after 'patch-dependencies 'delete-dependencies
391 (lambda args
392 (modify-json (delete-dependencies
393 '("eslint"
394 "expect.js"
395 "husky"
396 "lint-staged"
397 "mocha"))))))))
398 (home-page "https://github.com/zeit/ms#readme")
399 (properties '((hidden? . #t)))
400 (synopsis "Tiny millisecond conversion utility")
401 (description "Use this package to easily convert various time
402formats to milliseconds.")
403 (license license:expat)))
404
405(define-public node-binary-search-bootstrap
406 (package
407 (name "node-binary-search")
408 (version "1.3.6")
409 (source
410 (origin
411 (method git-fetch)
412 (uri (git-reference
413 (url "https://github.com/darkskyapp/binary-search.git")
414 (commit (string-append "v" version))))
415 (file-name (git-file-name name version))
416 (sha256
417 (base32
418 "1xr2msdc143cd3xwgq7n3rhzy7j8wrnaidxl0r6l6b6g3mpbpjig"))))
419 (build-system node-build-system)
420 (arguments
421 `(#:node ,node-bootstrap
422 #:tests? #f
423 #:phases
424 (modify-phases %standard-phases
425 (add-after 'patch-dependencies 'delete-dependencies
426 (lambda args
427 (modify-json (delete-dependencies `("chai" "mocha"))))))))
428 (home-page "https://github.com/darkskyapp/binary-search#readme")
429 (properties '((hidden? . #t)))
430 (synopsis "Tiny binary search function with comparators")
431 (description "This package is a binary search function for Node.js.")
432 (license license:cc0)))
433
434(define-public node-debug-bootstrap
435 (package
436 (name "node-debug")
437 (version "4.3.0")
438 (source
439 (origin
440 (method git-fetch)
441 (uri (git-reference
442 (url "https://github.com/visionmedia/debug.git")
443 (commit version)))
444 (file-name (git-file-name name version))
445 (sha256
446 (base32
447 "08g52r1d4yqcsfdfb7n5if33d4cghaq75gx5n9hj6m6fd8jfp2pi"))))
448 (build-system node-build-system)
449 (arguments
450 `(#:node ,node-bootstrap
451 #:tests? #f
452 #:phases
453 (modify-phases %standard-phases
454 (add-after 'patch-dependencies 'delete-dependencies
455 (lambda args
456 (modify-json (delete-dependencies
457 `("brfs"
458 "browserify"
459 "coveralls"
460 "istanbul"
461 "karma"
462 "karma-browserify"
463 "karma-chrome-launcher"
464 "karma-mocha"
465 "mocha"
466 "mocha-lcov-reporter"
467 "xo"))))))))
468 (inputs (list node-ms-bootstrap))
469 (home-page "https://github.com/visionmedia/debug#readme")
470 (properties '((hidden? . #t)))
471 (synopsis "Small debugging utility")
472 (description "This package contains a tiny JavaScript debugging
473utility modelled after Node.js core's debugging technique. It works in
474Node.js and web browsers.")
475 (license license:expat)))
476
477(define-public node-llparse-builder-bootstrap
478 (package
479 (name "node-llparse-builder")
480 (version "1.5.2")
481 (source
482 (origin
483 (method git-fetch)
484 (uri (git-reference
485 (url "https://github.com/indutny/llparse-builder.git")
486 (commit (string-append "v" version))))
487 (file-name (git-file-name name version))
488 (sha256
489 (base32
490 "0r82iiwqsb73k2fxw7842rjjiixllxpyc6yl9cq4ma6ybkf6xmzm"))
491 (modules '((guix build utils)))
492 (snippet
493 '(begin
494 ;; FIXME: Unneeded runtime dependency.
495 ;; https://github.com/indutny/llparse-builder/pull/2
496 (substitute* "package.json"
497 (("\"@types/debug.*,") ""))
498 ;; Fix imports for esbuild.
499 ;; https://github.com/evanw/esbuild/issues/477
500 (substitute* '("src/node/invoke.ts"
501 "src/node/base.ts"
502 "src/node/consume.ts"
503 "src/node/match.ts"
504 "src/node/error.ts"
505 "src/node/pause.ts"
506 "src/edge.ts"
507 "src/utils.ts"
508 "src/loop-checker/index.ts"
509 "src/loop-checker/lattice.ts"
510 "src/code/field.ts"
511 "src/span-allocator.ts")
512 (("\\* as assert") "assert")
513 (("\\* as debugAPI") "debugAPI"))
514 #t))))
515 (build-system node-build-system)
516 (arguments
517 `(#:node ,node-bootstrap
518 #:tests? #f
519 #:phases
520 (modify-phases %standard-phases
521 (add-after 'patch-dependencies 'delete-dependencies
522 (lambda _
523 (modify-json (delete-dependencies
524 `("@types/mocha"
525 "@types/node"
526 "mocha"
527 "ts-node"
528 "tslint"
529 "typescript")))))
530 (replace 'build
531 (lambda* (#:key inputs #:allow-other-keys)
532 (let ((esbuild (search-input-file inputs "/bin/esbuild")))
533 (invoke esbuild
534 "--platform=node"
535 "--outfile=lib/builder.js"
536 "--bundle"
537 "src/builder.ts")))))))
538 (inputs
539 (list node-binary-search-bootstrap node-debug-bootstrap))
540 (native-inputs
541 (list esbuild))
542 (home-page "https://github.com/indutny/llparse-builder#readme")
543 (properties '((hidden? . #t)))
544 (synopsis "Graph builder for consumption by llparse")
545 (description "This package builds graphs for consumption by llparse.")
546 (license license:expat)))
547
548(define-public node-llparse-frontend-bootstrap
549 (package
550 (name "node-llparse-frontend")
551 (version "3.0.0")
552 (source
553 (origin
554 (method git-fetch)
555 (uri (git-reference
556 (url "https://github.com/indutny/llparse-frontend.git")
557 (commit (string-append "v" version))))
558 (file-name (git-file-name name version))
559 (sha256
560 (base32 "1rm9g4ifyip30svm5cgnf0gx7d45jgh4mpf2hkd092xhngmfvicc"))
561 (modules '((guix build utils)))
562 (snippet
563 '(begin
564 ;; Fix imports for esbuild.
565 ;; https://github.com/evanw/esbuild/issues/477
566 (substitute* '("src/frontend.ts"
567 "src/code/field-value.ts"
568 "src/container/index.ts"
569 "src/container/wrap.ts"
570 "src/node/sequence.ts"
571 "src/node/single.ts"
572 "src/node/table-lookup.ts"
573 "src/trie/index.ts")
574 (("\\* as assert") "assert")
575 (("\\* as debugAPI") "debugAPI"))
576 #t))))
577 (build-system node-build-system)
578 (arguments
579 `(#:node ,node-bootstrap
580 #:tests? #f
581 #:phases
582 (modify-phases %standard-phases
583 (add-after 'patch-dependencies 'delete-dependencies
584 (lambda args
585 (modify-json (delete-dependencies
586 `("@types/debug"
587 "@types/mocha"
588 "@types/node"
589 "mocha"
590 "ts-node"
591 "tslint"
592 "typescript")))))
593 (replace 'build
594 (lambda* (#:key inputs #:allow-other-keys)
595 (let ((esbuild (search-input-file inputs "/bin/esbuild")))
596 (invoke esbuild
597 "--platform=node"
598 "--outfile=lib/frontend.js"
599 "--bundle"
600 "src/frontend.ts")))))))
601 (inputs
602 (list node-debug-bootstrap node-llparse-builder-bootstrap))
603 (native-inputs
604 (list esbuild))
605 (home-page "https://github.com/indutny/llparse-frontend#readme")
606 (properties '((hidden? . #t)))
607 (synopsis "Frontend for the llparse compiler")
608 (description "This package is a frontend for the llparse compiler.")
609 (license license:expat)))
610
611(define-public node-llparse-bootstrap
612 (package
613 (name "node-llparse")
614 (version "7.1.0")
615 (source
616 (origin
617 (method git-fetch)
618 (uri (git-reference
619 (url "https://github.com/indutny/llparse.git")
620 (commit (string-append "v" version))))
621 (file-name (git-file-name name version))
622 (sha256
623 (base32
624 "10da273iy2if88hp79cwms6c8qpsl1fkgzll6gmqyx5yxv5mkyp6"))
625 (modules '((guix build utils)))
626 (snippet
627 '(begin
628 ;; Fix imports for esbuild.
629 ;; https://github.com/evanw/esbuild/issues/477
630 (substitute* '("src/compiler/index.ts"
631 "src/implementation/c/node/base.ts"
632 "src/implementation/c/node/table-lookup.ts"
633 "src/implementation/c/compilation.ts"
634 "src/implementation/c/helpers/match-sequence.ts"
635 "src/implementation/c/code/mul-add.ts")
636 (("\\* as assert") "assert")
637 (("\\* as debugAPI") "debugAPI"))
638 #t))))
639 (build-system node-build-system)
640 (arguments
641 `(#:node ,node-bootstrap
642 #:tests? #f
643 #:phases
644 (modify-phases %standard-phases
645 (add-after 'patch-dependencies 'delete-dependencies
646 (lambda args
647 (modify-json (delete-dependencies
648 `("@types/debug"
649 "@types/mocha"
650 "@types/node"
651 "esm"
652 "llparse-test-fixture"
653 "mocha"
654 "ts-node"
655 "tslint"
656 "typescript")))))
657 (replace 'build
658 (lambda* (#:key inputs #:allow-other-keys)
659 (let ((esbuild (search-input-file inputs "/bin/esbuild")))
660 (invoke esbuild
661 "--platform=node"
662 "--outfile=lib/api.js"
663 "--bundle"
664 "src/api.ts")))))))
665 (inputs
666 (list node-debug-bootstrap node-llparse-frontend-bootstrap))
667 (native-inputs
668 (list esbuild))
669 (home-page "https://github.com/nodejs/llparse#readme")
670 (properties '((hidden? . #t)))
671 (synopsis "Compile incremental parsers to C code")
672 (description "This package offers an API for compiling an incremental
673parser definition into a C output.")
674 (license license:expat)))
675
676(define-public llhttp-bootstrap
677 (package
678 (name "llhttp")
679 (version "9.2.1")
680 (source (origin
681 (method git-fetch)
682 (uri (git-reference
683 (url "https://github.com/nodejs/llhttp.git")
684 (commit (string-append "v" version))))
685 (file-name (git-file-name name version))
686 (sha256
687 (base32
688 "0mzg19aqb1am498gms0z75cwd5kmfg9p78b1hhxw67019nsjcbac"))
689 (patches (search-patches "llhttp-ponyfill-object-fromentries.patch"))
690 (modules '((guix build utils)))
691 (snippet
692 '(begin
693 ;; Fix imports for esbuild.
694 ;; https://github.com/evanw/esbuild/issues/477
695 (substitute* "src/llhttp/http.ts"
696 (("\\* as assert") "assert"))
697 (substitute* "Makefile"
698 (("npx ts-node bin/generate.ts")
699 "node bin/generate.js"))
700 #t))))
701 (build-system gnu-build-system)
702 (arguments
703 `(#:tests? #f ; no tests
704 #:make-flags (list (string-append "CLANG=" ,(cc-for-target))
705 (string-append "DESTDIR=" (assoc-ref %outputs "out"))
706 "PREFIX=")
707 #:phases
708 (modify-phases %standard-phases
709 (replace 'configure
710 (lambda* (#:key inputs native-inputs #:allow-other-keys)
711 (let ((esbuild (search-input-file (or native-inputs inputs)
712 "/bin/esbuild")))
713 (invoke esbuild
714 "--platform=node"
715 "--target=node10"
716 "--outfile=bin/generate.js"
717 "--bundle" "bin/generate.ts"))))
718 (add-before 'install 'create-install-directories
719 (lambda* (#:key outputs #:allow-other-keys)
720 (let ((out (assoc-ref outputs "out")))
721 (for-each (lambda (dir)
722 (mkdir-p (string-append out dir)))
723 (list "/lib" "/include" "/src"))
724 #t)))
725 (add-after 'install 'install-src
726 (lambda* (#:key outputs #:allow-other-keys)
727 (let* ((out (assoc-ref outputs "out"))
728 (src-dir (string-append out "/src")))
729 (install-file "build/c/llhttp.c" src-dir)
730 (install-file "src/native/api.c" src-dir)
731 (install-file "src/native/http.c" src-dir)
732 #t))))))
733 (native-inputs
734 `(("esbuild" ,esbuild)
735 ("node" ,node-bootstrap)
736 ("node-semver" ,node-semver-bootstrap)
737 ("node-llparse-bootstrap" ,node-llparse-bootstrap)))
738 (home-page "https://github.com/nodejs/llhttp")
739 (properties '((hidden? . #t)))
740 (synopsis "Parser for HTTP messages")
741 (description "This is a rewrite of
742@url{https://github.com/nodejs/http-parser, http-parser} using
743@url{https://github.com/nodejs/llparse, llparse} to generate the C
744source files.")
745 (license license:expat)))
746
747(define-public node-lts
748 (package
749 (inherit node-bootstrap)
750 (version "22.14.0")
751 (source (origin
752 (method url-fetch)
753 (uri (string-append "https://nodejs.org/dist/v" version
754 "/node-v" version ".tar.gz"))
755 (sha256
756 (base32
757 "12msprh604s6qdsgwymxw4kl8ivaldbaydf4v37lbp02aznk2kkc"))
758 (modules '((guix build utils)))
759 (snippet
760 '(begin
761 ;; openssl.cnf is required for build.
762 (for-each delete-file-recursively
763 (find-files "deps/openssl"
764 (lambda (file stat)
765 (not (string-contains file "nodejs-openssl.cnf")))))
766 ;; Remove bundled software, where possible
767 (for-each delete-file-recursively
768 '("deps/brotli"
769 "deps/cares"
770 "deps/icu-small"
771 "deps/nghttp2"
772 "deps/ngtcp2"
773 "deps/uv"
774 "deps/zlib"))))))
775 (arguments
776 (substitute-keyword-arguments (package-arguments node-bootstrap)
777 ((#:configure-flags configure-flags)
778 ''("--shared-cares"
779 "--shared-libuv"
780 "--shared-nghttp2"
781 "--shared-openssl"
782 "--shared-zlib"
783 "--shared-brotli"
784 "--with-intl=system-icu"
785 "--shared-ngtcp2"
786 "--shared-nghttp3"
787 ;;Needed for correct snapshot checksums
788 "--v8-enable-snapshot-compression"))
789 ((#:phases phases)
790 `(modify-phases ,phases
791 (replace 'set-bootstrap-host-rpath
792 (lambda* (#:key native-inputs inputs #:allow-other-keys)
793 (let* ((inputs (or native-inputs inputs))
794 (c-ares (assoc-ref inputs "c-ares"))
795 (brotli (assoc-ref inputs "brotli"))
796 (icu4c (assoc-ref inputs "icu4c"))
797 (nghttp2 (assoc-ref inputs "nghttp2"))
798 (openssl (assoc-ref inputs "openssl"))
799 (libuv (assoc-ref inputs "libuv"))
800 (zlib (assoc-ref inputs "zlib"))
801 (host-binaries '("torque"
802 "bytecode_builtins_list_generator"
803 "gen-regexp-special-case"
804 "node_mksnapshot"
805 "mksnapshot")))
806 (substitute* '("node.gyp" "tools/v8_gypfiles/v8.gyp")
807 (((string-append "'target_name': '("
808 (string-join host-binaries "|")
809 ")',")
810 target)
811 (string-append target
812 "'ldflags': ['-Wl,-rpath="
813 c-ares "/lib:"
814 brotli "/lib:"
815 icu4c "/lib:"
816 nghttp2 "/lib:"
817 openssl "/lib:"
818 libuv "/lib:"
819 zlib "/lib"
820 "'],"))))))
821 (add-after 'patch-hardcoded-program-references
822 'patch-additional-hardcoded-program-references
823 (lambda* (#:key inputs #:allow-other-keys)
824 (substitute* "test/parallel/test-stdin-from-file-spawn.js"
825 (("'/bin/sh'") (string-append
826 "'" (search-input-file inputs "/bin/sh")
827 "'")))))
828 (replace 'delete-problematic-tests
829 (lambda* (#:key inputs #:allow-other-keys)
830 ;; FIXME: These tests fail in the build container, but they don't
831 ;; seem to be indicative of real problems in practice.
832 (for-each delete-file
833 '("test/parallel/test-cluster-primary-error.js"
834 "test/parallel/test-cluster-primary-kill.js"
835 "test/parallel/test-node-run.js"))
836
837 ;; These require a DNS resolver.
838 (for-each delete-file
839 '("test/parallel/test-dns.js"
840 "test/parallel/test-dns-lookupService-promises.js"
841 "test/parallel/test-net-socket-connect-without-cb.js"
842 "test/parallel/test-tcp-wrap-listen.js"
843 "test/report/test-report-exclude-network.js"))
844
845 ;; These tests require networking.
846 (for-each delete-file
847 '("test/parallel/test-https-agent-unref-socket.js"))
848
849 ;; This test is timing-sensitive, and fails sporadically on
850 ;; slow, busy, or even very fast machines.
851 (delete-file "test/parallel/test-fs-utimes.js")
852
853 ;; FIXME: This test fails randomly:
854 ;; https://github.com/nodejs/node/issues/31213
855 (delete-file "test/parallel/test-net-listen-after-destroying-stdin.js")
856
857 ;; FIXME: These tests fail on armhf-linux:
858 ;; https://github.com/nodejs/node/issues/31970
859 ,@(if (target-arm32?)
860 '((for-each delete-file
861 '("test/parallel/test-zlib.js"
862 "test/parallel/test-zlib-brotli.js"
863 "test/parallel/test-zlib-brotli-flush.js"
864 "test/parallel/test-zlib-brotli-from-brotli.js"
865 "test/parallel/test-zlib-brotli-from-string.js"
866 "test/parallel/test-zlib-convenience-methods.js"
867 "test/parallel/test-zlib-random-byte-pipes.js"
868 "test/parallel/test-zlib-write-after-flush.js")))
869 '())
870
871 ;; https://github.com/nodejs/node/issues/45906
872 ;; This test depends on 64-bit time_t so skipping on 32-bit systems.
873 ,@(if (target-32bit?)
874 '((delete-file "test/parallel/test-fs-utimes-y2K38.js")
875
876 (delete-file "test/parallel/test-debugger-heap-profiler.js"))
877 '())
878
879 ;; These tests have an expiry date: they depend on the validity of
880 ;; TLS certificates that are bundled with the source. We want this
881 ;; package to be reproducible forever, so remove those.
882 ;; TODO: Regenerate certs instead.
883 (for-each delete-file
884 '("test/parallel/test-tls-passphrase.js"
885 "test/parallel/test-tls-server-verify.js"))
886
887 ;; These tests fail when linking to upstream libuv.
888 ;; https://github.com/nodejs/node/commit/3f6addd590
889 (for-each delete-file
890 '("test/parallel/test-process-euid-egid.js"
891 "test/parallel/test-process-initgroups.js"
892 "test/parallel/test-process-setgroups.js"
893 "test/parallel/test-process-uid-gid.js"))))
894 (add-after 'delete-problematic-tests 'patch-problematic-tests
895 (lambda _
896 ;; XXX: These tests seem to not work by default
897 (substitute*
898 '("test/parallel/test-http2-premature-close.js"
899 "test/parallel/test-http2-invalid-last-stream-id.js")
900 (("client\\.connect\\(address\\)")
901 "client.connect(address.port)"))))
902 (add-after 'delete-problematic-tests 'replace-llhttp-sources
903 (lambda* (#:key inputs #:allow-other-keys)
904 ;; Replace pre-generated llhttp sources
905 (let ((llhttp (assoc-ref inputs "llhttp")))
906 (copy-file (string-append llhttp "/src/llhttp.c")
907 "deps/llhttp/src/llhttp.c")
908 (copy-file (string-append llhttp "/src/api.c")
909 "deps/llhttp/src/api.c")
910 (copy-file (string-append llhttp "/src/http.c")
911 "deps/llhttp/src/http.c")
912 (copy-file (string-append llhttp "/include/llhttp.h")
913 "deps/llhttp/include/llhttp.h"))))
914 ;; npm installs dependencies by copying their files over a tar
915 ;; stream. A file with more than one hardlink is marked as a
916 ;; "Link". pacote/lib/fetcher.js calls node-tar's extractor with a
917 ;; filter that ignores any "Link" entries. This means that
918 ;; dependending on the number of hardlinks on files in a node-*
919 ;; package *some* of its files may not be installed when generating
920 ;; another package's "node_modules" directory. The build output
921 ;; would differ depending on irrelevant file system state.
922 ;;
923 ;; To avoid this, we patch node-tar to treat files with hardlinks
924 ;; the same as any other file, so that node-tar has no choice but
925 ;; to extract all of them --- independent of pacote's filter.
926 ;;
927 ;; Why not patch pacote's filter instead? This has led to subtle
928 ;; differences in where the files are installed, so it's easier to
929 ;; just ensure that files with hardlinks are always treated as
930 ;; regular files.
931 ;;
932 ;; Discussion:
933 ;; https://lists.gnu.org/archive/html/guix-devel/2023-07/msg00040.html
934 ;; Upstream bug report:
935 ;; https://github.com/npm/pacote/issues/285
936 (add-after 'install 'ignore-number-of-hardlinks
937 (lambda* (#:key outputs #:allow-other-keys)
938 (let ((file (string-append (assoc-ref outputs "out")
939 "/lib/node_modules/npm/node_modules"
940 "/tar/lib/write-entry.js")))
941 (substitute* file
942 (("this.stat.nlink > 1") "false")))))
943 (add-after 'install 'install-node-gyp-wrapper
944 (lambda* (#:key inputs outputs #:allow-other-keys)
945 (let* ((out (assoc-ref outputs "out"))
946 (dir (string-append out "/lib/node_modules/npm/bin/node-gyp-bin"))
947 (file (string-append dir "/node-gyp")))
948 (mkdir-p dir)
949 ;; See https://github.com/npm/cli/issues/6842
950 (call-with-output-file file
951 (lambda (port)
952 (format port "#!~a/bin/sh
953if [ \"x$npm_config_node_gyp\" = \"x\" ]; then
954 ~a/bin/node \"~a/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js\" \"$@\"
955else
956 \"$npm_config_node_gyp\" \"$@\"
957fi"
958 (assoc-ref inputs "bash")
959 out
960 out)))
961 (chmod file #o555))))))))
962 (native-inputs
963 (list ;; Runtime dependencies for binaries used as a bootstrap.
964 c-ares-for-node-lts
965 brotli
966 icu4c-76
967 libuv-for-node-lts
968 `(,nghttp2 "lib")
969 openssl
970 zlib
971 ; ngtcp2? nghttp3?
972 ;; Regular build-time dependencies.
973 perl
974 pkg-config
975 procps
976 python
977 util-linux))
978 (inputs
979 (list bash-minimal
980 coreutils
981 c-ares-for-node-lts
982 icu4c-76
983 libuv-for-node-lts
984 llhttp-bootstrap
985 brotli
986 ngtcp2
987 nghttp3
988 `(,nghttp2 "lib")
989 openssl
990 zlib))
991 (supported-systems
992 (cons "riscv64-linux" (package-supported-systems node-bootstrap)))
993 (properties (alist-delete 'hidden? (package-properties node-bootstrap)))))
994
995(define-public node node-lts)
996
997(define-public libnode
998 (package/inherit node-lts
999 (name "libnode")
1000 (arguments
1001 (substitute-keyword-arguments (package-arguments node-lts)
1002 ((#:configure-flags flags ''())
1003 `(cons* "--shared" "--without-npm" ,flags))
1004 ((#:phases phases '%standard-phases)
1005 `(modify-phases ,phases
1006 (delete 'install-npmrc)
1007 (delete 'patch-nested-shebangs)
1008 (delete 'ignore-number-of-hardlinks)))))))