Subject: [bug#50755] [PATCH v2] import: Generate list of importers based on available modules

From: pinoaffe <[email-masked]>
Date: Thu, 23 Sep 2021 23:19:48 +0200

* guix/scripts/import.scm (importers): Generate a list of all importers by
looping over available guile modules, allowing for extensibility.
---
 guix/scripts/import.scm | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/guix/scripts/import.scm b/guix/scripts/import.scm
index 40fa6759ae..ed702d3bff 100644
--- a/guix/scripts/import.scm
+++ b/guix/scripts/import.scm
@@ -23,6 +23,7 @@
 
 (define-module (guix scripts import)
   #:use-module (guix ui)
+  #:use-module (guix discovery)
   #:use-module (guix scripts)
   #:use-module (guix utils)
   #:use-module (srfi srfi-1)
@@ -78,9 +79,14 @@ rather than \\n."
 ;;; Entry point.
 ;;;
 
-(define importers '("gnu" "pypi" "cpan" "hackage" "stackage" "egg" "elpa"
-                    "gem" "go" "cran" "crate" "texlive" "json" "opam"
-                    "minetest"))
+(define importers (filter-map (lambda (module)
+                                (match (module-name module)
+                                  (`(guix scripts import ,importer)
+                                   (symbol->string importer))
+                                  ( #t #f)))
+                              (all-modules (map (lambda (entry)
+                                                  `(,entry . "guix/scripts/import"))
+                                                %load-path))))
 
 (define (resolve-importer name)
   (let ((module (resolve-interface
-- 
2.32.0