mirror of
https://codeberg.org/guix/guix.git
synced 2026-04-28 14:43:51 +00:00
Compare commits
37 Commits
rust-team
...
javascript
| 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=.*")
|
||||
(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")
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)))))))
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user