Subject: [bug#77231] [PATCH 6/6] import: npm-binary: Filter out npm-ignored-inputs.

From: Nicolas Graves <[email-masked]>
Date: Mon, 24 Mar 2025 08:29:17 +0100

* guix/import/npm-binary.scm (npm-keep-input?): Add variable.
(npm-package->package-sexp): Use npm-keep-input? to filter out
unwanted inputs.
---
 guix/import/npm-binary.scm | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/guix/import/npm-binary.scm b/guix/import/npm-binary.scm
index 01079c2814..fed063f55d 100644
--- a/guix/import/npm-binary.scm
+++ b/guix/import/npm-binary.scm
@@ -24,6 +24,7 @@ (define-module (guix import npm-binary)
   #:use-module (gcrypt hash)
   #:use-module (gnu packages)
   #:use-module (guix base32)
+  #:use-module ((guix build node-build-system) #:select (npm-ignored-inputs))
   #:use-module (guix http-client)
   #:use-module (guix import json)
   #:use-module (guix import utils)
@@ -201,6 +202,16 @@ (define (package-revision->symbol package)
          (name (npm-name->name npm-name)))
     (name+version->symbol name version)))
 
+(define (npm-keep-input? input)
+  "If INPUT is not among `npm-ignored-inputs', return it.  Else return #f."
+  (match npm-ignored-inputs
+    (((ignored ...) (prefixes ...) . ())
+     (let ((name (versioned-package-name input)))
+       (and (not (or (member name ignored)
+                     (any (cut string-prefix? <> name) prefixes)))
+            input)))
+    (_ #f)))
+
 (define (npm-package->package-sexp npm-package)
   "Return the `package' s-expression for an NPM-PACKAGE."
   (define resolve-spec
@@ -218,6 +229,9 @@ (define resolve-spec
                            home-page
                            (string-append %default-page "/" (uri-encode name))))
             (synopsis description)
+            (dependencies (filter-map npm-keep-input? dependencies))
+            (dev-dependencies (filter-map npm-keep-input? dev-dependencies))
+            (peer-dependencies (filter-map npm-keep-input? peer-dependencies))
             (resolved-deps (map resolve-spec
                                 (append dependencies peer-dependencies)))
             (peer-names (map versioned-package-name peer-dependencies))
-- 
2.48.1