forked from tribes/guix
Compare commits
37 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 1cd09ce1ec | |||
| 4b7a750b64 | |||
| 5d1c8cfa1e | |||
| a4a3fe08c1 | |||
| e095512494 | |||
| 4a1f2852e1 | |||
| 649fc872ba | |||
| 6199e6609c | |||
| ec6b8c9808 | |||
| 429f698c17 | |||
| efa499747f | |||
| c81f5b764c | |||
| 3298ea0db1 | |||
| db6af3ab1a | |||
| 0987ec2b82 | |||
| 709c37f4db | |||
| ce843095f4 | |||
| 2487ff1879 | |||
| 71ef5c0ab6 | |||
| 4b4ea6eb9d | |||
| 65c24e5e11 | |||
| 07085345a2 | |||
| 98b2e3853b | |||
| 0e6f3fab58 | |||
| d4ddddd9b4 | |||
| ca11af32e2 | |||
| 40e40dafc4 | |||
| 2533fec0e1 | |||
| 462dc862b0 | |||
| abd6fc6d49 | |||
| 7c7c4ba6f5 | |||
| 7b8101940c | |||
| 9d3d936e2f | |||
| dd5c11de2b | |||
| 9247fd3bc7 | |||
| 721e60ef98 | |||
| 4f9a5a1a02 |
@@ -8760,7 +8760,7 @@ similar rank-based tests for equal probability distributions due to Neuhauser
|
|||||||
(("^PKG_LIBS=.*")
|
(("^PKG_LIBS=.*")
|
||||||
(string-append "PKG_LIBS="
|
(string-append "PKG_LIBS="
|
||||||
(assoc-ref inputs "libnode")
|
(assoc-ref inputs "libnode")
|
||||||
"/lib/libnode.so.127\n")))
|
"/lib/libnode.so.137\n")))
|
||||||
(setenv "INCLUDE_DIR"
|
(setenv "INCLUDE_DIR"
|
||||||
(string-append
|
(string-append
|
||||||
(assoc-ref inputs "libnode")
|
(assoc-ref inputs "libnode")
|
||||||
|
|||||||
@@ -164,14 +164,14 @@ resolution, asynchronous file system operations, and threading primitives.")
|
|||||||
(package
|
(package
|
||||||
(inherit libuv)
|
(inherit libuv)
|
||||||
(name "libuv")
|
(name "libuv")
|
||||||
(version "1.49.2")
|
(version "1.51.0")
|
||||||
(source (origin
|
(source (origin
|
||||||
(method url-fetch)
|
(method url-fetch)
|
||||||
(uri (string-append "https://dist.libuv.org/dist/v" version
|
(uri (string-append "https://dist.libuv.org/dist/v" version
|
||||||
"/libuv-v" version ".tar.gz"))
|
"/libuv-v" version ".tar.gz"))
|
||||||
(sha256
|
(sha256
|
||||||
(base32
|
(base32
|
||||||
"1a75p8wp4l43y2ffj1szs1ssm6nzjad7k51bqi2r04ngs9mp044c"))))
|
"1szqivvs7izbhw1a3nd1ipbk012yvqqkjg0sjmqxw1hi1fwmf1az"))))
|
||||||
(properties '((hidden? . #t)))))
|
(properties '((hidden? . #t)))))
|
||||||
|
|
||||||
(define-public libuv-for-r-httpuv
|
(define-public libuv-for-r-httpuv
|
||||||
|
|||||||
@@ -2324,7 +2324,7 @@ a string consisting of a number and a time unit is converted to milliseconds.")
|
|||||||
(define-public node-nan
|
(define-public node-nan
|
||||||
(package
|
(package
|
||||||
(name "node-nan")
|
(name "node-nan")
|
||||||
(version "2.22.0")
|
(version "2.26.2")
|
||||||
(source
|
(source
|
||||||
(origin
|
(origin
|
||||||
(method git-fetch)
|
(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))))
|
(commit (string-append "v" version))))
|
||||||
(file-name (git-file-name name version))
|
(file-name (git-file-name name version))
|
||||||
(sha256
|
(sha256
|
||||||
(base32 "02gqm23x26glffvyxrnk610hy3hg0kwh2v58dhnb032l0jhjzqvp"))))
|
(base32 "18xv0m40jgy3sc4pldw95w6p72ms5a5h0x2sm2mimlwlmxmrjlmb"))))
|
||||||
(build-system node-build-system)
|
(build-system node-build-system)
|
||||||
(arguments
|
(arguments
|
||||||
`(#:phases
|
`(#:phases
|
||||||
|
|||||||
+48
-58
@@ -274,7 +274,7 @@
|
|||||||
(lambda (file stat)
|
(lambda (file stat)
|
||||||
(executable-file? file))
|
(executable-file? file))
|
||||||
#:stat lstat)))))
|
#:stat lstat)))))
|
||||||
(add-after 'install 'install-npmrc
|
(add-after 'install 'fix-node-gyp-reference
|
||||||
;; Note: programs like node-gyp only receive these values if
|
;; Note: programs like node-gyp only receive these values if
|
||||||
;; they are started via `npm` or `npx`.
|
;; they are started via `npm` or `npx`.
|
||||||
;; See: https://github.com/nodejs/node-gyp#npm-configuration
|
;; See: https://github.com/nodejs/node-gyp#npm-configuration
|
||||||
@@ -482,7 +482,7 @@ Node.js and web browsers.")
|
|||||||
(origin
|
(origin
|
||||||
(method git-fetch)
|
(method git-fetch)
|
||||||
(uri (git-reference
|
(uri (git-reference
|
||||||
(url "https://github.com/indutny/llparse-builder.git")
|
(url "https://github.com/nodejs/llparse-builder.git")
|
||||||
(commit (string-append "v" version))))
|
(commit (string-append "v" version))))
|
||||||
(file-name (git-file-name name version))
|
(file-name (git-file-name name version))
|
||||||
(sha256
|
(sha256
|
||||||
@@ -491,10 +491,6 @@ Node.js and web browsers.")
|
|||||||
(modules '((guix build utils)))
|
(modules '((guix build utils)))
|
||||||
(snippet
|
(snippet
|
||||||
'(begin
|
'(begin
|
||||||
;; FIXME: Unneeded runtime dependency.
|
|
||||||
;; https://github.com/indutny/llparse-builder/pull/2
|
|
||||||
(substitute* "package.json"
|
|
||||||
(("\"@types/debug.*,") ""))
|
|
||||||
;; Fix imports for esbuild.
|
;; Fix imports for esbuild.
|
||||||
;; https://github.com/evanw/esbuild/issues/477
|
;; https://github.com/evanw/esbuild/issues/477
|
||||||
(substitute* '("src/node/invoke.ts"
|
(substitute* '("src/node/invoke.ts"
|
||||||
@@ -521,7 +517,8 @@ Node.js and web browsers.")
|
|||||||
(add-after 'patch-dependencies 'delete-dependencies
|
(add-after 'patch-dependencies 'delete-dependencies
|
||||||
(lambda _
|
(lambda _
|
||||||
(modify-json (delete-dependencies
|
(modify-json (delete-dependencies
|
||||||
`("@types/mocha"
|
`("@types/debug"
|
||||||
|
"@types/mocha"
|
||||||
"@types/node"
|
"@types/node"
|
||||||
"mocha"
|
"mocha"
|
||||||
"ts-node"
|
"ts-node"
|
||||||
@@ -539,7 +536,7 @@ Node.js and web browsers.")
|
|||||||
(list node-binary-search-bootstrap node-debug-bootstrap))
|
(list node-binary-search-bootstrap node-debug-bootstrap))
|
||||||
(native-inputs
|
(native-inputs
|
||||||
(list esbuild))
|
(list esbuild))
|
||||||
(home-page "https://github.com/indutny/llparse-builder#readme")
|
(home-page "https://github.com/nodejs/llparse-builder#readme")
|
||||||
(properties '((hidden? . #t)))
|
(properties '((hidden? . #t)))
|
||||||
(synopsis "Graph builder for consumption by llparse")
|
(synopsis "Graph builder for consumption by llparse")
|
||||||
(description "This package builds graphs for consumption by llparse.")
|
(description "This package builds graphs for consumption by llparse.")
|
||||||
@@ -553,7 +550,7 @@ Node.js and web browsers.")
|
|||||||
(origin
|
(origin
|
||||||
(method git-fetch)
|
(method git-fetch)
|
||||||
(uri (git-reference
|
(uri (git-reference
|
||||||
(url "https://github.com/indutny/llparse-frontend.git")
|
(url "https://github.com/nodejs/llparse-frontend.git")
|
||||||
(commit (string-append "v" version))))
|
(commit (string-append "v" version))))
|
||||||
(file-name (git-file-name name version))
|
(file-name (git-file-name name version))
|
||||||
(sha256
|
(sha256
|
||||||
@@ -602,7 +599,7 @@ Node.js and web browsers.")
|
|||||||
(list node-debug-bootstrap node-llparse-builder-bootstrap))
|
(list node-debug-bootstrap node-llparse-builder-bootstrap))
|
||||||
(native-inputs
|
(native-inputs
|
||||||
(list esbuild))
|
(list esbuild))
|
||||||
(home-page "https://github.com/indutny/llparse-frontend#readme")
|
(home-page "https://github.com/nodejs/llparse-frontend#readme")
|
||||||
(properties '((hidden? . #t)))
|
(properties '((hidden? . #t)))
|
||||||
(synopsis "Frontend for the llparse compiler")
|
(synopsis "Frontend for the llparse compiler")
|
||||||
(description "This package is a 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
|
(define-public node-llparse-bootstrap
|
||||||
(package
|
(package
|
||||||
(name "node-llparse")
|
(name "node-llparse")
|
||||||
(version "7.1.0")
|
(version "7.3.0")
|
||||||
(source
|
(source
|
||||||
(origin
|
(origin
|
||||||
(method git-fetch)
|
(method git-fetch)
|
||||||
(uri (git-reference
|
(uri (git-reference
|
||||||
(url "https://github.com/indutny/llparse.git")
|
(url "https://github.com/nodejs/llparse.git")
|
||||||
(commit (string-append "v" version))))
|
(commit (string-append "v" version))))
|
||||||
(file-name (git-file-name name version))
|
(file-name (git-file-name name version))
|
||||||
(sha256
|
(sha256
|
||||||
(base32
|
(base32
|
||||||
"10da273iy2if88hp79cwms6c8qpsl1fkgzll6gmqyx5yxv5mkyp6"))
|
"09hqjcynkz5iv7aydzdwgs42r7y2zylplv0ff7w0vkdsgb08j22a"))
|
||||||
(modules '((guix build utils)))
|
(modules '((guix build utils)))
|
||||||
(snippet
|
(snippet
|
||||||
'(begin
|
'(begin
|
||||||
@@ -645,10 +642,14 @@ Node.js and web browsers.")
|
|||||||
(add-after 'patch-dependencies 'delete-dependencies
|
(add-after 'patch-dependencies 'delete-dependencies
|
||||||
(lambda args
|
(lambda args
|
||||||
(modify-json (delete-dependencies
|
(modify-json (delete-dependencies
|
||||||
`("@types/debug"
|
`("@stylistic/eslint-plugin"
|
||||||
|
"@typescript-eslint/eslint-plugin"
|
||||||
|
"@typescript-eslint/parser"
|
||||||
|
"@types/debug"
|
||||||
"@types/mocha"
|
"@types/mocha"
|
||||||
"@types/node"
|
"@types/node"
|
||||||
"esm"
|
"esm"
|
||||||
|
"eslint"
|
||||||
"llparse-test-fixture"
|
"llparse-test-fixture"
|
||||||
"mocha"
|
"mocha"
|
||||||
"ts-node"
|
"ts-node"
|
||||||
@@ -676,7 +677,7 @@ parser definition into a C output.")
|
|||||||
(define-public llhttp-bootstrap
|
(define-public llhttp-bootstrap
|
||||||
(package
|
(package
|
||||||
(name "llhttp")
|
(name "llhttp")
|
||||||
(version "9.2.1")
|
(version "9.3.0")
|
||||||
(source (origin
|
(source (origin
|
||||||
(method git-fetch)
|
(method git-fetch)
|
||||||
(uri (git-reference
|
(uri (git-reference
|
||||||
@@ -685,7 +686,7 @@ parser definition into a C output.")
|
|||||||
(file-name (git-file-name name version))
|
(file-name (git-file-name name version))
|
||||||
(sha256
|
(sha256
|
||||||
(base32
|
(base32
|
||||||
"0mzg19aqb1am498gms0z75cwd5kmfg9p78b1hhxw67019nsjcbac"))
|
"0yz4ys94pjq2fs2pihpqjvmxj2mbpm8k5prlm445z4qlajzlr4kb"))
|
||||||
(patches (search-patches "llhttp-ponyfill-object-fromentries.patch"))
|
(patches (search-patches "llhttp-ponyfill-object-fromentries.patch"))
|
||||||
(modules '((guix build utils)))
|
(modules '((guix build utils)))
|
||||||
(snippet
|
(snippet
|
||||||
@@ -747,14 +748,14 @@ source files.")
|
|||||||
(define-public node-lts
|
(define-public node-lts
|
||||||
(package
|
(package
|
||||||
(inherit node-bootstrap)
|
(inherit node-bootstrap)
|
||||||
(version "22.14.0")
|
(version "24.14.1")
|
||||||
(source (origin
|
(source (origin
|
||||||
(method url-fetch)
|
(method url-fetch)
|
||||||
(uri (string-append "https://nodejs.org/dist/v" version
|
(uri (string-append "https://nodejs.org/dist/v" version
|
||||||
"/node-v" version ".tar.gz"))
|
"/node-v" version ".tar.gz"))
|
||||||
(sha256
|
(sha256
|
||||||
(base32
|
(base32
|
||||||
"12msprh604s6qdsgwymxw4kl8ivaldbaydf4v37lbp02aznk2kkc"))
|
"1cri5lp3a9jhh34dbd48hq2zyb7xjb9qs6zl36l3q2blawgwz642"))
|
||||||
(modules '((guix build utils)))
|
(modules '((guix build utils)))
|
||||||
(snippet
|
(snippet
|
||||||
'(begin
|
'(begin
|
||||||
@@ -770,13 +771,17 @@ source files.")
|
|||||||
"deps/icu-small"
|
"deps/icu-small"
|
||||||
"deps/nghttp2"
|
"deps/nghttp2"
|
||||||
"deps/ngtcp2"
|
"deps/ngtcp2"
|
||||||
|
"deps/llhttp"
|
||||||
"deps/uv"
|
"deps/uv"
|
||||||
"deps/zlib"))))))
|
"deps/zlib"
|
||||||
|
"deps/zstd"))))))
|
||||||
(arguments
|
(arguments
|
||||||
(substitute-keyword-arguments arguments
|
(substitute-keyword-arguments arguments
|
||||||
((#:configure-flags configure-flags)
|
((#:configure-flags configure-flags)
|
||||||
''("--shared-cares"
|
''("--shared-cares"
|
||||||
"--shared-libuv"
|
"--shared-libuv"
|
||||||
|
"--shared-http-parser"
|
||||||
|
"--shared-http-parser-libname=llhttp"
|
||||||
"--shared-nghttp2"
|
"--shared-nghttp2"
|
||||||
"--shared-openssl"
|
"--shared-openssl"
|
||||||
"--shared-zlib"
|
"--shared-zlib"
|
||||||
@@ -784,6 +789,7 @@ source files.")
|
|||||||
"--with-intl=system-icu"
|
"--with-intl=system-icu"
|
||||||
"--shared-ngtcp2"
|
"--shared-ngtcp2"
|
||||||
"--shared-nghttp3"
|
"--shared-nghttp3"
|
||||||
|
"--shared-zstd"
|
||||||
;;Needed for correct snapshot checksums
|
;;Needed for correct snapshot checksums
|
||||||
"--v8-enable-snapshot-compression"))
|
"--v8-enable-snapshot-compression"))
|
||||||
((#:phases phases)
|
((#:phases phases)
|
||||||
@@ -846,9 +852,11 @@ source files.")
|
|||||||
(for-each delete-file
|
(for-each delete-file
|
||||||
'("test/parallel/test-https-agent-unref-socket.js"))
|
'("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.
|
;; 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:
|
;; FIXME: This test fails randomly:
|
||||||
;; https://github.com/nodejs/node/issues/31213
|
;; https://github.com/nodejs/node/issues/31213
|
||||||
@@ -899,18 +907,6 @@ source files.")
|
|||||||
"test/parallel/test-http2-invalid-last-stream-id.js")
|
"test/parallel/test-http2-invalid-last-stream-id.js")
|
||||||
(("client\\.connect\\(address\\)")
|
(("client\\.connect\\(address\\)")
|
||||||
"client.connect(address.port)"))))
|
"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
|
;; npm installs dependencies by copying their files over a tar
|
||||||
;; stream. A file with more than one hardlink is marked as a
|
;; stream. A file with more than one hardlink is marked as a
|
||||||
;; "Link". pacote/lib/fetcher.js calls node-tar's extractor with 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
|
;; https://github.com/npm/pacote/issues/285
|
||||||
(add-after 'install 'ignore-number-of-hardlinks
|
(add-after 'install 'ignore-number-of-hardlinks
|
||||||
(lambda* (#:key outputs #:allow-other-keys)
|
(lambda* (#:key outputs #:allow-other-keys)
|
||||||
(let ((file (string-append (assoc-ref outputs "out")
|
(let ((dir (string-append (assoc-ref outputs "out")
|
||||||
"/lib/node_modules/npm/node_modules"
|
"/lib/node_modules/npm/node_modules"
|
||||||
"/tar/lib/write-entry.js")))
|
"/tar/dist")))
|
||||||
(substitute* file
|
(substitute*
|
||||||
|
(list (string-append dir "/esm/write-entry.js")
|
||||||
|
(string-append dir "/commonjs/write-entry.js"))
|
||||||
(("this.stat.nlink > 1") "false")))))
|
(("this.stat.nlink > 1") "false")))))
|
||||||
(add-after 'install 'install-node-gyp-wrapper
|
(replace 'fix-node-gyp-reference
|
||||||
(lambda* (#:key inputs outputs #:allow-other-keys)
|
(lambda* (#:key inputs outputs #:allow-other-keys)
|
||||||
(let* ((out (assoc-ref outputs "out"))
|
(let ((out (assoc-ref outputs "out")))
|
||||||
(dir (string-append out "/lib/node_modules/npm/bin/node-gyp-bin"))
|
(for-each
|
||||||
(file (string-append dir "/node-gyp")))
|
(lambda (spec)
|
||||||
(mkdir-p dir)
|
(wrap-program (string-append out spec)
|
||||||
;; See https://github.com/npm/cli/issues/6842
|
`("npm_package_config_node_gyp_nodedir" = (,out))))
|
||||||
(call-with-output-file file
|
'("/bin/npm"
|
||||||
(lambda (port)
|
"/bin/npx")))))))))
|
||||||
(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))))))))
|
|
||||||
(native-inputs
|
(native-inputs
|
||||||
(list ;; Runtime dependencies for binaries used as a bootstrap.
|
(list ;; Runtime dependencies for binaries used as a bootstrap.
|
||||||
c-ares-for-node-lts
|
c-ares-for-node-lts
|
||||||
@@ -974,7 +962,8 @@ fi"
|
|||||||
pkg-config
|
pkg-config
|
||||||
procps
|
procps
|
||||||
python
|
python
|
||||||
util-linux))
|
util-linux
|
||||||
|
gcc-14))
|
||||||
(inputs
|
(inputs
|
||||||
(list bash-minimal
|
(list bash-minimal
|
||||||
coreutils
|
coreutils
|
||||||
@@ -987,7 +976,8 @@ fi"
|
|||||||
nghttp3
|
nghttp3
|
||||||
`(,nghttp2 "lib")
|
`(,nghttp2 "lib")
|
||||||
openssl
|
openssl
|
||||||
zlib))
|
zlib
|
||||||
|
`(,zstd-1.5.7 "lib")))
|
||||||
(supported-systems
|
(supported-systems
|
||||||
(cons "riscv64-linux" (package-supported-systems node-bootstrap)))
|
(cons "riscv64-linux" (package-supported-systems node-bootstrap)))
|
||||||
(properties (alist-delete 'hidden? (package-properties node-bootstrap)))))
|
(properties (alist-delete 'hidden? (package-properties node-bootstrap)))))
|
||||||
@@ -1003,6 +993,6 @@ fi"
|
|||||||
`(cons* "--shared" "--without-npm" ,flags))
|
`(cons* "--shared" "--without-npm" ,flags))
|
||||||
((#:phases phases '%standard-phases)
|
((#:phases phases '%standard-phases)
|
||||||
`(modify-phases ,phases
|
`(modify-phases ,phases
|
||||||
(delete 'install-npmrc)
|
(delete 'fix-node-gyp-reference)
|
||||||
(delete 'patch-nested-shebangs)
|
(delete 'patch-nested-shebangs)
|
||||||
(delete 'ignore-number-of-hardlinks)))))))
|
(delete 'ignore-number-of-hardlinks)))))))
|
||||||
|
|||||||
@@ -116,7 +116,7 @@ knowledge of the Z-Wave protocol.")
|
|||||||
(lambda _
|
(lambda _
|
||||||
(substitute* "binding.gyp"
|
(substitute* "binding.gyp"
|
||||||
(("std=c\\+\\+11")
|
(("std=c\\+\\+11")
|
||||||
"std=c++17"))))
|
"std=c++20"))))
|
||||||
(replace 'build
|
(replace 'build
|
||||||
;; For some reason, `npm install` doesn't build
|
;; For some reason, `npm install` doesn't build
|
||||||
;; the addon automatically, so we do it explicitly here.
|
;; the addon automatically, so we do it explicitly here.
|
||||||
|
|||||||
@@ -30,10 +30,16 @@
|
|||||||
#:use-module (guix search-paths)
|
#:use-module (guix search-paths)
|
||||||
#:use-module (guix build-system)
|
#:use-module (guix build-system)
|
||||||
#:use-module (guix build-system gnu)
|
#:use-module (guix build-system gnu)
|
||||||
#:export (%node-build-system-modules
|
#:export (%default-lockfiles
|
||||||
|
%node-build-system-modules
|
||||||
node-build
|
node-build
|
||||||
node-build-system))
|
node-build-system))
|
||||||
|
|
||||||
|
(define %default-lockfiles
|
||||||
|
(list "package-lock.json"
|
||||||
|
"yarn.lock"
|
||||||
|
"npm-shrinkwrap.json"))
|
||||||
|
|
||||||
(define %node-build-system-modules
|
(define %node-build-system-modules
|
||||||
;; Build-side modules imported by default.
|
;; Build-side modules imported by default.
|
||||||
`((guix build node-build-system)
|
`((guix build node-build-system)
|
||||||
@@ -47,6 +53,10 @@
|
|||||||
"Return the default Node package, resolved lazily."
|
"Return the default Node package, resolved lazily."
|
||||||
(@* (gnu packages node) node-lts))
|
(@* (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
|
(define* (lower name
|
||||||
#:key source inputs native-inputs outputs system target
|
#:key source inputs native-inputs outputs system target
|
||||||
(node (default-node))
|
(node (default-node))
|
||||||
@@ -78,17 +88,12 @@
|
|||||||
(build node-build)
|
(build node-build)
|
||||||
(arguments (strip-keyword-arguments private-keywords arguments)))))
|
(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
|
(define* (node-build name inputs
|
||||||
#:key
|
#:key
|
||||||
source
|
source
|
||||||
(npm-flags ''())
|
(npm-flags ''())
|
||||||
(test-target "test")
|
(test-target "test")
|
||||||
|
(lockfiles %default-lockfiles)
|
||||||
(tests? #t)
|
(tests? #t)
|
||||||
(phases '%standard-phases)
|
(phases '%standard-phases)
|
||||||
(outputs '("out"))
|
(outputs '("out"))
|
||||||
@@ -110,6 +115,7 @@
|
|||||||
#:system #$system
|
#:system #$system
|
||||||
#:npm-flags #$npm-flags
|
#:npm-flags #$npm-flags
|
||||||
#:test-target #$test-target
|
#:test-target #$test-target
|
||||||
|
#:lockfiles '#$lockfiles
|
||||||
#:tests? #$tests?
|
#:tests? #$tests?
|
||||||
#:phases #$phases
|
#:phases #$phases
|
||||||
#:outputs #$(outputs->gexp outputs)
|
#:outputs #$(outputs->gexp outputs)
|
||||||
|
|||||||
@@ -105,6 +105,7 @@
|
|||||||
source
|
source
|
||||||
(phases '%standard-phases)
|
(phases '%standard-phases)
|
||||||
(grammar-directories '("."))
|
(grammar-directories '("."))
|
||||||
|
(lockfiles %default-lockfiles)
|
||||||
(tests? #t)
|
(tests? #t)
|
||||||
(outputs '("out" "js"))
|
(outputs '("out" "js"))
|
||||||
(search-paths '())
|
(search-paths '())
|
||||||
@@ -123,6 +124,7 @@
|
|||||||
#:source #+source
|
#:source #+source
|
||||||
#:system #$system
|
#:system #$system
|
||||||
#:phases #$phases
|
#:phases #$phases
|
||||||
|
#:lockfiles '#$lockfiles
|
||||||
#:tests? #$tests?
|
#:tests? #$tests?
|
||||||
#:grammar-directories '#$grammar-directories
|
#:grammar-directories '#$grammar-directories
|
||||||
#:outputs #$(outputs->gexp outputs)
|
#:outputs #$(outputs->gexp outputs)
|
||||||
@@ -145,6 +147,7 @@
|
|||||||
guile source
|
guile source
|
||||||
(phases '%standard-phases)
|
(phases '%standard-phases)
|
||||||
(grammar-directories '("."))
|
(grammar-directories '("."))
|
||||||
|
(lockfiles %default-lockfiles)
|
||||||
(tests? #t)
|
(tests? #t)
|
||||||
(outputs '("out" "js"))
|
(outputs '("out" "js"))
|
||||||
(search-paths '())
|
(search-paths '())
|
||||||
@@ -179,6 +182,7 @@
|
|||||||
#:build #$build
|
#:build #$build
|
||||||
#:target #$target
|
#:target #$target
|
||||||
#:phases #$phases
|
#:phases #$phases
|
||||||
|
#:lockfiles '#$lockfiles
|
||||||
#:tests? #$tests?
|
#:tests? #$tests?
|
||||||
#:grammar-directories '#$grammar-directories
|
#:grammar-directories '#$grammar-directories
|
||||||
#:outputs #$(outputs->gexp outputs)
|
#:outputs #$(outputs->gexp outputs)
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
;;; Copyright © 2021, 2022 Philip McGrath <philip@philipmcgrath.com>
|
;;; Copyright © 2021, 2022 Philip McGrath <philip@philipmcgrath.com>
|
||||||
;;; Copyright © 2022 Liliana Marie Prikler <liliana.prikler@gmail.com>
|
;;; Copyright © 2022 Liliana Marie Prikler <liliana.prikler@gmail.com>
|
||||||
;;; Copyright © 2024 Daniel Khodabakhsh <d.khodabakhsh@gmail.com>
|
;;; Copyright © 2024 Daniel Khodabakhsh <d.khodabakhsh@gmail.com>
|
||||||
|
;;; Copyright © 2025 Nicolas Graves <ngraves@ngraves.fr>
|
||||||
;;;
|
;;;
|
||||||
;;; This file is part of GNU Guix.
|
;;; This file is part of GNU Guix.
|
||||||
;;;
|
;;;
|
||||||
@@ -29,6 +30,7 @@
|
|||||||
#:use-module (ice-9 match)
|
#:use-module (ice-9 match)
|
||||||
#:use-module (json)
|
#:use-module (json)
|
||||||
#:use-module (srfi srfi-1)
|
#:use-module (srfi srfi-1)
|
||||||
|
#:use-module (srfi srfi-26)
|
||||||
#:use-module (srfi srfi-71)
|
#:use-module (srfi srfi-71)
|
||||||
#:export (%standard-phases
|
#:export (%standard-phases
|
||||||
delete-dependencies
|
delete-dependencies
|
||||||
@@ -40,34 +42,6 @@
|
|||||||
replace-fields
|
replace-fields
|
||||||
with-atomic-json-file-replacement))
|
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
|
;;; 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
|
To prevent the deleted dependencies from being reintroduced, use this function
|
||||||
only after the 'patch-dependencies' phase."
|
only after the 'patch-dependencies' phase."
|
||||||
(lambda (pkg-meta)
|
(let ((predicate (lambda (dependency)
|
||||||
(fold
|
(member (car dependency) dependencies-to-remove)))
|
||||||
(lambda (dependency-key pkg-meta)
|
(dependency? (cut member <> (list "devDependencies"
|
||||||
(alist-update
|
"dependencies"
|
||||||
pkg-meta
|
"peerDependencies"
|
||||||
dependency-key
|
"optionalDependencies"))))
|
||||||
(lambda (dependencies)
|
(lambda (pkg-meta)
|
||||||
(remove
|
(map (match-lambda
|
||||||
(lambda (dependency)
|
(((? dependency? key) . dependencies)
|
||||||
(member (car dependency) dependencies-to-remove))
|
(cons key (remove predicate dependencies)))
|
||||||
dependencies))))
|
(otherwise
|
||||||
pkg-meta
|
otherwise))
|
||||||
(list
|
pkg-meta))))
|
||||||
"devDependencies"
|
|
||||||
"dependencies"
|
|
||||||
"peerDependencies"
|
|
||||||
"optionalDependencies"))))
|
|
||||||
|
|
||||||
(define* (modify-json-fields
|
(define* (modify-json-fields
|
||||||
fields
|
fields
|
||||||
@@ -236,8 +206,7 @@ only after the 'patch-dependencies' phase."
|
|||||||
(begin
|
(begin
|
||||||
(mkdir dir)
|
(mkdir dir)
|
||||||
(setenv "HOME" (string-append (getcwd) "/" dir))
|
(setenv "HOME" (string-append (getcwd) "/" dir))
|
||||||
(format #t "set HOME to ~s~%" (getenv "HOME")))))))
|
(format #t "set HOME to ~s~%" (getenv "HOME"))))))))
|
||||||
#t)
|
|
||||||
|
|
||||||
(define (module-name module)
|
(define (module-name module)
|
||||||
(let* ((package.json (string-append module "/package.json"))
|
(let* ((package.json (string-append module "/package.json"))
|
||||||
@@ -257,67 +226,65 @@ only after the 'patch-dependencies' phase."
|
|||||||
(for-each (lambda (dir)
|
(for-each (lambda (dir)
|
||||||
(let ((nm (string-append dir "/lib/node_modules")))
|
(let ((nm (string-append dir "/lib/node_modules")))
|
||||||
(for-each (lambda (module)
|
(for-each (lambda (module)
|
||||||
(hash-set! index (module-name module) module))
|
(hash-set! index (module-name module)
|
||||||
|
(string-append "file://" module)))
|
||||||
(list-modules nm))))
|
(list-modules nm))))
|
||||||
input-paths)
|
input-paths)
|
||||||
index))
|
index))
|
||||||
|
|
||||||
(define* (patch-dependencies #:key inputs #:allow-other-keys)
|
(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)
|
(define (resolve key getter)
|
||||||
(map
|
|
||||||
(match-lambda
|
|
||||||
((dependency . version)
|
|
||||||
(cons dependency (hash-ref index dependency version))))
|
|
||||||
dependencies))
|
|
||||||
|
|
||||||
(with-atomic-json-file-replacement
|
|
||||||
(lambda (pkg-meta)
|
(lambda (pkg-meta)
|
||||||
(fold
|
(assoc-set! pkg-meta key
|
||||||
(lambda (proc pkg-meta) (proc pkg-meta))
|
(resolve-dependencies (getter 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)
|
|
||||||
|
|
||||||
(define* (delete-lockfiles #:key inputs #:allow-other-keys)
|
(modify-json
|
||||||
"Delete 'package-lock.json', 'yarn.lock', and 'npm-shrinkwrap.json', if they
|
(resolve "devDependencies"
|
||||||
exist."
|
(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)
|
(for-each (lambda (pth)
|
||||||
(when (file-exists? pth)
|
(when (file-exists? pth)
|
||||||
(delete-file pth)))
|
(delete-file pth)))
|
||||||
'("package-lock.json"
|
lockfiles))
|
||||||
"yarn.lock"
|
|
||||||
"npm-shrinkwrap.json"))
|
|
||||||
#t)
|
|
||||||
|
|
||||||
(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")))
|
(let ((npm (string-append (assoc-ref inputs "node") "/bin/npm")))
|
||||||
(invoke npm "--offline" "--ignore-scripts" "--install-links" "install")
|
(invoke npm "--offline"
|
||||||
#t))
|
"--ignore-scripts"
|
||||||
|
"--install-links"
|
||||||
|
"--no-audit"
|
||||||
|
"install")))
|
||||||
|
|
||||||
(define* (build #:key inputs #:allow-other-keys)
|
(define* (build #:key inputs #:allow-other-keys)
|
||||||
(let ((package-meta (call-with-input-file "package.json" json->scm)))
|
(let* ((package-meta (call-with-input-file "package.json" json->scm))
|
||||||
(if (assoc-ref* (assoc-ref* package-meta "scripts" '()) "build" #f)
|
(scripts (assoc-ref package-meta "scripts")))
|
||||||
|
(if (and scripts (assoc-ref scripts "build"))
|
||||||
(let ((npm (string-append (assoc-ref inputs "node") "/bin/npm")))
|
(let ((npm (string-append (assoc-ref inputs "node") "/bin/npm")))
|
||||||
(invoke npm "run" "build"))
|
(invoke npm "run" "build"))
|
||||||
(format #t "there is no build script to run~%"))
|
(format #t "there is no build script to run~%"))))
|
||||||
#t))
|
|
||||||
|
|
||||||
(define* (check #:key tests? inputs test-target #:allow-other-keys)
|
(define* (check #:key tests? inputs test-target #:allow-other-keys)
|
||||||
"Run 'npm run TEST-TARGET' if TESTS?"
|
"Run 'npm run TEST-TARGET' if TESTS?"
|
||||||
@@ -334,8 +301,7 @@ exist."
|
|||||||
"--owner=0"
|
"--owner=0"
|
||||||
"--group=0"
|
"--group=0"
|
||||||
"--numeric-owner"
|
"--numeric-owner"
|
||||||
"-czf" "../package.tgz" ".")
|
"-czf" "../package.tgz" "."))
|
||||||
#t)
|
|
||||||
|
|
||||||
(define* (install #:key outputs inputs #:allow-other-keys)
|
(define* (install #:key outputs inputs #:allow-other-keys)
|
||||||
"Install the node module to the output store item."
|
"Install the node module to the output store item."
|
||||||
@@ -347,8 +313,7 @@ exist."
|
|||||||
"--loglevel" "info"
|
"--loglevel" "info"
|
||||||
"--production"
|
"--production"
|
||||||
"--install-links"
|
"--install-links"
|
||||||
"install" "../package.tgz")
|
"install" "../package.tgz")))
|
||||||
#t))
|
|
||||||
|
|
||||||
(define* (avoid-node-gyp-rebuild #:key outputs #:allow-other-keys)
|
(define* (avoid-node-gyp-rebuild #:key outputs #:allow-other-keys)
|
||||||
"Adjust the installed 'package.json' to remove an 'install' script that
|
"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:
|
;; For further details, see:
|
||||||
;; - https://docs.npmjs.com/cli/v8/configuring-npm/package-json#default-values
|
;; - https://docs.npmjs.com/cli/v8/configuring-npm/package-json#default-values
|
||||||
;; - https://docs.npmjs.com/cli/v8/using-npm/scripts#best-practices
|
;; - https://docs.npmjs.com/cli/v8/using-npm/scripts#best-practices
|
||||||
(define installed-package.json
|
(let* ((installed-package.json
|
||||||
(search-input-file outputs (string-append "/lib/node_modules/"
|
(search-input-file outputs (string-append "/lib/node_modules/"
|
||||||
(module-name ".")
|
(module-name ".")
|
||||||
"/package.json")))
|
"/package.json")))
|
||||||
;; We don't want to use an atomic replacement here, because we often don't
|
;; We don't want to use an atomic replacement here, because we often
|
||||||
;; even need to overwrite this file. Therefore, let's use some helpers
|
;; don't even need to overwrite this file. Therefore, let's use some
|
||||||
;; that we'd otherwise not need.
|
;; helpers that we'd otherwise not need.
|
||||||
(define pkg-meta
|
(pkg-meta (call-with-input-file installed-package.json json->scm))
|
||||||
(call-with-input-file installed-package.json json->scm))
|
(scripts (or (assoc-ref pkg-meta "scripts") '())))
|
||||||
(define scripts
|
(when (equal? "node-gyp rebuild" (assoc-ref scripts "install"))
|
||||||
(assoc-ref* pkg-meta "scripts" '()))
|
(call-with-output-file installed-package.json
|
||||||
|
(lambda (out)
|
||||||
(when (equal? "node-gyp rebuild" (assoc-ref* scripts "install" #f))
|
(scm->json
|
||||||
(call-with-output-file installed-package.json
|
(assoc-set! pkg-meta
|
||||||
(lambda (out)
|
"scripts"
|
||||||
(scm->json
|
(assoc-set! scripts
|
||||||
(assoc-set! pkg-meta
|
"install"
|
||||||
"scripts"
|
"echo Guix: avoiding node-gyp rebuild"))
|
||||||
(assoc-set! scripts
|
out))))))
|
||||||
"install"
|
|
||||||
"echo Guix: avoiding node-gyp rebuild"))
|
|
||||||
out)))))
|
|
||||||
|
|
||||||
(define %standard-phases
|
(define %standard-phases
|
||||||
(modify-phases gnu:%standard-phases
|
(modify-phases gnu:%standard-phases
|
||||||
|
|||||||
Reference in New Issue
Block a user