Compare commits

...

37 Commits

Author SHA1 Message Date
Jelle Licht
1cd09ce1ec gnu: node-lts: Update to 24.14.1.
* gnu/packages/node.scm (node-lts): Update to 24.14.1.

Change-Id: I60457e8e8e05e0102feb450655113ba410bd7667
2026-04-05 23:31:19 +02:00
Jelle Licht
4b7a750b64 gnu: node-nan: Update to 2.26.2.
* gnu/packages/node-xyz.scm (node-nan): Update to 2.26.2.

Change-Id: I84c8aa254540646c559b4b65646083e1ea961d75
2026-04-05 23:31:18 +02:00
Jelle Licht
5d1c8cfa1e gnu: node-openzwave-shared: Fix compilation for new versions of node.
* gnu/packages/zwave.scm (node-openzwave-shared):[arguments]<#:phases>:Adjust
patch-compiler phase use std=c++20 to allow compilation with node versions 24
and up.

Change-Id: I04b4657c025d233f4abbbc4d3829ca44351fdae3
2026-04-05 23:31:18 +02:00
Jelle Licht
a4a3fe08c1 Revert "build-system: node: Rewrite modify-json."
This reverts commit dff01d4eb1. The #:file
keyword argument was still part of the rest arguments, which lead to custom
file arguments being called as functions due to the `apply compose'.

Change-Id: I91d6b576adb7ebb5af6a584e999248b5cc410f6a
2026-04-05 23:31:18 +02:00
Jelle Licht
e095512494 gnu: node-lts: Update to 24.14.0.
* gnu/packages/node.scm (node-lts): Update to 24.14.0.

Change-Id: I51f3c4c77530a81ddac6dc0ebbef0c0f2897c875
2026-04-05 23:31:18 +02:00
Jelle Licht
4a1f2852e1 gnu: node-lts: Update to 24.11.0.
* gnu/packages/node.scm (node-lts): Update to 24.11.0.
[arguments]<#:phases>: Adjust 'ignore-number-of-hardlinks phase to patch both
ESM and CJS modules. Remove deprecated 'install-node-gyp-wrapper phase.
Introduce new replacement for 'fix-node-gyp-references phase.

Change-Id: I1a372ceb10e31ecfedeff7653030708efa97dab9
2026-04-05 23:31:18 +02:00
Jelle Licht
649fc872ba gnu: node-bootstrap: Rename phase that fixes node-gyp references
* gnu/packages/node.scm (node-bootstrap)[arguments]<#:phases>: Rename
install-npmrc phase to fix-node-gyp-reference.
(libnode)[arguments]<#:phases>: Delete 'fix-node-gyp-reference phase instead
of 'install-npmrc phase.

Change-Id: I062753b79e42e5a8a311b019855168bb96a566b2
2026-04-05 23:31:18 +02:00
Jelle Licht
6199e6609c build-system: tree-sitter: Fix lockfiles extensibility.
* guix/build-system/tree-sitter.scm (tree-sitter-build-build): Add and pass
along lockfiles argument.
(tree-sitter-cross-build): Likewise.

Change-Id: I6f68c0741f21ff26367dd37ff3c53e612fdc9bc2
2026-04-05 23:31:17 +02:00
Jelle Licht
ec6b8c9808 build-system: node: Export %default-lockfiles for build systems.
* guix/build-system/node.scm (%default-lockfiles): New variable.

Change-Id: I8d9f01bf07670615a7c6012fca3e08308eab3c1c
2026-04-05 23:31:17 +02:00
Jelle Licht
429f698c17 gnu: r-v8: Fix build with node-lts@24.
The version bump of node-lts from 22 to 24 also bumped the version in the so-file.

* gnu/packages/cran.scm (r-v8)[#:phases]<find-v8>: Look for libnode-so.137 as
provided by node-lts@24.

Change-Id: I41bf86cd387c49b214d84a43135fca969a515202
2026-04-05 23:31:17 +02:00
Jelle Licht
efa499747f build-system: node: Use file:// prefix for local dependencies.
Using the file:// prefix for local packages was always allowed, and since npm
version 11 required in order to properly resolve local dependencies when
installing from tarballs.

* guix/build/node-build-system.scm (index-modules): Add "file://" prefix to
hash table values for local modules.

Change-Id: I9d95a5d6788cc918b94677b4524391617e3a73b4
2026-04-05 23:31:17 +02:00
Nicolas Graves
c81f5b764c build-system: node: Refresh phase 'configure.
* guix/build/node-build-system.scm (configure): Remove unused outputs
argument, add --no-outputs flag.

Change-Id: Icf0d5d23cf70abc9168038e79c995391fae48e6a
Signed-off-by: Jelle Licht <jlicht@fsfe.org>
2026-04-05 23:31:17 +02:00
Nicolas Graves
3298ea0db1 build-system: node: Refresh phase 'avoid-node-gyp-rebuild.
* guix/build/node-build-system.scm (avoid-node-gyp-rebuild): Refresh
phase by using let* instead of multiple defines.

Change-Id: I30c53f5d7d5bc69444ddcef45cdf8eefcab7db84
Signed-off-by: Jelle Licht <jlicht@fsfe.org>
2026-04-05 23:31:16 +02:00
Nicolas Graves
db6af3ab1a build-system: node: Remove trailing #t.
* guix/build/node-build-system.scm (set-home, delete-lockfiles, build,
repack, install): Remove trailing #t.

Change-Id: Idf5ba50242a7b9fb5d30c8fca6e6662471cf87e4
Signed-off-by: Jelle Licht <jlicht@fsfe.org>
2026-04-05 23:31:16 +02:00
Nicolas Graves
0987ec2b82 build-system: node: Rewrite phase 'patch-dependencies.
* guix/build/node-build-system.scm (alist-update): Remove procedure.
(patch-dependencies): Rewrite using modify-json and higher-order
function resolve.

Change-Id: I6a3e30526d5523b559d48317f0e052f2b1dcf04c
Signed-off-by: Jelle Licht <jlicht@fsfe.org>
2026-04-05 23:31:16 +02:00
Nicolas Graves
709c37f4db build-system: node: Improve lockfiles extensibility.
* guix/build-system/node.scm (%default-lockfiles): New variable.
(node-build): Add lockfiles argument.

* guix/build/node-build-system.scm (delete-lockfiles): Re-factor with
lockfiles argument.

Change-Id: I09927977ec7c6430191f592f7f36d4030721c520
Signed-off-by: Jelle Licht <jlicht@fsfe.org>
2026-04-05 23:31:16 +02:00
Nicolas Graves
ce843095f4 build-system: node: Improve (default-guile-json) import style.
Also place it just after (default-node).

* guix/build-system/node.scm (default-guile-json): Place it
after (default-node) and use helper macro @*.

Change-Id: Idc21c9627f414a011915033da0cab845529ddbff
Signed-off-by: Jelle Licht <jlicht@fsfe.org>
2026-04-05 23:31:16 +02:00
Nicolas Graves
2487ff1879 build-system: node: Rewrite modify-json.
This function seems way too complex for what it's trying to do.

* guix/build/node-build-system.scm (modify-json): Rewrite procedure
using apply and compose.

Change-Id: I6419bd32eea76031393573a1d6450571d092ec4d
Signed-off-by: Jelle Licht <jlicht@fsfe.org>
2026-04-05 23:31:16 +02:00
Nicolas Graves
71ef5c0ab6 build-system: node: Refresh delete-dependencies procedure.
* guix/build/node-build-system.scm (delete-dependencies): Use map and
match-lambda to improve readability of the phase.

Change-Id: I6d9275c7eea1514f103988215916d478a68ea466
Signed-off-by: Jelle Licht <jlicht@fsfe.org>
2026-04-05 23:31:15 +02:00
Nicolas Graves
4b4ea6eb9d build-system: node: Remove alist-pop, simplify alist-update.
Those functions are most likely not worth the complexity they carry.
They might be a little more efficient (stop at the first encounter
instead of mapping until the end), but is it worth the additional
complexity? I'm unsure.

* guix/build/node-build-system.scm (alist-pop): Remove variable.
(alist-update): Use a more standard map.

Change-Id: I47b91461849d6e6d627e98f67bc6a08f12fa7370
Signed-off-by: Jelle Licht <jlicht@fsfe.org>
2026-04-05 23:31:15 +02:00
Nicolas Graves
65c24e5e11 build-system: node: Remove assoc-ref* helper.
This procedure has little added value and is basically equivalent to a
simple composition of assoc-ref and or.

* guix/build/node-build-system.scm (assoc-ref*): Remove procedure.
(patch-dependencies, build, avoid-node-gyp-rebuild): Replace use of
assoc-ref*.

Change-Id: I947a66fe91eaa2b4adc8dc405232a32257f9d061
Signed-off-by: Jelle Licht <jlicht@fsfe.org>
2026-04-05 23:31:15 +02:00
Jelle Licht
07085345a2 gnu: node-lts: Update to 24.9.0.
* gnu/packages/node.scm (node-lts): Update to 24.9.0.

Change-Id: I0ed967dc028e88f927cf24e08bc51d6fc6933998
2026-04-05 23:31:15 +02:00
Jelle Licht
98b2e3853b gnu: node-lts: Update to 24.8.0.
* gnu/packages/node.scm (node-lts): Update to 24.8.0.

Change-Id: I1950d278b9105e72adad2401e4d1ef78c78da16f
2026-04-05 23:31:15 +02:00
Jelle Licht
0e6f3fab58 gnu: node-lts: Update to 24.7.0.
* gnu/packages/node.scm (node-lts): Update to 24.7.0.

Change-Id: I1384b65244c16c67d2aad13931ac0af6e9ce2acf
2026-04-05 23:31:14 +02:00
Jelle Licht
d4ddddd9b4 gnu: node-lts: Update to 24.6.0.
* gnu/packages/node.scm (node-lts): Update to 24.6.0.

Change-Id: I2aca0c22cf13306d76ba274a78a4560b43be0de4
2026-04-05 23:31:14 +02:00
Jelle Licht
ca11af32e2 gnu: node-lts: Update to 24.5.0.
* gnu/packages/node.scm (node-lts): Update to 24.5.0.

Change-Id: I09ab8f4c9fc16c534519ff6b48c02adf2796f5a3
2026-04-05 23:31:14 +02:00
Jelle Licht
40e40dafc4 gnu: node-lts: Update to 24.4.1.
* gnu/packages/node.scm (node-lts): Update to 24.4.1.

Change-Id: I13e3a6ce872ba3cd24050b4df72c7c626746b4fe
2026-04-05 23:31:14 +02:00
Jelle Licht
2533fec0e1 gnu: node-lts: Update to 24.4.0.
* gnu/packages/node.scm (node-lts): Update to 24.4.0.

Change-Id: Id2a929edfb2deb8149cbb97e93d2427fb946121a
2026-04-05 23:31:14 +02:00
Jelle Licht
462dc862b0 gnu: node-lts: Update to 24.3.0.
* gnu/packages/node.scm (node-lts): Update to 24.3.0.

Change-Id: Iff0e02f30300fe55e71e4e4e0c15578f3095ba9e
2026-04-05 23:31:14 +02:00
Jelle Licht
abd6fc6d49 gnu: node-lts: Update to 24.2.0.
* gnu/packages/node.scm (node-lts): Update to 24.2.0.
[source]: Update snippet to delete bundled llhttp and zstd sources.
[arguments]<#:configure-flags>: Add "--shared-http-parser" and
"--shared-http-parser-libname=llhttp". Add "--shared-zstd".
<#:phases>: Delete 'replace-llhttp-sources phase.
[inputs]: Add (zstd-1.5.7 "lib").

Change-Id: I44c7accf85a2d88b34438fa506ff725739e995ce
2026-04-05 23:31:13 +02:00
Jelle Licht
7c7c4ba6f5 gnu: libuv-for-node-lts: Update to 1.51.0.
* gnu/packages/libevent.scm (libuv-for-node-lts): Update to 1.51.0.

Change-Id: I6a49d7337ff62f54004dde24803c43490e2daac4
2026-04-05 23:31:13 +02:00
Jelle Licht
7b8101940c gnu: llhttp-bootstrap: Update to 9.3.0.
* gnu/packages/node.scm (llhttp-bootstrap): Update to 9.3.0.

Change-Id: Id18f84a582f12ef3ebb31f214bbb4da7e39018de
2026-04-05 23:31:13 +02:00
Jelle Licht
9d3d936e2f gnu: node-llparse-bootstrap: Update to 7.3.0.
* gnu/packages/node.scm (node-llparse-bootstrap): Update to 7.3.0.

Change-Id: I1a84ea216933bf4ce12c12782d57fef5b4891f4c
2026-04-05 23:31:13 +02:00
Jelle Licht
dd5c11de2b gnu: node-llparse-frontend-bootstrap: Update to 3.0.0.
* gnu/packages/node.scm (node-llparse-frontend-bootstrap): Update to 3.0.0.

Change-Id: I11957e5238999f85db00b39548a590ccd6feed47
2026-04-05 23:31:13 +02:00
Jelle Licht
9247fd3bc7 gnu: node-llparse-builder-bootstrap: Update to 1.5.2.
* gnu/packages/node.scm (node-llparse-builder-bootstrap): Update to 1.5.2.

Change-Id: I886eceb7f284fe1ba4c3ccb2c3bfea5e0fd9c9dd
2026-04-05 23:31:12 +02:00
Jelle Licht
721e60ef98 gnu: node-lts: Update to 24.0.1.
* gnu/packages/node.scm (node-lts): Update to 24.0.1.
[arguments]<#:phases>: Add timing-sensitive test to 'delete-problematic-tests
phase.
[native-inputs]: Add gcc-14.

Change-Id: I28fc890e40070dc50bd40b89c1bd98ffabc7be5d
2026-04-05 23:31:12 +02:00
Jelle Licht
4f9a5a1a02 gnu: libuv-for-node-lts: Update to 1.50.0.
* gnu/packages/libevent.scm (libuv-for-node-lts): Update to 1.50.0.

Change-Id: Ic51d832d30872d31b070ecfe1a51daff26dedeea
2026-04-05 23:31:09 +02:00
8 changed files with 149 additions and 187 deletions

View File

@@ -8760,7 +8760,7 @@ similar rank-based tests for equal probability distributions due to Neuhauser
(("^PKG_LIBS=.*")
(string-append "PKG_LIBS="
(assoc-ref inputs "libnode")
"/lib/libnode.so.127\n")))
"/lib/libnode.so.137\n")))
(setenv "INCLUDE_DIR"
(string-append
(assoc-ref inputs "libnode")

View File

@@ -164,14 +164,14 @@ resolution, asynchronous file system operations, and threading primitives.")
(package
(inherit libuv)
(name "libuv")
(version "1.49.2")
(version "1.51.0")
(source (origin
(method url-fetch)
(uri (string-append "https://dist.libuv.org/dist/v" version
"/libuv-v" version ".tar.gz"))
(sha256
(base32
"1a75p8wp4l43y2ffj1szs1ssm6nzjad7k51bqi2r04ngs9mp044c"))))
"1szqivvs7izbhw1a3nd1ipbk012yvqqkjg0sjmqxw1hi1fwmf1az"))))
(properties '((hidden? . #t)))))
(define-public libuv-for-r-httpuv

View File

@@ -2324,7 +2324,7 @@ a string consisting of a number and a time unit is converted to milliseconds.")
(define-public node-nan
(package
(name "node-nan")
(version "2.22.0")
(version "2.26.2")
(source
(origin
(method git-fetch)
@@ -2333,7 +2333,7 @@ a string consisting of a number and a time unit is converted to milliseconds.")
(commit (string-append "v" version))))
(file-name (git-file-name name version))
(sha256
(base32 "02gqm23x26glffvyxrnk610hy3hg0kwh2v58dhnb032l0jhjzqvp"))))
(base32 "18xv0m40jgy3sc4pldw95w6p72ms5a5h0x2sm2mimlwlmxmrjlmb"))))
(build-system node-build-system)
(arguments
`(#:phases

View File

@@ -274,7 +274,7 @@
(lambda (file stat)
(executable-file? file))
#:stat lstat)))))
(add-after 'install 'install-npmrc
(add-after 'install 'fix-node-gyp-reference
;; Note: programs like node-gyp only receive these values if
;; they are started via `npm` or `npx`.
;; See: https://github.com/nodejs/node-gyp#npm-configuration
@@ -482,7 +482,7 @@ Node.js and web browsers.")
(origin
(method git-fetch)
(uri (git-reference
(url "https://github.com/indutny/llparse-builder.git")
(url "https://github.com/nodejs/llparse-builder.git")
(commit (string-append "v" version))))
(file-name (git-file-name name version))
(sha256
@@ -491,10 +491,6 @@ Node.js and web browsers.")
(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"
@@ -521,7 +517,8 @@ Node.js and web browsers.")
(add-after 'patch-dependencies 'delete-dependencies
(lambda _
(modify-json (delete-dependencies
`("@types/mocha"
`("@types/debug"
"@types/mocha"
"@types/node"
"mocha"
"ts-node"
@@ -539,7 +536,7 @@ Node.js and web browsers.")
(list node-binary-search-bootstrap node-debug-bootstrap))
(native-inputs
(list esbuild))
(home-page "https://github.com/indutny/llparse-builder#readme")
(home-page "https://github.com/nodejs/llparse-builder#readme")
(properties '((hidden? . #t)))
(synopsis "Graph builder for consumption by llparse")
(description "This package builds graphs for consumption by llparse.")
@@ -553,7 +550,7 @@ Node.js and web browsers.")
(origin
(method git-fetch)
(uri (git-reference
(url "https://github.com/indutny/llparse-frontend.git")
(url "https://github.com/nodejs/llparse-frontend.git")
(commit (string-append "v" version))))
(file-name (git-file-name name version))
(sha256
@@ -602,7 +599,7 @@ Node.js and web browsers.")
(list node-debug-bootstrap node-llparse-builder-bootstrap))
(native-inputs
(list esbuild))
(home-page "https://github.com/indutny/llparse-frontend#readme")
(home-page "https://github.com/nodejs/llparse-frontend#readme")
(properties '((hidden? . #t)))
(synopsis "Frontend for the llparse compiler")
(description "This package is a frontend for the llparse compiler.")
@@ -611,17 +608,17 @@ Node.js and web browsers.")
(define-public node-llparse-bootstrap
(package
(name "node-llparse")
(version "7.1.0")
(version "7.3.0")
(source
(origin
(method git-fetch)
(uri (git-reference
(url "https://github.com/indutny/llparse.git")
(url "https://github.com/nodejs/llparse.git")
(commit (string-append "v" version))))
(file-name (git-file-name name version))
(sha256
(base32
"10da273iy2if88hp79cwms6c8qpsl1fkgzll6gmqyx5yxv5mkyp6"))
"09hqjcynkz5iv7aydzdwgs42r7y2zylplv0ff7w0vkdsgb08j22a"))
(modules '((guix build utils)))
(snippet
'(begin
@@ -645,10 +642,14 @@ Node.js and web browsers.")
(add-after 'patch-dependencies 'delete-dependencies
(lambda args
(modify-json (delete-dependencies
`("@types/debug"
`("@stylistic/eslint-plugin"
"@typescript-eslint/eslint-plugin"
"@typescript-eslint/parser"
"@types/debug"
"@types/mocha"
"@types/node"
"esm"
"eslint"
"llparse-test-fixture"
"mocha"
"ts-node"
@@ -676,7 +677,7 @@ parser definition into a C output.")
(define-public llhttp-bootstrap
(package
(name "llhttp")
(version "9.2.1")
(version "9.3.0")
(source (origin
(method git-fetch)
(uri (git-reference
@@ -685,7 +686,7 @@ parser definition into a C output.")
(file-name (git-file-name name version))
(sha256
(base32
"0mzg19aqb1am498gms0z75cwd5kmfg9p78b1hhxw67019nsjcbac"))
"0yz4ys94pjq2fs2pihpqjvmxj2mbpm8k5prlm445z4qlajzlr4kb"))
(patches (search-patches "llhttp-ponyfill-object-fromentries.patch"))
(modules '((guix build utils)))
(snippet
@@ -747,14 +748,14 @@ source files.")
(define-public node-lts
(package
(inherit node-bootstrap)
(version "22.14.0")
(version "24.14.1")
(source (origin
(method url-fetch)
(uri (string-append "https://nodejs.org/dist/v" version
"/node-v" version ".tar.gz"))
(sha256
(base32
"12msprh604s6qdsgwymxw4kl8ivaldbaydf4v37lbp02aznk2kkc"))
"1cri5lp3a9jhh34dbd48hq2zyb7xjb9qs6zl36l3q2blawgwz642"))
(modules '((guix build utils)))
(snippet
'(begin
@@ -770,13 +771,17 @@ source files.")
"deps/icu-small"
"deps/nghttp2"
"deps/ngtcp2"
"deps/llhttp"
"deps/uv"
"deps/zlib"))))))
"deps/zlib"
"deps/zstd"))))))
(arguments
(substitute-keyword-arguments arguments
((#:configure-flags configure-flags)
''("--shared-cares"
"--shared-libuv"
"--shared-http-parser"
"--shared-http-parser-libname=llhttp"
"--shared-nghttp2"
"--shared-openssl"
"--shared-zlib"
@@ -784,6 +789,7 @@ source files.")
"--with-intl=system-icu"
"--shared-ngtcp2"
"--shared-nghttp3"
"--shared-zstd"
;;Needed for correct snapshot checksums
"--v8-enable-snapshot-compression"))
((#:phases phases)
@@ -846,9 +852,11 @@ source files.")
(for-each delete-file
'("test/parallel/test-https-agent-unref-socket.js"))
;; This test is timing-sensitive, and fails sporadically on
;; These tests are timing-sensitive, and fail sporadically on
;; slow, busy, or even very fast machines.
(delete-file "test/parallel/test-fs-utimes.js")
(for-each delete-file
'("test/parallel/test-fs-utimes.js"
"test/sequential/test-performance-eventloopdelay.js"))
;; FIXME: This test fails randomly:
;; https://github.com/nodejs/node/issues/31213
@@ -899,18 +907,6 @@ source files.")
"test/parallel/test-http2-invalid-last-stream-id.js")
(("client\\.connect\\(address\\)")
"client.connect(address.port)"))))
(add-after 'delete-problematic-tests 'replace-llhttp-sources
(lambda* (#:key inputs #:allow-other-keys)
;; 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"))))
;; npm installs dependencies by copying their files over a tar
;; stream. A file with more than one hardlink is marked as a
;; "Link". pacote/lib/fetcher.js calls node-tar's extractor with a
@@ -935,30 +931,22 @@ source files.")
;; https://github.com/npm/pacote/issues/285
(add-after 'install 'ignore-number-of-hardlinks
(lambda* (#:key outputs #:allow-other-keys)
(let ((file (string-append (assoc-ref outputs "out")
"/lib/node_modules/npm/node_modules"
"/tar/lib/write-entry.js")))
(substitute* file
(let ((dir (string-append (assoc-ref outputs "out")
"/lib/node_modules/npm/node_modules"
"/tar/dist")))
(substitute*
(list (string-append dir "/esm/write-entry.js")
(string-append dir "/commonjs/write-entry.js"))
(("this.stat.nlink > 1") "false")))))
(add-after 'install 'install-node-gyp-wrapper
(replace 'fix-node-gyp-reference
(lambda* (#:key inputs outputs #:allow-other-keys)
(let* ((out (assoc-ref outputs "out"))
(dir (string-append out "/lib/node_modules/npm/bin/node-gyp-bin"))
(file (string-append dir "/node-gyp")))
(mkdir-p dir)
;; See https://github.com/npm/cli/issues/6842
(call-with-output-file file
(lambda (port)
(format port "#!~a/bin/sh
if [ \"x$npm_config_node_gyp\" = \"x\" ]; then
~a/bin/node \"~a/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js\" \"$@\"
else
\"$npm_config_node_gyp\" \"$@\"
fi"
(assoc-ref inputs "bash")
out
out)))
(chmod file #o555))))))))
(let ((out (assoc-ref outputs "out")))
(for-each
(lambda (spec)
(wrap-program (string-append out spec)
`("npm_package_config_node_gyp_nodedir" = (,out))))
'("/bin/npm"
"/bin/npx")))))))))
(native-inputs
(list ;; Runtime dependencies for binaries used as a bootstrap.
c-ares-for-node-lts
@@ -974,7 +962,8 @@ fi"
pkg-config
procps
python
util-linux))
util-linux
gcc-14))
(inputs
(list bash-minimal
coreutils
@@ -987,7 +976,8 @@ fi"
nghttp3
`(,nghttp2 "lib")
openssl
zlib))
zlib
`(,zstd-1.5.7 "lib")))
(supported-systems
(cons "riscv64-linux" (package-supported-systems node-bootstrap)))
(properties (alist-delete 'hidden? (package-properties node-bootstrap)))))
@@ -1003,6 +993,6 @@ fi"
`(cons* "--shared" "--without-npm" ,flags))
((#:phases phases '%standard-phases)
`(modify-phases ,phases
(delete 'install-npmrc)
(delete 'fix-node-gyp-reference)
(delete 'patch-nested-shebangs)
(delete 'ignore-number-of-hardlinks)))))))

View File

@@ -116,7 +116,7 @@ knowledge of the Z-Wave protocol.")
(lambda _
(substitute* "binding.gyp"
(("std=c\\+\\+11")
"std=c++17"))))
"std=c++20"))))
(replace 'build
;; For some reason, `npm install` doesn't build
;; the addon automatically, so we do it explicitly here.

View File

@@ -30,10 +30,16 @@
#:use-module (guix search-paths)
#:use-module (guix build-system)
#:use-module (guix build-system gnu)
#:export (%node-build-system-modules
#:export (%default-lockfiles
%node-build-system-modules
node-build
node-build-system))
(define %default-lockfiles
(list "package-lock.json"
"yarn.lock"
"npm-shrinkwrap.json"))
(define %node-build-system-modules
;; Build-side modules imported by default.
`((guix build node-build-system)
@@ -47,6 +53,10 @@
"Return the default Node package, resolved lazily."
(@* (gnu packages node) node-lts))
(define (default-guile-json)
"Return the default guile-json package, resolved lazily."
(@* (gnu packages guile) guile-json-4))
(define* (lower name
#:key source inputs native-inputs outputs system target
(node (default-node))
@@ -78,17 +88,12 @@
(build node-build)
(arguments (strip-keyword-arguments private-keywords arguments)))))
(define (default-guile-json)
"Return the default guile-json package."
;; Lazily resolve the binding to avoid a circular dependency.
(let ((mod (resolve-interface '(gnu packages guile))))
(module-ref mod 'guile-json-4)))
(define* (node-build name inputs
#:key
source
(npm-flags ''())
(test-target "test")
(lockfiles %default-lockfiles)
(tests? #t)
(phases '%standard-phases)
(outputs '("out"))
@@ -110,6 +115,7 @@
#:system #$system
#:npm-flags #$npm-flags
#:test-target #$test-target
#:lockfiles '#$lockfiles
#:tests? #$tests?
#:phases #$phases
#:outputs #$(outputs->gexp outputs)

View File

@@ -105,6 +105,7 @@
source
(phases '%standard-phases)
(grammar-directories '("."))
(lockfiles %default-lockfiles)
(tests? #t)
(outputs '("out" "js"))
(search-paths '())
@@ -123,6 +124,7 @@
#:source #+source
#:system #$system
#:phases #$phases
#:lockfiles '#$lockfiles
#:tests? #$tests?
#:grammar-directories '#$grammar-directories
#:outputs #$(outputs->gexp outputs)
@@ -145,6 +147,7 @@
guile source
(phases '%standard-phases)
(grammar-directories '("."))
(lockfiles %default-lockfiles)
(tests? #t)
(outputs '("out" "js"))
(search-paths '())
@@ -179,6 +182,7 @@
#:build #$build
#:target #$target
#:phases #$phases
#:lockfiles '#$lockfiles
#:tests? #$tests?
#:grammar-directories '#$grammar-directories
#:outputs #$(outputs->gexp outputs)

View File

@@ -5,6 +5,7 @@
;;; Copyright © 2021, 2022 Philip McGrath <philip@philipmcgrath.com>
;;; Copyright © 2022 Liliana Marie Prikler <liliana.prikler@gmail.com>
;;; Copyright © 2024 Daniel Khodabakhsh <d.khodabakhsh@gmail.com>
;;; Copyright © 2025 Nicolas Graves <ngraves@ngraves.fr>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -29,6 +30,7 @@
#:use-module (ice-9 match)
#:use-module (json)
#:use-module (srfi srfi-1)
#:use-module (srfi srfi-26)
#:use-module (srfi srfi-71)
#:export (%standard-phases
delete-dependencies
@@ -40,34 +42,6 @@
replace-fields
with-atomic-json-file-replacement))
(define* (assoc-ref* alist key #:optional default)
"Like assoc-ref, but return DEFAULT instead of #f if no value exists."
(match (assoc key alist)
(#f default)
((_ . value) value)))
(define* (alist-pop alist key #:optional (= equal?))
"Return two values, the first pair in ALIST with key KEY, and the other
elements. Equality calls are made as (= KEY ALISTCAR)."
(define (found? pair)
(= key (car pair)))
(let ((before after (break found? alist)))
(if (pair? after)
(values (car after) (append before (cdr after)))
(values #f before))))
(define* (alist-update alist key proc #:optional (= equal?))
"Return an association list like ALIST, but with KEY mapped to the result of
PROC applied to the first value found under the comparison (= KEY ALISTCAR).
If no such value exists, return the list unchanged.
Unlike acons, this removes the previous association of KEY (assuming it is
unique), but the result may still share storage with ALIST."
(let ((pair rest (alist-pop alist key =)))
(if (pair? pair)
(acons key (proc (cdr pair)) rest)
alist)))
;;;
;;; package.json modification procedures
;;;
@@ -106,23 +80,19 @@ listed in 'dependencies-to-remove', a list of strings naming npm packages.
To prevent the deleted dependencies from being reintroduced, use this function
only after the 'patch-dependencies' phase."
(lambda (pkg-meta)
(fold
(lambda (dependency-key pkg-meta)
(alist-update
pkg-meta
dependency-key
(lambda (dependencies)
(remove
(lambda (dependency)
(member (car dependency) dependencies-to-remove))
dependencies))))
pkg-meta
(list
"devDependencies"
"dependencies"
"peerDependencies"
"optionalDependencies"))))
(let ((predicate (lambda (dependency)
(member (car dependency) dependencies-to-remove)))
(dependency? (cut member <> (list "devDependencies"
"dependencies"
"peerDependencies"
"optionalDependencies"))))
(lambda (pkg-meta)
(map (match-lambda
(((? dependency? key) . dependencies)
(cons key (remove predicate dependencies)))
(otherwise
otherwise))
pkg-meta))))
(define* (modify-json-fields
fields
@@ -236,8 +206,7 @@ only after the 'patch-dependencies' phase."
(begin
(mkdir dir)
(setenv "HOME" (string-append (getcwd) "/" dir))
(format #t "set HOME to ~s~%" (getenv "HOME")))))))
#t)
(format #t "set HOME to ~s~%" (getenv "HOME"))))))))
(define (module-name module)
(let* ((package.json (string-append module "/package.json"))
@@ -257,67 +226,65 @@ only after the 'patch-dependencies' phase."
(for-each (lambda (dir)
(let ((nm (string-append dir "/lib/node_modules")))
(for-each (lambda (module)
(hash-set! index (module-name module) module))
(hash-set! index (module-name module)
(string-append "file://" module)))
(list-modules nm))))
input-paths)
index))
(define* (patch-dependencies #:key inputs #:allow-other-keys)
"Replace versions by paths when found among INPUTS in `package.json'."
(define index (index-modules (map cdr inputs)))
(define resolve-dependencies
(let ((index (index-modules (map cdr inputs))))
(cut map
(match-lambda
((dependency . version)
(cons dependency (hash-ref index dependency version))))
<>)))
(define (resolve-dependencies dependencies)
(map
(match-lambda
((dependency . version)
(cons dependency (hash-ref index dependency version))))
dependencies))
(with-atomic-json-file-replacement
(define (resolve key getter)
(lambda (pkg-meta)
(fold
(lambda (proc pkg-meta) (proc pkg-meta))
pkg-meta
(list
(lambda (pkg-meta)
(alist-update pkg-meta "devDependencies" resolve-dependencies))
(lambda (pkg-meta)
(assoc-set!
pkg-meta
"dependencies"
(resolve-dependencies
; Combined "peerDependencies" and "dependencies" dependencies
; with "dependencies" taking precedent.
(fold
(lambda (dependency dependencies)
(assoc-set! dependencies (car dependency) (cdr dependency)))
(assoc-ref* pkg-meta "peerDependencies" '())
(assoc-ref* pkg-meta "dependencies" '())))))))))
#t)
(assoc-set! pkg-meta key
(resolve-dependencies (getter pkg-meta)))))
(define* (delete-lockfiles #:key inputs #:allow-other-keys)
"Delete 'package-lock.json', 'yarn.lock', and 'npm-shrinkwrap.json', if they
exist."
(modify-json
(resolve "devDependencies"
(lambda (pkg-meta)
(or (assoc-ref pkg-meta "devDependencies") '())))
(resolve "dependencies"
;; Combined "peerDependencies" and "dependencies" dependencies
;; with "dependencies" taking precedent.
(lambda (pkg-meta)
(fold
(lambda (dependency dependencies)
(assoc-set! dependencies
(car dependency) (cdr dependency)))
(or (assoc-ref pkg-meta "peerDependencies") '())
(or (assoc-ref pkg-meta "dependencies") '()))))))
(define* (delete-lockfiles #:key lockfiles #:allow-other-keys)
"Delete LOCKFILES if they exist."
(for-each (lambda (pth)
(when (file-exists? pth)
(delete-file pth)))
'("package-lock.json"
"yarn.lock"
"npm-shrinkwrap.json"))
#t)
lockfiles))
(define* (configure #:key outputs inputs #:allow-other-keys)
(define* (configure #:key inputs #:allow-other-keys)
(let ((npm (string-append (assoc-ref inputs "node") "/bin/npm")))
(invoke npm "--offline" "--ignore-scripts" "--install-links" "install")
#t))
(invoke npm "--offline"
"--ignore-scripts"
"--install-links"
"--no-audit"
"install")))
(define* (build #:key inputs #:allow-other-keys)
(let ((package-meta (call-with-input-file "package.json" json->scm)))
(if (assoc-ref* (assoc-ref* package-meta "scripts" '()) "build" #f)
(let* ((package-meta (call-with-input-file "package.json" json->scm))
(scripts (assoc-ref package-meta "scripts")))
(if (and 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))
(format #t "there is no build script to run~%"))))
(define* (check #:key tests? inputs test-target #:allow-other-keys)
"Run 'npm run TEST-TARGET' if TESTS?"
@@ -334,8 +301,7 @@ exist."
"--owner=0"
"--group=0"
"--numeric-owner"
"-czf" "../package.tgz" ".")
#t)
"-czf" "../package.tgz" "."))
(define* (install #:key outputs inputs #:allow-other-keys)
"Install the node module to the output store item."
@@ -347,8 +313,7 @@ exist."
"--loglevel" "info"
"--production"
"--install-links"
"install" "../package.tgz")
#t))
"install" "../package.tgz")))
(define* (avoid-node-gyp-rebuild #:key outputs #:allow-other-keys)
"Adjust the installed 'package.json' to remove an 'install' script that
@@ -376,28 +341,25 @@ would try to run 'node-gyp rebuild'."
;; For further details, see:
;; - https://docs.npmjs.com/cli/v8/configuring-npm/package-json#default-values
;; - https://docs.npmjs.com/cli/v8/using-npm/scripts#best-practices
(define installed-package.json
(search-input-file outputs (string-append "/lib/node_modules/"
(module-name ".")
"/package.json")))
;; We don't want to use an atomic replacement here, because we often don't
;; even need to overwrite this file. Therefore, let's use some helpers
;; that we'd otherwise not need.
(define pkg-meta
(call-with-input-file installed-package.json json->scm))
(define scripts
(assoc-ref* pkg-meta "scripts" '()))
(when (equal? "node-gyp rebuild" (assoc-ref* scripts "install" #f))
(call-with-output-file installed-package.json
(lambda (out)
(scm->json
(assoc-set! pkg-meta
"scripts"
(assoc-set! scripts
"install"
"echo Guix: avoiding node-gyp rebuild"))
out)))))
(let* ((installed-package.json
(search-input-file outputs (string-append "/lib/node_modules/"
(module-name ".")
"/package.json")))
;; We don't want to use an atomic replacement here, because we often
;; don't even need to overwrite this file. Therefore, let's use some
;; helpers that we'd otherwise not need.
(pkg-meta (call-with-input-file installed-package.json json->scm))
(scripts (or (assoc-ref pkg-meta "scripts") '())))
(when (equal? "node-gyp rebuild" (assoc-ref scripts "install"))
(call-with-output-file installed-package.json
(lambda (out)
(scm->json
(assoc-set! pkg-meta
"scripts"
(assoc-set! scripts
"install"
"echo Guix: avoiding node-gyp rebuild"))
out))))))
(define %standard-phases
(modify-phases gnu:%standard-phases