diff mbox series

[bug#50873,2/7] guix home: import: Allow multiple modules to be imported for each service.

Message ID ac6637753c1939bddd18c285e4ce0a5937d4cb02.1633861021.git.public@yoctocell.xyz
State New
Headers show
Series Fixes to ‘guix home import’ | 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
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
cbaines/comparison success View comparision
cbaines/git branch success View Git branch
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/applying patch success View Laminar job
cbaines/issue success View issue

Commit Message

Xinglu Chen Oct. 10, 2021, 10:20 a.m. UTC
Previously, only one module could be imported for each service, e.g., only
(gnu home-services shell) could be imported when generating the Bash service
declaration.  However, for some services, multiple modules might need to be
imported in order for it to work.

* guix/scripts/home/import.scm (generate-bash-module+configuration): Rename to
...
(generate-bash-configuration+modules): ... this.
(%files-configurations-alist): Rename to ...
(%files+configurations-alist): ... this.
(modules+configurations): Rename to ...
(configurations+modules): ... this.
(manifest->code): Adjust accordingly.
---
 guix/scripts/home/import.scm | 43 ++++++++++++++++++------------------
 1 file changed, 22 insertions(+), 21 deletions(-)
diff mbox series

Patch

diff --git a/guix/scripts/home/import.scm b/guix/scripts/home/import.scm
index a6ab68a32c..ad926fa202 100644
--- a/guix/scripts/home/import.scm
+++ b/guix/scripts/home/import.scm
@@ -40,15 +40,14 @@  (define-module (guix scripts home import)
 (define %destination-directory
   (make-parameter (string-append (getenv "HOME") "/src/guix-config")))
 
-(define (generate-bash-module+configuration)
+(define (generate-bash-configuration+modules)
   (define (destination-append path)
     (string-append (%destination-directory) "/" path))
 
   (let ((rc (destination-append ".bashrc"))
         (profile (destination-append ".bash_profile"))
         (logout (destination-append ".bash_logout")))
-    `((gnu home-services bash)
-      (service home-bash-service-type
+    `((service home-bash-service-type
                (home-bash-configuration
                 ,@(if (file-exists? rc)
                       `((bashrc
@@ -64,14 +63,16 @@  (define (destination-append path)
                       `((bash-logout
                          (list (slurp-file-gexp
                                 (local-file ,logout)))))
-                      '()))))))
+                      '())))
+      (gnu home-services bash))))
 
-(define %files-configurations-alist
-  `((".bashrc" . ,generate-bash-module+configuration)
-    (".bash_profile" . ,generate-bash-module+configuration)
-    (".bash_logout" . ,generate-bash-module+configuration)))
 
-(define (modules+configurations)
+(define %files+configurations-alist
+  `((".bashrc" . ,generate-bash-configuration+modules)
+    (".bash_profile" . ,generate-bash-configuration+modules)
+    (".bash_logout" . ,generate-bash-configuration+modules)))
+
+(define (configurations+modules)
   (define configurations
     (delete-duplicates
      (filter-map (match-lambda
@@ -85,11 +86,11 @@  (define configurations
                                         (%destination-directory) "/" file))
                             proc)
                           #f))))
-                 %files-configurations-alist)
+                 %files+configurations-alist)
      (lambda (x y)
        (equal? (procedure-name x) (procedure-name y)))))
   
-    (map (lambda (proc) (proc)) configurations))
+  (map (lambda (proc) (proc)) configurations))
 
 ;; Based on `manifest->code' from (guix profiles)
 ;; MAYBE: Upstream it?
@@ -144,14 +145,14 @@  (define (qualified-name entry)
                                                    ":" output))))
                         (manifest-entries manifest))))
         (if home-environment?
-            (let ((modules+configurations (modules+configurations)))
+            (let ((configurations+modules (configurations+modules)))
               `(begin
-               (use-modules (gnu home)
-                            (gnu packages)
-                            ,@(map first modules+configurations))
-               ,(home-environment-template
-                 #:specs specs
-                 #:services (map second modules+configurations))))
+                 (use-modules (gnu home)
+                              (gnu packages)
+                              ,@(concatenate (map cdr configurations+modules)))
+                 ,(home-environment-template
+                   #:specs specs
+                   #:services (map first configurations+modules))))
             `(begin
                (use-modules (gnu packages))
 
@@ -186,18 +187,18 @@  (define name
                              (options->transformation ',options))))
                        transformation-procedures)))
         (if home-environment?
-            (let ((modules+configurations (modules+configurations)))
+            (let ((configurations+modules (configurations+modules)))
               `(begin
                  (use-modules (guix transformations)
                               (gnu home)
                               (gnu packages)
-                              ,@(map first modules+configurations))
+                              ,@(concatenate (map cdr configurations+modules)))
 
                  ,@transformations
 
                  ,(home-environment-template
                    #:packages packages
-                   #:services (map second modules+configurations))))
+                   #:services (map first configurations+modules))))
             `(begin
                (use-modules (guix transformations)
                             (gnu packages))