guix_mirror_bot pushed a commit to branch javascript-team in repository guix.
commit 83e86ab0da0f9af3876482e35f90939ff3a189af Author: Jelle Licht <[email protected]> AuthorDate: Thu Oct 15 13:07:38 2026 +0200 build/node: Remove 'avoid-node-gyp-rebuild' phase. Since version 7 npm no longer writes the 'node-gyp rebuild' install script to the installed package.json. Dependents do not run install scripts because npm_config_ignore_scripts is set. * guix/build/node-build-system.scm (avoid-node-gyp-rebuild): Remove procedure. (%standard-phases): Remove 'avoid-node-gyp-rebuild. --- guix/build/node-build-system.scm | 50 +--------------------------------------- 1 file changed, 1 insertion(+), 49 deletions(-) diff --git a/guix/build/node-build-system.scm b/guix/build/node-build-system.scm index fbe30615ecc..c9069864e63 100644 --- a/guix/build/node-build-system.scm +++ b/guix/build/node-build-system.scm @@ -313,53 +313,6 @@ when running scripts." (delete-except "build" (cut string=? <> "Release")) (delete-except "build/Release" (cut string-suffix? ".node" <>)))))) -(define* (avoid-node-gyp-rebuild #:key outputs #:allow-other-keys) - "Adjust the installed 'package.json' to remove an 'install' script that -would try to run 'node-gyp rebuild'." - ;; We want to take advantage of `npm install`'s automatic support for - ;; building native addons with node-gyp: in particular, it helps us avoid - ;; hard-coding the specifics of how npm's internal copy of node-gyp is - ;; currently packaged. However, the mechanism by which the automatic support - ;; is implemented causes problems for us. - ;; - ;; If a package contains a 'binding.gyp' file and does not define an - ;; 'install' or 'preinstall' script, 'npm install' runs a default install - ;; script consisting of 'node-gyp rebuild'. In our 'install' phase, this - ;; implicit 'install' script, if it is applicable, is explicitly added to - ;; the "package.json" file. However, if another Guix package were to use a - ;; Node.js package with such an 'install' script, the dependent package's - ;; build process would fail, because 'node-gyp rebuild' would try to write - ;; to the store. - ;; - ;; Here, if the installed "package.json" defines scripts.install as - ;; "node-gyp rebuild", we replace it with a no-op. Importantly, deleting the - ;; install script definition would not be enough, because the default - ;; install script would cause the same problem. - ;; - ;; 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 - (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 - #:pretty #t)))))) - (define %standard-phases (modify-phases gnu:%standard-phases (add-after 'unpack 'set-home set-home) @@ -371,8 +324,7 @@ would try to run 'node-gyp rebuild'." (add-before 'install 'repack repack) (replace 'install install) (add-after 'install 'build-addon build-addon) - (add-after 'build-addon 'link-bins link-bins) - (add-after 'link-bins 'avoid-node-gyp-rebuild avoid-node-gyp-rebuild))) + (add-after 'build-addon 'link-bins link-bins))) (define* (node-build #:key inputs (phases %standard-phases) #:allow-other-keys #:rest args)
