diff mbox series

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

Message ID 87tuibh43w.fsf@airmail.cc
State New
Headers show
Series [bug#50755] import: Generate list of importers based on available modules | expand

Checks

Context Check Description
cbaines/comparison success View comparision
cbaines/git branch success View Git branch
cbaines/applying patch success View Laminar job
cbaines/issue success View issue
cbaines/comparison success View comparision
cbaines/git branch success View Git branch
cbaines/applying patch success View Laminar job
cbaines/issue success View issue

Commit Message

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

Comments

Sarah Morgensen Sept. 23, 2021, 6:07 p.m. UTC | #1
Hello,

This looks like a good improvement! Thanks for submitting the patch.
Just reading ths, I have a couple comments.

pinoaffe <pinoaffe@airmail.cc> writes:

> * guix/scripts/import.scm (importers): Generate a list of all importers by
> looping over available guile modules, allowing for extensibility.
> ---
>  guix/scripts/import.scm | 9 ++++++---
>  1 file changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/guix/scripts/import.scm b/guix/scripts/import.scm
> index 40fa6759ae..44cbaf13d6 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,11 @@ rather than \\n."
>  ;;; Entry point.
>  ;;;
>  
> -(define importers '("gnu" "pypi" "cpan" "hackage" "stackage" "egg" "elpa"
> -                    "gem" "go" "cran" "crate" "texlive" "json" "opam"
> -                    "minetest"))
> +(define importers (map (lambda (module)
> +                         (symbol->string (caddr (module-name module))))

Prefer ice-9 'match'/'match-lambda' over 'car'/'cadr'/'caddr'/etc, or if
necessary, SRFI-1 'first', 'second', ..., 'last'.

> +                       (all-modules (map (lambda (entry)
> +                                           `(,entry . "guix/import"))
                         should this be guix/scripts/import? ^

> +                                         %load-path))))
>  
>  (define (resolve-importer name)
>    (let ((module (resolve-interface

--
Sarah
pinoaffe Sept. 23, 2021, 9:17 p.m. UTC | #2
Hi, thanks for the comments!

Sarah Morgensen writes:
> Prefer ice-9 'match'/'match-lambda' over 'car'/'cadr'/'caddr'/etc, or if
> necessary, SRFI-1 'first', 'second', ..., 'last'.
okay, I'll change this

>                          should this be guix/scripts/import? ^
It definitely should be, oopsidaisy :)

will send a new patch in a sec
diff mbox series

Patch

diff --git a/guix/scripts/import.scm b/guix/scripts/import.scm
index 40fa6759ae..44cbaf13d6 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,11 @@  rather than \\n."
 ;;; Entry point.
 ;;;
 
-(define importers '("gnu" "pypi" "cpan" "hackage" "stackage" "egg" "elpa"
-                    "gem" "go" "cran" "crate" "texlive" "json" "opam"
-                    "minetest"))
+(define importers (map (lambda (module)
+                         (symbol->string (caddr (module-name module))))
+                       (all-modules (map (lambda (entry)
+                                           `(,entry . "guix/import"))
+                                         %load-path))))
 
 (define (resolve-importer name)
   (let ((module (resolve-interface