GNU bug report logs - #50873
[PATCH 0/5] Fixes to ‘guix home import’

Previous Next

Package: guix-patches;

Reported by: Xinglu Chen <public <at> yoctocell.xyz>

Date: Tue, 28 Sep 2021 17:34:02 UTC

Severity: normal

Tags: patch

Done: Ludovic Courtès <ludo <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 50873 in the body.
You can then email your comments to 50873 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to ludo <at> gnu.org, andrew <at> trop.in, guix-patches <at> gnu.org:
bug#50873; Package guix-patches. (Tue, 28 Sep 2021 17:34:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Xinglu Chen <public <at> yoctocell.xyz>:
New bug report received and forwarded. Copy sent to ludo <at> gnu.org, andrew <at> trop.in, guix-patches <at> gnu.org. (Tue, 28 Sep 2021 17:34:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Xinglu Chen <public <at> yoctocell.xyz>
To: guix-patches <at> gnu.org
Subject: [PATCH 0/5] Fixes to ‘guix home import’
Date: Tue, 28 Sep 2021 19:33:09 +0200
[Message part 1 (text/plain, inline)]
This series makes some fixes to the ‘guix home import’ subcommand which
brings it into a usable state.

The last patch documents the subcommand in the manual.

As a sidenote, the ‘manifest->code’ procedure in (guix scripts home
import), which is based on ‘manifest->code’ from (guix profiles) should
probably be factorized with the original ‘manifest->code’ procedure.

Xinglu Chen (5):
  guix home: import: Make the user to specify a destination directory.
  guix home: import: Allow multiple modules to be imported for each
    service.
  guix home: import: Fix module name for Bash service.
  guix home: import: Delete duplicate modules when importing.
  doc: Document the ‘guix home import’ subcommand.

 doc/guix.texi                |  33 ++++++++++
 guix/scripts/home.scm        |  25 +++++---
 guix/scripts/home/import.scm | 118 ++++++++++++++++++++---------------
 3 files changed, 116 insertions(+), 60 deletions(-)


base-commit: 5edfa6d15e5bb92609ecff7e37e3985eced1dd4d
-- 
2.33.0



[signature.asc (application/pgp-signature, inline)]

Information forwarded to ludo <at> gnu.org, andrew <at> trop.in, guix-patches <at> gnu.org:
bug#50873; Package guix-patches. (Tue, 28 Sep 2021 17:36:02 GMT) Full text and rfc822 format available.

Message #8 received at 50873 <at> debbugs.gnu.org (full text, mbox):

From: Xinglu Chen <public <at> yoctocell.xyz>
To: 50873 <at> debbugs.gnu.org
Subject: [PATCH 1/5] guix home: import: Make the user to specify a
 destination directory.
Date: Tue, 28 Sep 2021 19:35:35 +0200
Copy the appropriate the relevant configuration files to the destination
directory, and call ‘local-file’ on them.

Without this, ‘guix home import’ will generate a service declaration like this

  (service
   home-bash-service-type
   (home-bash-configuration
    (bashrc
     (list (slurp-file-gexp
            (local-file "/home/yoctocell/.bashrc"))))))

but when running ‘guix home reconfigure’, the ~/.bashrc file would be moved, so
when running ‘guix home reconfigure’ for the second time, it would read the
~/.bashrc which is itself a symlink to a file the store.

* guix/scripts/home/import.scm (%destination-directory): New parameter.
(generate-bash-module+configuration): Adjust accordingly.
(modules+configurations): Copy the user’s configuration file to
‘%destination-directory’.
* guix/scripts/home.scm (process-command): Adjust accordingly; create
‘%destination-directory’ if it doesn’t exist.
---
 guix/scripts/home.scm        | 25 +++++++-----
 guix/scripts/home/import.scm | 75 +++++++++++++++++++++---------------
 2 files changed, 60 insertions(+), 40 deletions(-)

diff --git a/guix/scripts/home.scm b/guix/scripts/home.scm
index 75df6d707d..0f638b643e 100644
--- a/guix/scripts/home.scm
+++ b/guix/scripts/home.scm
@@ -38,6 +38,7 @@ (define-module (guix scripts home)
   #:autoload   (guix scripts pull) (channel-commit-hyperlink)
   #:use-module (guix scripts home import)
   #:use-module ((guix status) #:select (with-status-verbosity))
+  #:use-module ((guix build utils) #:select (mkdir-p))
   #:use-module (guix gexp)
   #:use-module (guix monads)
   #:use-module (srfi srfi-1)
@@ -248,15 +249,21 @@ (define-syntax-rule (with-store* store exp ...)
      (apply search args))
     ((import)
      (let* ((profiles (delete-duplicates
-                      (match (filter-map (match-lambda
-                                           (('profile . p) p)
-                                           (_              #f))
-                                         opts)
-                        (() (list %current-profile))
-                        (lst (reverse lst)))))
-           (manifest (concatenate-manifests
-                      (map profile-manifest profiles))))
-       (import-manifest manifest (current-output-port))))
+                       (match (filter-map (match-lambda
+                                            (('profile . p) p)
+                                            (_              #f))
+                                          opts)
+                         (() (list %current-profile))
+                         (lst (reverse lst)))))
+            (manifest (concatenate-manifests
+                       (map profile-manifest profiles)))
+            (destination (match args
+                           ((destination) destination)
+                           (_ (leave (G_ "wrong number of arguments~%"))))))
+       (unless (file-exists? destination)
+         (mkdir-p destination))
+       (parameterize ((%destination-directory destination))
+         (import-manifest manifest (current-output-port)))))
     ((describe)
      (match (generation-number %guix-home)
        (0
diff --git a/guix/scripts/home/import.scm b/guix/scripts/home/import.scm
index 79fb23a2fd..a6ab68a32c 100644
--- a/guix/scripts/home/import.scm
+++ b/guix/scripts/home/import.scm
@@ -27,7 +27,8 @@ (define-module (guix scripts home import)
   #:use-module (ice-9 pretty-print)
   #:use-module (srfi srfi-1)
   #:use-module (srfi srfi-26)
-  #:export (import-manifest))
+  #:export (import-manifest
+            %destination-directory))
 
 ;;; Commentary:
 ;;;
@@ -36,29 +37,34 @@ (define-module (guix scripts home import)
 ;;;
 ;;; Code:
 
+(define %destination-directory
+  (make-parameter (string-append (getenv "HOME") "/src/guix-config")))
 
 (define (generate-bash-module+configuration)
-  (let ((rc (string-append (getenv "HOME") "/.bashrc"))
-        (profile (string-append (getenv "HOME") "/.bash_profile"))
-        (logout (string-append (getenv "HOME") "/.bash_logout")))
+  (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
-                 (home-bash-configuration
-                  ,@(if (file-exists? rc)
-                        `((bashrc
-                           (list (slurp-file-gexp (local-file ,rc)))))
-                        '())
-                  ,@(if (file-exists? profile)
-                        `((bash-profile
-                           (list (slurp-file-gexp
-                                  (local-file ,profile)))))
-                        '())
-                  ,@(if (file-exists? logout)
-                        `((bash-logout
-                           (list (slurp-file-gexp
-                                  (local-file ,logout)))))
-                        '()))))))
-
+               (home-bash-configuration
+                ,@(if (file-exists? rc)
+                      `((bashrc
+                         (list (slurp-file-gexp
+                                (local-file ,rc)))))
+                      '())
+                ,@(if (file-exists? profile)
+                      `((bash-profile
+                         (list (slurp-file-gexp
+                                (local-file ,profile)))))
+                      '())
+                ,@(if (file-exists? logout)
+                      `((bash-logout
+                         (list (slurp-file-gexp
+                                (local-file ,logout)))))
+                      '()))))))
 
 (define %files-configurations-alist
   `((".bashrc" . ,generate-bash-module+configuration)
@@ -66,17 +72,24 @@ (define %files-configurations-alist
     (".bash_logout" . ,generate-bash-module+configuration)))
 
 (define (modules+configurations)
-  (let ((configurations (delete-duplicates
-                         (filter-map (match-lambda
-                                ((file . proc)
-                                 (if (file-exists?
-                                      (string-append (getenv "HOME") "/" file))
-                                     proc
-                                     #f)))
-                                     %files-configurations-alist)
-                         (lambda (x y)
-                           (equal? (procedure-name x) (procedure-name y))))))
-    (map (lambda (proc) (proc)) configurations)))
+  (define configurations
+    (delete-duplicates
+     (filter-map (match-lambda
+                   ((file . proc)
+                    (let ((absolute-path (string-append (getenv "HOME")
+                                                        "/" file)))
+                      (if (file-exists? absolute-path)
+                          (begin
+                            (copy-file absolute-path
+                                       (string-append
+                                        (%destination-directory) "/" file))
+                            proc)
+                          #f))))
+                 %files-configurations-alist)
+     (lambda (x y)
+       (equal? (procedure-name x) (procedure-name y)))))
+  
+    (map (lambda (proc) (proc)) configurations))
 
 ;; Based on `manifest->code' from (guix profiles)
 ;; MAYBE: Upstream it?
-- 
2.33.0







Information forwarded to ludo <at> gnu.org, andrew <at> trop.in, guix-patches <at> gnu.org:
bug#50873; Package guix-patches. (Tue, 28 Sep 2021 17:37:01 GMT) Full text and rfc822 format available.

Message #11 received at 50873 <at> debbugs.gnu.org (full text, mbox):

From: Xinglu Chen <public <at> yoctocell.xyz>
To: 50873 <at> debbugs.gnu.org
Subject: [PATCH 2/5] guix home: import: Allow multiple modules to be
 imported for each service.
Date: Tue, 28 Sep 2021 19:35:47 +0200
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 --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))
-- 
2.33.0







Information forwarded to ludo <at> gnu.org, andrew <at> trop.in, guix-patches <at> gnu.org:
bug#50873; Package guix-patches. (Tue, 28 Sep 2021 17:37:02 GMT) Full text and rfc822 format available.

Message #14 received at 50873 <at> debbugs.gnu.org (full text, mbox):

From: Xinglu Chen <public <at> yoctocell.xyz>
To: 50873 <at> debbugs.gnu.org
Subject: [PATCH 3/5] guix home: import: Fix module name for Bash service.
Date: Tue, 28 Sep 2021 19:35:52 +0200
* guix/scripts/home/import.scm (generate-bash-configuration+modules): Change
(gnu home-services bash) to (gnu home-services shells).
---
 guix/scripts/home/import.scm | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/guix/scripts/home/import.scm b/guix/scripts/home/import.scm
index ad926fa202..6d9ca98f28 100644
--- a/guix/scripts/home/import.scm
+++ b/guix/scripts/home/import.scm
@@ -64,7 +64,7 @@ (define (destination-append path)
                          (list (slurp-file-gexp
                                 (local-file ,logout)))))
                       '())))
-      (gnu home-services bash))))
+      (gnu home-services shells))))
 
 
 (define %files+configurations-alist
-- 
2.33.0







Information forwarded to ludo <at> gnu.org, andrew <at> trop.in, guix-patches <at> gnu.org:
bug#50873; Package guix-patches. (Tue, 28 Sep 2021 17:37:02 GMT) Full text and rfc822 format available.

Message #17 received at 50873 <at> debbugs.gnu.org (full text, mbox):

From: Xinglu Chen <public <at> yoctocell.xyz>
To: 50873 <at> debbugs.gnu.org
Subject: [PATCH 4/5] guix home: import: Delete duplicate modules when
 importing.
Date: Tue, 28 Sep 2021 19:36:00 +0200
Two different services might require the same module(s), so delete duplicates
when generating the ‘use-modules’ form.

* import.scm (manifest->code): Delete duplicate modules.
---
 guix/scripts/home/import.scm | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/guix/scripts/home/import.scm b/guix/scripts/home/import.scm
index 6d9ca98f28..5ba99378af 100644
--- a/guix/scripts/home/import.scm
+++ b/guix/scripts/home/import.scm
@@ -149,7 +149,8 @@ (define (qualified-name entry)
               `(begin
                  (use-modules (gnu home)
                               (gnu packages)
-                              ,@(concatenate (map cdr configurations+modules)))
+                              ,@((compose delete-duplicates concatenate)
+                                 (map cdr configurations+modules)))
                  ,(home-environment-template
                    #:specs specs
                    #:services (map first configurations+modules))))
@@ -192,7 +193,8 @@ (define name
                  (use-modules (guix transformations)
                               (gnu home)
                               (gnu packages)
-                              ,@(concatenate (map cdr configurations+modules)))
+                              ,@((compose delete-duplicates concatenate)
+                                 (map cdr configurations+modules)))
 
                  ,@transformations
 
-- 
2.33.0







Information forwarded to ludo <at> gnu.org, andrew <at> trop.in, guix-patches <at> gnu.org:
bug#50873; Package guix-patches. (Tue, 28 Sep 2021 17:37:03 GMT) Full text and rfc822 format available.

Message #20 received at 50873 <at> debbugs.gnu.org (full text, mbox):

From: Xinglu Chen <public <at> yoctocell.xyz>
To: 50873 <at> debbugs.gnu.org
Subject: [PATCH 5/5] doc: Document the ‘guix home import’ subcommand.
Date: Tue, 28 Sep 2021 19:36:02 +0200
* doc/guix.texi (Invoking guix home): Document ‘guix home import’.
---
 doc/guix.texi | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)

diff --git a/doc/guix.texi b/doc/guix.texi
index 7956652050..2c268705d0 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -36088,6 +36088,39 @@
 $ guix home list-generations 10d
 @end example
 
+@item import
+Generate a @dfn{home environment} from the packages in the default
+profile and configuration files found in the user's home directory.  The
+configuration files will be copied to the specified directory.  Note
+that not every home service that exists is supported (@pxref{Home
+Services}).
+
+@example
+$ guix home import ~/guix-config
+;; This "home-environment" file can be passed to 'guix home reconfigure'
+;; to reproduce the content of your profile.  This is "symbolic": it only
+;; specifies package names.  To reproduce the exact same profile, you also
+;; need to capture the channels being used, as returned by "guix describe".
+;; See the "Replicating Guix" section in the manual.
+
+(use-modules
+  (gnu home)
+  (gnu packages)
+  (gnu home-services bash))
+
+(home-environment
+  (packages
+    (map specification->package
+         (list "glibc-locales" "nss-certs" "nss")))
+  (services
+    (list (service
+            home-bash-service-type
+            (home-bash-configuration
+              (bashrc
+                (list (slurp-file-gexp
+                        (local-file "/home/alice/guix-config/.bashrc")))))))))
+@end example
+
 @end table
 
 @node Documentation
-- 
2.33.0







Information forwarded to ludo <at> gnu.org, andrew <at> trop.in, guix-patches <at> gnu.org:
bug#50873; Package guix-patches. (Tue, 28 Sep 2021 19:01:02 GMT) Full text and rfc822 format available.

Message #23 received at 50873 <at> debbugs.gnu.org (full text, mbox):

From: Xinglu Chen <public <at> yoctocell.xyz>
To: 50873 <at> debbugs.gnu.org
Cc: Antero Mejr <antero <at> mailbox.org>
Subject: Re: [bug#50796] [PATCH] gnu: Add pn.
Date: Tue, 28 Sep 2021 20:59:52 +0200
[Message part 1 (text/plain, inline)]
On Fri, Sep 24 2021, Antero Mejr via Guix-patches via wrote:

> * gnu/packages/telephony.scm (pn): New variable.

The ‘libphonenumber’ package is also added; this should be split into
patches, each adding one new package.

> ---
> Add pn and its dependencies.
> It's a phone number CLI tool used by Linux phone GUIs like SXMO.
>
>  gnu/packages/telephony.scm | 72 ++++++++++++++++++++++++++++++++++++++
>  1 file changed, 72 insertions(+)
>
> diff --git a/gnu/packages/telephony.scm b/gnu/packages/telephony.scm
> index 48bbe12920..9015cf536a 100644
> --- a/gnu/packages/telephony.scm
> +++ b/gnu/packages/telephony.scm
> @@ -20,6 +20,7 @@
>  ;;; Copyright © 2020, 2021 Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
>  ;;; Copyright © 2020 Vincent Legoll <vincent.legoll <at> gmail.com>
>  ;;; Copyright © 2021 LibreMiami <packaging-guix <at> libremiami.org>
> +;;; Copyright © 2021 Antero Mejr <antero <at> mailbox.org>
>  ;;;
>  ;;; This file is part of GNU Guix.
>  ;;;
> @@ -54,12 +55,14 @@
>    #:use-module (gnu packages documentation)
>    #:use-module (gnu packages file)
>    #:use-module (gnu packages protobuf)
> +  #:use-module (gnu packages gawk)
>    #:use-module (gnu packages gettext)
>    #:use-module (gnu packages gl)
>    #:use-module (gnu packages glib)
>    #:use-module (gnu packages gnome)
>    #:use-module (gnu packages gnupg)
>    #:use-module (gnu packages gtk)
> +  #:use-module (gnu packages icu4c)
>    #:use-module (gnu packages image)
>    #:use-module (gnu packages libcanberra)
>    #:use-module (gnu packages linphone)
> @@ -907,3 +910,72 @@ Initiation Protocol (SIP) and a multimedia framework.")
>  telephony functionality into custom Telegram clients.")
>      (home-page "https://github.com/zevlg/libtgvoip")
>      (license license:unlicense)))
> +
> +(define-public libphonenumber
> +  (package
> +    (name "libphonenumber")
> +    (version "8.12.33")
> +    (source
> +     (origin
> +       (method git-fetch)
> +       (uri (git-reference
> +             (url "https://github.com/google/libphonenumber")
> +             (commit (string-append "v" version))))
> +       (file-name (git-file-name name version))
> +       (sha256
> +         (base32
> +          "0r12icyig6jy0v87j9n3w14acfa2yfckzzfbmnjx1hww6qc9ih25"))))
> +    (build-system cmake-build-system)
> +    (arguments
> +     `(#:tests? #f

There should be a comment explaining why tests are disabled.

> +       #:phases
> +        (modify-phases %standard-phases
> +          (add-after 'unpack 'enter-dir
> +            (lambda _ (chdir "cpp") #t)))))

Phases don’t have to return #t.

> +    (inputs
> +     `(("boost" ,boost)
> +       ("googletest" ,googletest)
> +       ("protobuf" ,protobuf)
> +       ("icu4c" ,icu4c)))
> +    (home-page "https://github.com/google/libphonenumber")
> +    (synopsis "C++ library for phone number parsing")
> +    (description
> +     "libphonenumber is Google's common Java, C++ and JavaScript library for
> +parsing, formatting, and validating international phone numbers.")

I would use @code{libphonenumber}.

The package doesn’t seem to be reproducible; ‘guix build libphonenumber
--rounds=2’ fails with

--8<---------------cut here---------------start------------->8---
guix build: error: derivation `/gnu/store/a0vycg9ic70bziygn098bbvw4hy39zzb-libphonenumber-8.12.33.drv' may not be deterministic: output `/gnu/store/1ifj4ndpf3mv8nwbjp0gzrx5jpjvghgb-libphonenumber-8.12.33' differs
--8<---------------cut here---------------end--------------->8---

Could you look into this?

> +    (license license:asl2.0)))
> +
> +(define-public pn
> +  (package
> +    (name "pn")
> +    (version "0.9.0")
> +    (source
> +     (origin
> +       (method git-fetch)
> +       (uri (git-reference
> +             (url "https://github.com/Orange-OpenSource/pn")
> +             (commit (string-append "v" version))))
> +       (file-name (git-file-name name version))
> +       (sha256
> +        (base32
> +         "1lvzb0yixj7wmmqzsri20k9nn3gf06j0yjvmg2mi1zihywq7s4dx"))))
> +    (build-system cmake-build-system)
> +    (arguments
> +     `(#:tests? #f

Why are tests disabled?

> +       #:phases
> +        (modify-phases %standard-phases
> +         (add-after 'unpack 'sub-bin-path
> +           (lambda _
> +             (substitute* "CMakeLists.txt" (("DESTINATION \\$\\{AWKLIBPATH\\}")
> +                                             "DESTINATION bin")))))))
> +    (inputs
> +     `(("libphonenumber" ,libphonenumber)
> +       ("icu4c" ,icu4c)
> +       ("protobuf" ,protobuf)
> +       ("gawk" ,gawk)))
> +    (home-page "https://github.com/Orange-OpenSource/pn")
> +    (synopsis "Command-line validation tool for phone numbers")
> +    (description
> +     "pn is a tool that allows command line user/programmers to operate on
> +phone numbers (get validity information, reformat them, or extract numbers
> +from a text snippet), using libphonenumber.")

I suggest

  @code{pn} provides a command line tools that allows on to operate on
  phone numbers (get validity information, reformat them, or extract
  numbers from a text snippet), using @code{libphonenumber}.


[signature.asc (application/pgp-signature, inline)]

Information forwarded to guix-patches <at> gnu.org:
bug#50873; Package guix-patches. (Tue, 28 Sep 2021 20:53:01 GMT) Full text and rfc822 format available.

Message #26 received at 50873 <at> debbugs.gnu.org (full text, mbox):

From: Antero Mejr <antero <at> mailbox.org>
To: 50873 <at> debbugs.gnu.org
Cc: Antero Mejr <antero <at> mailbox.org>
Subject: [PATCH 1/2] gnu: Add libphonenumber.
Date: Tue, 28 Sep 2021 16:52:26 -0400
* gnu/packages/telephony.scm (libphonenumber): New variable.
---
 gnu/packages/telephony.scm | 38 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)

diff --git a/gnu/packages/telephony.scm b/gnu/packages/telephony.scm
index 48bbe12920..50b5790ae3 100644
--- a/gnu/packages/telephony.scm
+++ b/gnu/packages/telephony.scm
@@ -20,6 +20,7 @@
 ;;; Copyright © 2020, 2021 Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
 ;;; Copyright © 2020 Vincent Legoll <vincent.legoll <at> gmail.com>
 ;;; Copyright © 2021 LibreMiami <packaging-guix <at> libremiami.org>
+;;; Copyright © 2021 Antero Mejr <antero <at> mailbox.org>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -54,12 +55,14 @@
   #:use-module (gnu packages documentation)
   #:use-module (gnu packages file)
   #:use-module (gnu packages protobuf)
+  #:use-module (gnu packages gawk)
   #:use-module (gnu packages gettext)
   #:use-module (gnu packages gl)
   #:use-module (gnu packages glib)
   #:use-module (gnu packages gnome)
   #:use-module (gnu packages gnupg)
   #:use-module (gnu packages gtk)
+  #:use-module (gnu packages icu4c)
   #:use-module (gnu packages image)
   #:use-module (gnu packages libcanberra)
   #:use-module (gnu packages linphone)
@@ -907,3 +910,38 @@ Initiation Protocol (SIP) and a multimedia framework.")
 telephony functionality into custom Telegram clients.")
     (home-page "https://github.com/zevlg/libtgvoip")
     (license license:unlicense)))
+
+(define-public libphonenumber
+  (package
+    (name "libphonenumber")
+    (version "8.12.33")
+    (source
+     (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://github.com/google/libphonenumber")
+             (commit (string-append "v" version))))
+       (file-name (git-file-name name version))
+       (sha256
+         (base32
+          "0r12icyig6jy0v87j9n3w14acfa2yfckzzfbmnjx1hww6qc9ih25"))))
+    (build-system cmake-build-system)
+    (arguments
+     `(#:phases
+        (modify-phases %standard-phases
+          (add-after 'unpack 'enter-dir
+            (lambda _ (chdir "cpp")))
+          (replace 'check
+            (lambda _ (invoke "./libphonenumber_test"))))))
+    (inputs
+     `(("boost" ,boost)
+       ("googletest" ,googletest)
+       ("protobuf" ,protobuf)
+       ("icu4c" ,icu4c)))
+    (home-page "https://github.com/google/libphonenumber")
+    (synopsis "C++ library for phone number parsing")
+    (description
+     "@code{libphonenumber} is Google's common Java, C++ and JavaScript
+library for parsing, formatting, and validating international phone numbers.")
+    (license license:asl2.0)))
+
-- 
2.30.2





Information forwarded to guix-patches <at> gnu.org:
bug#50873; Package guix-patches. (Tue, 28 Sep 2021 20:54:01 GMT) Full text and rfc822 format available.

Message #29 received at 50873 <at> debbugs.gnu.org (full text, mbox):

From: Antero Mejr <antero <at> mailbox.org>
To: 50873 <at> debbugs.gnu.org
Cc: Antero Mejr <antero <at> mailbox.org>
Subject: [PATCH 2/2] gnu: Add pn.
Date: Tue, 28 Sep 2021 16:52:27 -0400
* gnu/packages/telephony.scm (pn): New variable.
---
 gnu/packages/telephony.scm | 35 +++++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)

diff --git a/gnu/packages/telephony.scm b/gnu/packages/telephony.scm
index 50b5790ae3..d30c8aa661 100644
--- a/gnu/packages/telephony.scm
+++ b/gnu/packages/telephony.scm
@@ -945,3 +945,38 @@ telephony functionality into custom Telegram clients.")
 library for parsing, formatting, and validating international phone numbers.")
     (license license:asl2.0)))
 
+(define-public pn
+  (package
+    (name "pn")
+    (version "0.9.0")
+    (source
+     (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://github.com/Orange-OpenSource/pn")
+             (commit (string-append "v" version))))
+       (file-name (git-file-name name version))
+       (sha256
+        (base32
+         "1lvzb0yixj7wmmqzsri20k9nn3gf06j0yjvmg2mi1zihywq7s4dx"))))
+    (build-system cmake-build-system)
+    (arguments
+     `(#:tests? #f ; no tests
+       #:phases
+        (modify-phases %standard-phases
+         (add-after 'unpack 'sub-bin-path
+           (lambda _
+             (substitute* "CMakeLists.txt" (("DESTINATION \\$\\{AWKLIBPATH\\}")
+                                             "DESTINATION bin")))))))
+    (inputs
+     `(("libphonenumber" ,libphonenumber)
+       ("icu4c" ,icu4c)
+       ("protobuf" ,protobuf)
+       ("gawk" ,gawk)))
+    (home-page "https://github.com/Orange-OpenSource/pn")
+    (synopsis "Command-line validation tool for phone numbers")
+    (description
+     "@code{pn} provides a command line tool that allows users to operate on
+phone numbers (get validity information, reformat them, or extract
+numbers from a text snippet), using @code{libphonenumber}.")
+    (license license:asl2.0)))
-- 
2.30.2





Information forwarded to guix-patches <at> gnu.org:
bug#50873; Package guix-patches. (Tue, 28 Sep 2021 20:54:02 GMT) Full text and rfc822 format available.

Message #32 received at 50873 <at> debbugs.gnu.org (full text, mbox):

From: Antero Mejr <antero <at> mailbox.org>
To: 50873 <at> debbugs.gnu.org
Cc: Antero Mejr <antero <at> mailbox.org>
Subject: [PATCH 0/2] Add pn.
Date: Tue, 28 Sep 2021 16:52:25 -0400
Thanks for the suggestions Xinglu, I updated with the changes.

> The package doesn’t seem to be reproducible; ‘guix build libphonenumber
> --rounds=2’ fails

libphonenumber reproduces on my main computer, I can try again with a different one later:
successfully built /gnu/store/dyf2a70slkvfxf4qcims3q69a51ydb0x-libphonenumber-8.12.33.drv
successfully built /gnu/store/dyf2a70slkvfxf4qcims3q69a51ydb0x-libphonenumber-8.12.33.drv




Information forwarded to guix-patches <at> gnu.org:
bug#50873; Package guix-patches. (Thu, 30 Sep 2021 07:09:02 GMT) Full text and rfc822 format available.

Message #35 received at 50873 <at> debbugs.gnu.org (full text, mbox):

From: Andrew Tropin <andrew <at> trop.in>
To: Xinglu Chen <public <at> yoctocell.xyz>, 50873 <at> debbugs.gnu.org
Cc: Ludovic Courtès <ludo <at> gnu.org>
Subject: Re: [bug#50873] [PATCH 5/5] doc: Document the ‘guix home import’ subcommand.
Date: Thu, 30 Sep 2021 10:08:45 +0300
[Message part 1 (text/plain, inline)]
On 2021-09-28 19:36, Xinglu Chen wrote:

> * doc/guix.texi (Invoking guix home): Document ‘guix home import’.
> ---
>  doc/guix.texi | 33 +++++++++++++++++++++++++++++++++
>  1 file changed, 33 insertions(+)
>
> diff --git a/doc/guix.texi b/doc/guix.texi
> index 7956652050..2c268705d0 100644
> --- a/doc/guix.texi
> +++ b/doc/guix.texi
> @@ -36088,6 +36088,39 @@
>  $ guix home list-generations 10d
>  @end example
>  
> +@item import
> +Generate a @dfn{home environment} from the packages in the default
> +profile and configuration files found in the user's home directory.  The
> +configuration files will be copied to the specified directory.  Note
> +that not every home service that exists is supported (@pxref{Home
> +Services}).
> +
> +@example
> +$ guix home import ~/guix-config
> +;; This "home-environment" file can be passed to 'guix home reconfigure'
> +;; to reproduce the content of your profile.  This is "symbolic": it only
> +;; specifies package names.  To reproduce the exact same profile, you also
> +;; need to capture the channels being used, as returned by "guix describe".
> +;; See the "Replicating Guix" section in the manual.
> +
> +(use-modules
> +  (gnu home)
> +  (gnu packages)
> +  (gnu home-services bash))
> +
> +(home-environment
> +  (packages
> +    (map specification->package
> +         (list "glibc-locales" "nss-certs" "nss")))
> +  (services
> +    (list (service
> +            home-bash-service-type
> +            (home-bash-configuration
> +              (bashrc
> +                (list (slurp-file-gexp

It still uses slurp-file-gexp, which is not upstreamed, but overall
looks ok.

I'll make a rationale behind this function and the approach I picked in
home services config serializers and will prepare some examples next
week.  Maybe it will convince Ludovic or maybe I'll change my mind and
rework configuration records for home services to use file-like objects.

> +                        (local-file "/home/alice/guix-config/.bashrc")))))))))
> +@end example
> +
>  @end table
>  
>  @node Documentation
[signature.asc (application/pgp-signature, inline)]

Information forwarded to guix-patches <at> gnu.org:
bug#50873; Package guix-patches. (Fri, 01 Oct 2021 05:10:02 GMT) Full text and rfc822 format available.

Message #38 received at 50873 <at> debbugs.gnu.org (full text, mbox):

From: Xinglu Chen <public <at> yoctocell.xyz>
To: Andrew Tropin <andrew <at> trop.in>, 50873 <at> debbugs.gnu.org
Cc: Ludovic Courtès <ludo <at> gnu.org>
Subject: Re: [bug#50873] [PATCH 5/5] doc: Document the ‘guix home import’ subcommand.
Date: Fri, 01 Oct 2021 07:08:21 +0200
[Message part 1 (text/plain, inline)]
On Thu, Sep 30 2021, Andrew Tropin wrote:

> On 2021-09-28 19:36, Xinglu Chen wrote:
>
>> * doc/guix.texi (Invoking guix home): Document ‘guix home import’.
>> ---
>>  doc/guix.texi | 33 +++++++++++++++++++++++++++++++++
>>  1 file changed, 33 insertions(+)
>>
>> diff --git a/doc/guix.texi b/doc/guix.texi
>> index 7956652050..2c268705d0 100644
>> --- a/doc/guix.texi
>> +++ b/doc/guix.texi
>> @@ -36088,6 +36088,39 @@
>>  $ guix home list-generations 10d
>>  @end example
>>  
>> +@item import
>> +Generate a @dfn{home environment} from the packages in the default
>> +profile and configuration files found in the user's home directory.  The
>> +configuration files will be copied to the specified directory.  Note
>> +that not every home service that exists is supported (@pxref{Home
>> +Services}).
>> +
>> +@example
>> +$ guix home import ~/guix-config
>> +;; This "home-environment" file can be passed to 'guix home reconfigure'
>> +;; to reproduce the content of your profile.  This is "symbolic": it only
>> +;; specifies package names.  To reproduce the exact same profile, you also
>> +;; need to capture the channels being used, as returned by "guix describe".
>> +;; See the "Replicating Guix" section in the manual.
>> +
>> +(use-modules
>> +  (gnu home)
>> +  (gnu packages)
>> +  (gnu home-services bash))
>> +
>> +(home-environment
>> +  (packages
>> +    (map specification->package
>> +         (list "glibc-locales" "nss-certs" "nss")))
>> +  (services
>> +    (list (service
>> +            home-bash-service-type
>> +            (home-bash-configuration
>> +              (bashrc
>> +                (list (slurp-file-gexp
>
> It still uses slurp-file-gexp, which is not upstreamed, but overall
> looks ok.

Oh, I thought it was already upstreamed, my bad.

> I'll make a rationale behind this function and the approach I picked in
> home services config serializers and will prepare some examples next
> week.  Maybe it will convince Ludovic or maybe I'll change my mind and
> rework configuration records for home services to use file-like
> objects.

OK, then we should probably wait for this ‘slurp-file-gexp’ discussion
to reach an consensus, then I can send a v2 for this series.  :-)
[signature.asc (application/pgp-signature, inline)]

Information forwarded to guix-patches <at> gnu.org:
bug#50873; Package guix-patches. (Sat, 02 Oct 2021 15:11:01 GMT) Full text and rfc822 format available.

Message #41 received at 50873 <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: Xinglu Chen <public <at> yoctocell.xyz>
Cc: 50873 <at> debbugs.gnu.org, Andrew Tropin <andrew <at> trop.in>
Subject: Re: bug#50873: [PATCH 0/5] Fixes to ‘guix home
 import’
Date: Sat, 02 Oct 2021 17:10:11 +0200
Hi,

Xinglu Chen <public <at> yoctocell.xyz> skribis:

> On Thu, Sep 30 2021, Andrew Tropin wrote:

[...]

>> It still uses slurp-file-gexp, which is not upstreamed, but overall
>> looks ok.
>
> Oh, I thought it was already upstreamed, my bad.
>
>> I'll make a rationale behind this function and the approach I picked in
>> home services config serializers and will prepare some examples next
>> week.  Maybe it will convince Ludovic or maybe I'll change my mind and
>> rework configuration records for home services to use file-like
>> objects.
>
> OK, then we should probably wait for this ‘slurp-file-gexp’ discussion
> to reach an consensus, then I can send a v2 for this series.  :-)

Yes, but I don’t expect to change my mind on this one.  :-)

I’ve explained my views before, and really, it’s no different than the
situation of Guix System services so I see no reason to do things
differently.

Apart from this bit, the documentation part LGTM.

Thank you, Xinglu!

Ludo’.




Information forwarded to guix-patches <at> gnu.org:
bug#50873; Package guix-patches. (Sat, 02 Oct 2021 15:14:01 GMT) Full text and rfc822 format available.

Message #44 received at 50873 <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: Xinglu Chen <public <at> yoctocell.xyz>
Cc: 50873 <at> debbugs.gnu.org, Andrew Tropin <andrew <at> trop.in>
Subject: Re: bug#50873: [PATCH 0/5] Fixes to ‘guix home
 import’
Date: Sat, 02 Oct 2021 17:13:05 +0200
Xinglu Chen <public <at> yoctocell.xyz> skribis:

> This series makes some fixes to the ‘guix home import’ subcommand which
> brings it into a usable state.
>
> The last patch documents the subcommand in the manual.
>
> As a sidenote, the ‘manifest->code’ procedure in (guix scripts home
> import), which is based on ‘manifest->code’ from (guix profiles) should
> probably be factorized with the original ‘manifest->code’ procedure.
>
> Xinglu Chen (5):
>   guix home: import: Make the user to specify a destination directory.
>   guix home: import: Allow multiple modules to be imported for each
>     service.
>   guix home: import: Fix module name for Bash service.
>   guix home: import: Delete duplicate modules when importing.
>   doc: Document the ‘guix home import’ subcommand.

Could you (Xinglu, Andrew, Oleg?) add tests for this?  I think
Scheme-level tests like we have for the ‘guix import’ code would be
fine.  It would also help review because it’d give a clearer view of how
this is supposed to work.

Thanks for following up on this!

Ludo’.




Information forwarded to guix-patches <at> gnu.org:
bug#50873; Package guix-patches. (Sat, 02 Oct 2021 18:47:02 GMT) Full text and rfc822 format available.

Message #47 received at 50873 <at> debbugs.gnu.org (full text, mbox):

From: Xinglu Chen <public <at> yoctocell.xyz>
To: Ludovic Courtès <ludo <at> gnu.org>
Cc: 50873 <at> debbugs.gnu.org, Andrew Tropin <andrew <at> trop.in>
Subject: Re: [bug#50873] [PATCH 0/5] Fixes to ‘guix home
 import’
Date: Sat, 02 Oct 2021 20:45:56 +0200
[Message part 1 (text/plain, inline)]
On Sat, Oct 02 2021, Ludovic Courtès wrote:

> Xinglu Chen <public <at> yoctocell.xyz> skribis:
>
>> This series makes some fixes to the ‘guix home import’ subcommand which
>> brings it into a usable state.
>>
>> The last patch documents the subcommand in the manual.
>>
>> As a sidenote, the ‘manifest->code’ procedure in (guix scripts home
>> import), which is based on ‘manifest->code’ from (guix profiles) should
>> probably be factorized with the original ‘manifest->code’ procedure.
>>
>> Xinglu Chen (5):
>>   guix home: import: Make the user to specify a destination directory.
>>   guix home: import: Allow multiple modules to be imported for each
>>     service.
>>   guix home: import: Fix module name for Bash service.
>>   guix home: import: Delete duplicate modules when importing.
>>   doc: Document the ‘guix home import’ subcommand.
>
> Could you (Xinglu, Andrew, Oleg?) add tests for this?  I think
> Scheme-level tests like we have for the ‘guix import’ code would be
> fine.  It would also help review because it’d give a clearer view of how
> this is supposed to work.

Sure!

> Thanks for following up on this!

You are welcome!  :-)
[signature.asc (application/pgp-signature, inline)]

Information forwarded to guix-patches <at> gnu.org:
bug#50873; Package guix-patches. (Sun, 10 Oct 2021 10:21:01 GMT) Full text and rfc822 format available.

Message #50 received at 50873 <at> debbugs.gnu.org (full text, mbox):

From: Xinglu Chen <public <at> yoctocell.xyz>
To: 50873 <at> debbugs.gnu.org
Cc: Oleg Pykhalov <go.wigust <at> gmail.com>,
 Ludovic Courtès <ludo <at> gnu.org>,
 Andrew Tropin <andrew <at> trop.in>
Subject: [PATCH 0/7] Fixes to ‘guix home import’
Date: Sun, 10 Oct 2021 12:19:57 +0200
[Message part 1 (text/plain, inline)]
Change since v1:

* Remove uses of ‘slurp-file-gexp’.

* Add tests for the Scheme API of (guix scripts home import).

Xinglu Chen (7):
  guix home: import: Make the user to specify a destination directory.
  guix home: import: Allow multiple modules to be imported for each
    service.
  guix home: import: Fix module name for Bash service.
  guix home: import: Don’t use 'slurp-file-gexp'.
  guix home: import: Delete duplicate modules when importing.
  doc: Document the ‘guix home import’ subcommand.
  Add tests for ‘guix home import’.

 Makefile.am                  |   1 +
 doc/guix.texi                |  32 +++++++
 guix/scripts/home.scm        |  25 +++--
 guix/scripts/home/import.scm | 115 +++++++++++++----------
 tests/home-import.scm        | 174 +++++++++++++++++++++++++++++++++++
 5 files changed, 289 insertions(+), 58 deletions(-)
 create mode 100644 tests/home-import.scm


base-commit: edbcbdabac9a64dba3850b0f7e596b396f044599
-- 
2.33.0



[signature.asc (application/pgp-signature, inline)]

Information forwarded to guix-patches <at> gnu.org:
bug#50873; Package guix-patches. (Sun, 10 Oct 2021 10:21:02 GMT) Full text and rfc822 format available.

Message #53 received at 50873 <at> debbugs.gnu.org (full text, mbox):

From: Xinglu Chen <public <at> yoctocell.xyz>
To: 50873 <at> debbugs.gnu.org
Cc: Oleg Pykhalov <go.wigust <at> gmail.com>,
 Ludovic Courtès <ludo <at> gnu.org>,
 Andrew Tropin <andrew <at> trop.in>
Subject: [PATCH 1/7] guix home: import: Make the user to specify a
 destination directory.
Date: Sun, 10 Oct 2021 12:20:11 +0200
Copy the appropriate the relevant configuration files to the destination
directory, and call ‘local-file’ on them.

Without this, ‘guix home import’ will generate a service declaration like this

  (service
   home-bash-service-type
   (home-bash-configuration
    (bashrc
     (list (slurp-file-gexp
            (local-file "/home/yoctocell/.bashrc"))))))

but when running ‘guix home reconfigure’, the ~/.bashrc file would be moved, so
when running ‘guix home reconfigure’ for the second time, it would read the
~/.bashrc which is itself a symlink to a file the store.

* guix/scripts/home/import.scm (%destination-directory): New parameter.
(generate-bash-module+configuration): Adjust accordingly.
(modules+configurations): Copy the user’s configuration file to
‘%destination-directory’.
* guix/scripts/home.scm (process-command): Adjust accordingly; create
‘%destination-directory’ if it doesn’t exist.
---
 guix/scripts/home.scm        | 25 +++++++-----
 guix/scripts/home/import.scm | 75 +++++++++++++++++++++---------------
 2 files changed, 61 insertions(+), 39 deletions(-)

diff --git a/guix/scripts/home.scm b/guix/scripts/home.scm
index 55e7b436c1..520360e14a 100644
--- a/guix/scripts/home.scm
+++ b/guix/scripts/home.scm
@@ -40,6 +40,7 @@ (define-module (guix scripts home)
   #:autoload   (guix scripts pull) (channel-commit-hyperlink)
   #:use-module (guix scripts home import)
   #:use-module ((guix status) #:select (with-status-verbosity))
+  #:use-module ((guix build utils) #:select (mkdir-p))
   #:use-module (guix gexp)
   #:use-module (guix monads)
   #:use-module (srfi srfi-1)
@@ -260,15 +261,21 @@ (define-syntax-rule (with-store* store exp ...)
      (apply search args))
     ((import)
      (let* ((profiles (delete-duplicates
-                      (match (filter-map (match-lambda
-                                           (('profile . p) p)
-                                           (_              #f))
-                                         opts)
-                        (() (list %current-profile))
-                        (lst (reverse lst)))))
-           (manifest (concatenate-manifests
-                      (map profile-manifest profiles))))
-       (import-manifest manifest (current-output-port))))
+                       (match (filter-map (match-lambda
+                                            (('profile . p) p)
+                                            (_              #f))
+                                          opts)
+                         (() (list %current-profile))
+                         (lst (reverse lst)))))
+            (manifest (concatenate-manifests
+                       (map profile-manifest profiles)))
+            (destination (match args
+                           ((destination) destination)
+                           (_ (leave (G_ "wrong number of arguments~%"))))))
+       (unless (file-exists? destination)
+         (mkdir-p destination))
+       (parameterize ((%destination-directory destination))
+         (import-manifest manifest (current-output-port)))))
     ((describe)
      (match (generation-number %guix-home)
        (0
diff --git a/guix/scripts/home/import.scm b/guix/scripts/home/import.scm
index 611f580e85..a6ab68a32c 100644
--- a/guix/scripts/home/import.scm
+++ b/guix/scripts/home/import.scm
@@ -27,7 +27,8 @@ (define-module (guix scripts home import)
   #:use-module (ice-9 pretty-print)
   #:use-module (srfi srfi-1)
   #:use-module (srfi srfi-26)
-  #:export (import-manifest))
+  #:export (import-manifest
+            %destination-directory))
 
 ;;; Commentary:
 ;;;
@@ -36,27 +37,34 @@ (define-module (guix scripts home import)
 ;;;
 ;;; Code:
 
+(define %destination-directory
+  (make-parameter (string-append (getenv "HOME") "/src/guix-config")))
 
 (define (generate-bash-module+configuration)
-  (let ((rc (string-append (getenv "HOME") "/.bashrc"))
-        (profile (string-append (getenv "HOME") "/.bash_profile"))
-        (logout (string-append (getenv "HOME") "/.bash_logout")))
-    `((gnu home services bash)
-      (service home-bash-service-type
-                 (home-bash-configuration
-                  ,@(if (file-exists? rc)
-                        `((bashrc
-                           (list (local-file ,rc))))
-                        '())
-                  ,@(if (file-exists? profile)
-                        `((bash-profile
-                           (list (local-file ,profile))))
-                        '())
-                  ,@(if (file-exists? logout)
-                        `((bash-logout
-                           (list (local-file ,logout))))
-                        '()))))))
+  (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
+               (home-bash-configuration
+                ,@(if (file-exists? rc)
+                      `((bashrc
+                         (list (slurp-file-gexp
+                                (local-file ,rc)))))
+                      '())
+                ,@(if (file-exists? profile)
+                      `((bash-profile
+                         (list (slurp-file-gexp
+                                (local-file ,profile)))))
+                      '())
+                ,@(if (file-exists? logout)
+                      `((bash-logout
+                         (list (slurp-file-gexp
+                                (local-file ,logout)))))
+                      '()))))))
 
 (define %files-configurations-alist
   `((".bashrc" . ,generate-bash-module+configuration)
@@ -64,17 +72,24 @@ (define %files-configurations-alist
     (".bash_logout" . ,generate-bash-module+configuration)))
 
 (define (modules+configurations)
-  (let ((configurations (delete-duplicates
-                         (filter-map (match-lambda
-                                ((file . proc)
-                                 (if (file-exists?
-                                      (string-append (getenv "HOME") "/" file))
-                                     proc
-                                     #f)))
-                                     %files-configurations-alist)
-                         (lambda (x y)
-                           (equal? (procedure-name x) (procedure-name y))))))
-    (map (lambda (proc) (proc)) configurations)))
+  (define configurations
+    (delete-duplicates
+     (filter-map (match-lambda
+                   ((file . proc)
+                    (let ((absolute-path (string-append (getenv "HOME")
+                                                        "/" file)))
+                      (if (file-exists? absolute-path)
+                          (begin
+                            (copy-file absolute-path
+                                       (string-append
+                                        (%destination-directory) "/" file))
+                            proc)
+                          #f))))
+                 %files-configurations-alist)
+     (lambda (x y)
+       (equal? (procedure-name x) (procedure-name y)))))
+  
+    (map (lambda (proc) (proc)) configurations))
 
 ;; Based on `manifest->code' from (guix profiles)
 ;; MAYBE: Upstream it?
-- 
2.33.0







Information forwarded to guix-patches <at> gnu.org:
bug#50873; Package guix-patches. (Sun, 10 Oct 2021 10:21:02 GMT) Full text and rfc822 format available.

Message #56 received at 50873 <at> debbugs.gnu.org (full text, mbox):

From: Xinglu Chen <public <at> yoctocell.xyz>
To: 50873 <at> debbugs.gnu.org
Cc: Oleg Pykhalov <go.wigust <at> gmail.com>,
 Ludovic Courtès <ludo <at> gnu.org>,
 Andrew Tropin <andrew <at> trop.in>
Subject: [PATCH 2/7] guix home: import: Allow multiple modules to be
 imported for each service.
Date: Sun, 10 Oct 2021 12:20:14 +0200
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 --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))
-- 
2.33.0







Information forwarded to guix-patches <at> gnu.org:
bug#50873; Package guix-patches. (Sun, 10 Oct 2021 10:21:02 GMT) Full text and rfc822 format available.

Message #59 received at 50873 <at> debbugs.gnu.org (full text, mbox):

From: Xinglu Chen <public <at> yoctocell.xyz>
To: 50873 <at> debbugs.gnu.org
Cc: Oleg Pykhalov <go.wigust <at> gmail.com>,
 Ludovic Courtès <ludo <at> gnu.org>,
 Andrew Tropin <andrew <at> trop.in>
Subject: [PATCH 3/7] guix home: import: Fix module name for Bash service.
Date: Sun, 10 Oct 2021 12:20:23 +0200
* guix/scripts/home/import.scm (generate-bash-configuration+modules): Change
(gnu home-services bash) to (gnu home-services shells).
---
 guix/scripts/home/import.scm | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/guix/scripts/home/import.scm b/guix/scripts/home/import.scm
index ad926fa202..96ed710c2d 100644
--- a/guix/scripts/home/import.scm
+++ b/guix/scripts/home/import.scm
@@ -64,7 +64,7 @@ (define (destination-append path)
                          (list (slurp-file-gexp
                                 (local-file ,logout)))))
                       '())))
-      (gnu home-services bash))))
+      (gnu home services shells))))
 
 
 (define %files+configurations-alist
-- 
2.33.0







Information forwarded to guix-patches <at> gnu.org:
bug#50873; Package guix-patches. (Sun, 10 Oct 2021 10:21:03 GMT) Full text and rfc822 format available.

Message #62 received at 50873 <at> debbugs.gnu.org (full text, mbox):

From: Xinglu Chen <public <at> yoctocell.xyz>
To: 50873 <at> debbugs.gnu.org
Cc: Oleg Pykhalov <go.wigust <at> gmail.com>,
 Ludovic Courtès <ludo <at> gnu.org>,
 Andrew Tropin <andrew <at> trop.in>
Subject: [PATCH 4/7] guix home: import: Don’t use 'slurp-file-gexp'.
Date: Sun, 10 Oct 2021 12:20:30 +0200
‘slurp-file-gexp’ is not a bound procedure.

* guix/scripts/home/import.scm (generate-bash-configuration+modules): Don’t
  use ‘slurp-file-gexp’.
---
 guix/scripts/home/import.scm | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/guix/scripts/home/import.scm b/guix/scripts/home/import.scm
index 96ed710c2d..21f762f239 100644
--- a/guix/scripts/home/import.scm
+++ b/guix/scripts/home/import.scm
@@ -51,22 +51,18 @@ (define (destination-append path)
                (home-bash-configuration
                 ,@(if (file-exists? rc)
                       `((bashrc
-                         (list (slurp-file-gexp
-                                (local-file ,rc)))))
+                         (list (local-file ,rc))))
                       '())
                 ,@(if (file-exists? profile)
                       `((bash-profile
-                         (list (slurp-file-gexp
-                                (local-file ,profile)))))
+                         (list (local-file ,profile))))
                       '())
                 ,@(if (file-exists? logout)
                       `((bash-logout
-                         (list (slurp-file-gexp
-                                (local-file ,logout)))))
+                         (list (local-file ,logout))))
                       '())))
       (gnu home services shells))))
 
-
 (define %files+configurations-alist
   `((".bashrc" . ,generate-bash-configuration+modules)
     (".bash_profile" . ,generate-bash-configuration+modules)
-- 
2.33.0







Information forwarded to guix-patches <at> gnu.org:
bug#50873; Package guix-patches. (Sun, 10 Oct 2021 10:21:03 GMT) Full text and rfc822 format available.

Message #65 received at 50873 <at> debbugs.gnu.org (full text, mbox):

From: Xinglu Chen <public <at> yoctocell.xyz>
To: 50873 <at> debbugs.gnu.org
Cc: Oleg Pykhalov <go.wigust <at> gmail.com>,
 Ludovic Courtès <ludo <at> gnu.org>,
 Andrew Tropin <andrew <at> trop.in>
Subject: [PATCH 5/7] guix home: import: Delete duplicate modules when
 importing.
Date: Sun, 10 Oct 2021 12:20:33 +0200
Two different services might require the same module(s), so delete duplicates
when generating the ‘use-modules’ form.

* import.scm (manifest->code): Delete duplicate modules.
---
 guix/scripts/home/import.scm | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/guix/scripts/home/import.scm b/guix/scripts/home/import.scm
index 21f762f239..b892ae3dfa 100644
--- a/guix/scripts/home/import.scm
+++ b/guix/scripts/home/import.scm
@@ -145,7 +145,8 @@ (define (qualified-name entry)
               `(begin
                  (use-modules (gnu home)
                               (gnu packages)
-                              ,@(concatenate (map cdr configurations+modules)))
+                              ,@((compose delete-duplicates concatenate)
+                                 (map cdr configurations+modules)))
                  ,(home-environment-template
                    #:specs specs
                    #:services (map first configurations+modules))))
@@ -188,7 +189,8 @@ (define name
                  (use-modules (guix transformations)
                               (gnu home)
                               (gnu packages)
-                              ,@(concatenate (map cdr configurations+modules)))
+                              ,@((compose delete-duplicates concatenate)
+                                 (map cdr configurations+modules)))
 
                  ,@transformations
 
-- 
2.33.0







Information forwarded to guix-patches <at> gnu.org:
bug#50873; Package guix-patches. (Sun, 10 Oct 2021 10:21:03 GMT) Full text and rfc822 format available.

Message #68 received at 50873 <at> debbugs.gnu.org (full text, mbox):

From: Xinglu Chen <public <at> yoctocell.xyz>
To: 50873 <at> debbugs.gnu.org
Cc: Oleg Pykhalov <go.wigust <at> gmail.com>,
 Ludovic Courtès <ludo <at> gnu.org>,
 Andrew Tropin <andrew <at> trop.in>
Subject: [PATCH 6/7] doc: Document the ‘guix home import’ subcommand.
Date: Sun, 10 Oct 2021 12:20:38 +0200
* doc/guix.texi (Invoking guix home): Document ‘guix home import’.
---
 doc/guix.texi | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)

diff --git a/doc/guix.texi b/doc/guix.texi
index b577684eb7..107a76a9d3 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -36089,6 +36089,38 @@
 $ guix home list-generations 10d
 @end example
 
+@item import
+Generate a @dfn{home environment} from the packages in the default
+profile and configuration files found in the user's home directory.  The
+configuration files will be copied to the specified directory.  Note
+that not every home service that exists is supported (@pxref{Home
+Services}).
+
+@example
+$ guix home import ~/guix-config
+;; This "home-environment" file can be passed to 'guix home reconfigure'
+;; to reproduce the content of your profile.  This is "symbolic": it only
+;; specifies package names.  To reproduce the exact same profile, you also
+;; need to capture the channels being used, as returned by "guix describe".
+;; See the "Replicating Guix" section in the manual.
+
+(use-modules
+  (gnu home)
+  (gnu packages)
+  (gnu home services shells))
+
+(home-environment
+  (packages
+    (map specification->package
+         (list "glibc-locales" "nss-certs" "nss")))
+  (services
+    (list (service
+            home-bash-service-type
+            (home-bash-configuration
+              (bashrc
+                (list (local-file "/tmp/guix-config/.bashrc"))))))))
+@end example
+
 @end table
 
 @var{options} can contain any of the common build options (@pxref{Common
-- 
2.33.0







Information forwarded to guix-patches <at> gnu.org:
bug#50873; Package guix-patches. (Sun, 10 Oct 2021 10:21:04 GMT) Full text and rfc822 format available.

Message #71 received at 50873 <at> debbugs.gnu.org (full text, mbox):

From: Xinglu Chen <public <at> yoctocell.xyz>
To: 50873 <at> debbugs.gnu.org
Cc: Oleg Pykhalov <go.wigust <at> gmail.com>,
 Ludovic Courtès <ludo <at> gnu.org>,
 Andrew Tropin <andrew <at> trop.in>
Subject: [PATCH 7/7] Add tests for ‘guix home import’.
Date: Sun, 10 Oct 2021 12:20:49 +0200
* tests/home-import.scm: New file.
* Makefile.am (SCM_TESTS): Add it.
---
 Makefile.am                  |   1 +
 guix/scripts/home/import.scm |   5 +-
 tests/home-import.scm        | 174 +++++++++++++++++++++++++++++++++++
 3 files changed, 179 insertions(+), 1 deletion(-)
 create mode 100644 tests/home-import.scm

diff --git a/Makefile.am b/Makefile.am
index 635147efc1..f93199e561 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -474,6 +474,7 @@ SCM_TESTS =					\
   tests/graph.scm				\
   tests/gremlin.scm				\
   tests/hackage.scm				\
+  tests/home-import.scm				\
   tests/import-git.scm				\
   tests/import-utils.scm			\
   tests/inferior.scm				\
diff --git a/guix/scripts/home/import.scm b/guix/scripts/home/import.scm
index b892ae3dfa..c68cfb9e78 100644
--- a/guix/scripts/home/import.scm
+++ b/guix/scripts/home/import.scm
@@ -28,7 +28,10 @@ (define-module (guix scripts home import)
   #:use-module (srfi srfi-1)
   #:use-module (srfi srfi-26)
   #:export (import-manifest
-            %destination-directory))
+            %destination-directory
+
+            ;; For tests.
+            manifest->code))
 
 ;;; Commentary:
 ;;;
diff --git a/tests/home-import.scm b/tests/home-import.scm
new file mode 100644
index 0000000000..8d141bba0f
--- /dev/null
+++ b/tests/home-import.scm
@@ -0,0 +1,174 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2021 Xinglu Chen <public <at> yoctocell.xyz
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (test-home-import)
+  #:use-module (guix scripts home import)
+  #:use-module (guix utils)
+  #:use-module (guix build utils)
+  #:use-module (guix packages)
+  #:use-module (ice-9 match)
+  #:use-module ((guix profiles) #:hide (manifest->code))
+  #:use-module (gnu packages)
+  #:use-module (srfi srfi-1)
+  #:use-module (srfi srfi-26)
+  #:use-module (srfi srfi-64))
+
+;; Test the (guix scripts home import) tools.
+
+(test-begin "home-import")
+
+;; Example manifest entries.
+
+(define guile-2.0.9
+  (manifest-entry
+    (name "guile")
+    (version "2.0.9")
+    (item "/gnu/store/...")))
+
+(define glibc
+  (manifest-entry
+    (name "glibc")
+    (version "2.19")
+    (item "/gnu/store/...")))
+
+(define gcc
+  (manifest-entry
+    (name "gcc")
+    (version "10.3.0")
+    (item "/gnu/store/...")))
+
+;; Helpers for checking and generating home environments.
+
+(%destination-directory "/tmp/guix-config")
+(mkdir-p (%destination-directory))
+
+(define %temporary-home-directory "/tmp/guix-home-import-test")
+
+(define-syntax-rule (define-home-environment-matcher name pattern)
+  (define (name obj)
+    (match obj
+      (pattern #t)
+      (x (pk 'fail x #f)))))
+
+(define (create-temporary-home files-alist)
+  "Create a temporary home directory in '%temporary-home-directory'.
+FILES-ALIST is an association list of files and the content of the
+corresponding file."
+  (define (create-file file content)
+    (let ((absolute-path (string-append %temporary-home-directory "/" file)))
+      (unless (file-exists? absolute-path)
+        (mkdir-p (pk (dirname absolute-path))))
+      (call-with-output-file (pk absolute-path)
+        (cut display content <>))))
+
+  (for-each (match-lambda
+              ((file . content) (create-file file content)))
+            (pk files-alist)))
+
+;; Copied from (guix profiles)
+(define (version-spec entry)
+  (let ((name (manifest-entry-name entry)))
+    (match (map package-version (find-packages-by-name name))
+      ((_)
+       ;; A single version of NAME is available, so do not specify the
+       ;; version number, even if the available version doesn't match ENTRY.
+       "")
+      (versions
+       ;; If ENTRY uses the latest version, don't specify any version.
+       ;; Otherwise return the shortest unique version prefix.  Note that
+       ;; this is based on the currently available packages, which could
+       ;; differ from the packages available in the revision that was used
+       ;; to build MANIFEST.
+       (let ((current (manifest-entry-version entry)))
+         (if (every (cut version>? current <>)
+                    (delete current versions))
+             ""
+             (version-unique-prefix (manifest-entry-version entry)
+                                    versions)))))))
+
+(define (eval-test-with-home-environment files-alist manifest matcher)
+  (create-temporary-home files-alist)
+  (setenv "HOME" %temporary-home-directory)
+  (mkdir-p %temporary-home-directory)
+  (let* ((home-environment (manifest->code manifest
+                                           #:entry-package-version version-spec
+                                           #:home-environment? #t))
+         (result (matcher home-environment)))
+    (delete-file-recursively %temporary-home-directory)
+    result))
+
+(define-home-environment-matcher match-home-environment-no-services
+  ('begin
+    ('use-modules
+     ('gnu 'home)
+     ('gnu 'packages))
+    ('home-environment
+     ('packages
+      ('map 'specification->package
+            ('list "guile <at> 2.0.9" "gcc" "glibc <at> 2.19")))
+     ('services
+      ('list)))))
+
+(define-home-environment-matcher match-home-environment-no-services-nor-packages
+  ('begin
+    ('use-modules
+     ('gnu 'home)
+     ('gnu 'packages))
+    ('home-environment
+     ('packages
+      ('map 'specification->package
+            ('list)))
+     ('services
+      ('list)))))
+
+(define-home-environment-matcher match-home-environment-bash-service
+  ('begin
+    ('use-modules
+     ('gnu 'home)
+     ('gnu 'packages)
+     ('gnu 'home 'services 'shells))
+    ('home-environment
+     ('packages
+      ('map 'specification->package
+            ('list)))
+     ('services
+      ('list ('service
+              'home-bash-service-type
+              ('home-bash-configuration
+               ('bashrc
+                ('list ('local-file "/tmp/guix-config/.bashrc"))))))))))
+
+(test-assert "manifest->code: No services"
+  (eval-test-with-home-environment
+   '()
+   (make-manifest (list guile-2.0.9 gcc glibc))
+   match-home-environment-no-services))
+
+(test-assert "manifest->code: No packages nor services"
+  (eval-test-with-home-environment
+   '()
+   (make-manifest '())
+   match-home-environment-no-services-nor-packages))
+
+(test-assert "manifest->code: Bash service"
+  (eval-test-with-home-environment
+   '((".bashrc" . "echo 'hello guix'"))
+   (make-manifest '())
+   match-home-environment-bash-service))
+
+(test-end "home-import")
-- 
2.33.0







Information forwarded to guix-patches <at> gnu.org:
bug#50873; Package guix-patches. (Mon, 11 Oct 2021 13:01:02 GMT) Full text and rfc822 format available.

Message #74 received at 50873 <at> debbugs.gnu.org (full text, mbox):

From: Oleg Pykhalov <go.wigust <at> gmail.com>
To: Xinglu Chen <public <at> yoctocell.xyz>
Cc: Ludovic Courtès <ludo <at> gnu.org>, 50873 <at> debbugs.gnu.org,
 Andrew Tropin <andrew <at> trop.in>
Subject: Re: bug#50873: [PATCH 0/5] Fixes to ‘guix home
 import’
Date: Mon, 11 Oct 2021 16:00:43 +0300
[Message part 1 (text/plain, inline)]
Hi,

Xinglu Chen <public <at> yoctocell.xyz> writes:

[…]

> +;; Helpers for checking and generating home environments.
> +
> +(%destination-directory "/tmp/guix-config")
> +(mkdir-p (%destination-directory))
> +
> +(define %temporary-home-directory "/tmp/guix-home-import-test")

Better use temporary directory like in tests/opam.scm.

--8<---------------cut here---------------start------------->8---
(define-module ...
  #:use-module ((guix build syscalls) #:select (mkdtemp!))
  ...)

(mkdtemp! "/tmp/guix-home-import-test.XXXXXX")
--8<---------------cut here---------------end--------------->8---

> +
> +(define-syntax-rule (define-home-environment-matcher name pattern)
> +  (define (name obj)
> +    (match obj
> +      (pattern #t)
> +      (x (pk 'fail x #f)))))
> +
> +(define (create-temporary-home files-alist)
> +  "Create a temporary home directory in '%temporary-home-directory'.
> +FILES-ALIST is an association list of files and the content of the
> +corresponding file."
> +  (define (create-file file content)
> +    (let ((absolute-path (string-append %temporary-home-directory "/" file)))
> +      (unless (file-exists? absolute-path)
> +        (mkdir-p (pk (dirname absolute-path))))
> +      (call-with-output-file (pk absolute-path)
> +        (cut display content <>))))

Do we need those 'pk' calls?

[…]

> +(define-home-environment-matcher match-home-environment-bash-service
> +  ('begin
> +    ('use-modules
> +     ('gnu 'home)
> +     ('gnu 'packages)
> +     ('gnu 'home 'services 'shells))
> +    ('home-environment
> +     ('packages
> +      ('map 'specification->package
> +            ('list)))
> +     ('services
> +      ('list ('service
> +              'home-bash-service-type
> +              ('home-bash-configuration
> +               ('bashrc
> +                ('list ('local-file "/tmp/guix-config/.bashrc"))))))))))

We should use '%temporary-home-directory' if we use 'mkdtemp!'.

> +
> +(test-assert "manifest->code: No services"
> +  (eval-test-with-home-environment
> +   '()
> +   (make-manifest (list guile-2.0.9 gcc glibc))
> +   match-home-environment-no-services))
> +
> +(test-assert "manifest->code: No packages nor services"
> +  (eval-test-with-home-environment
> +   '()
> +   (make-manifest '())
> +   match-home-environment-no-services-nor-packages))
> +
> +(test-assert "manifest->code: Bash service"
> +  (eval-test-with-home-environment
> +   '((".bashrc" . "echo 'hello guix'"))
> +   (make-manifest '())
> +   match-home-environment-bash-service))
> +
> +(test-end "home-import")

I tried to use 'guix home import /tmp/foo', where '/tmp/foo' is an empty
directory.  Then a pasted the generated code to '/tmp/foo/home.scm'
file.

--8<---------------cut here---------------start------------->8---
oleg <at> guixsd ~/src/guix [env]$ ./pre-inst-env guix home build /tmp/foo/home.scm
/tmp/foo/home.scm:487:11: error: service: unbound variable
hint: Did you forget `(use-modules (gnu services))'?
--8<---------------cut here---------------end--------------->8---

OK, added missing (use-modules (gnu services)).

--8<---------------cut here---------------start------------->8---
oleg <at> guixsd ~/src/guix [env]$ ./pre-inst-env guix home build /tmp/foo/home.scm
/tmp/foo/home.scm:491:29: error: local-file: unbound variable
hint: Did you forget `(use-modules (guix gexp))'?
--8<---------------cut here---------------end--------------->8---

OK, added missing (use-modules (guix gexp))

--8<---------------cut here---------------start------------->8---
oleg <at> guixsd ~/src/guix [env]$
oleg <at> guixsd ~/src/guix [env]$ ./pre-inst-env guix home build /tmp/foo/home.scm
guix home: error: invalid name: `.bashrc'
--8<---------------cut here---------------end--------------->8---

Now, I need to rename .bashrc to dot-bashrc and .bash_profile to
dot-bash_profile.  Maybe we should save all dot file with a 'dot-'
prefix by default?

Oleg.
[signature.asc (application/pgp-signature, inline)]

Information forwarded to guix-patches <at> gnu.org:
bug#50873; Package guix-patches. (Wed, 13 Oct 2021 09:25:01 GMT) Full text and rfc822 format available.

Message #77 received at 50873 <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: Xinglu Chen <public <at> yoctocell.xyz>
Cc: Oleg Pykhalov <go.wigust <at> gmail.com>, 50873 <at> debbugs.gnu.org,
 Andrew Tropin <andrew <at> trop.in>
Subject: Re: bug#50873: [PATCH 0/5] Fixes to ‘guix home
 import’
Date: Wed, 13 Oct 2021 11:24:00 +0200
Hello,

Xinglu Chen <public <at> yoctocell.xyz> skribis:

> Copy the appropriate the relevant configuration files to the destination
> directory, and call ‘local-file’ on them.
>
> Without this, ‘guix home import’ will generate a service declaration like this
>
>   (service
>    home-bash-service-type
>    (home-bash-configuration
>     (bashrc
>      (list (slurp-file-gexp
>             (local-file "/home/yoctocell/.bashrc"))))))
>
> but when running ‘guix home reconfigure’, the ~/.bashrc file would be moved, so
> when running ‘guix home reconfigure’ for the second time, it would read the
> ~/.bashrc which is itself a symlink to a file the store.

Ooh, good catch!

> * guix/scripts/home/import.scm (%destination-directory): New parameter.
> (generate-bash-module+configuration): Adjust accordingly.
> (modules+configurations): Copy the user’s configuration file to
> ‘%destination-directory’.
> * guix/scripts/home.scm (process-command): Adjust accordingly; create
> ‘%destination-directory’ if it doesn’t exist.

[...]

> +(define %destination-directory
> +  (make-parameter (string-append (getenv "HOME") "/src/guix-config")))

Instead of making it a parameter, with a default value that looks fishy
but is never actually used :-), can we make it an explicit parameter of
‘generate-bash-module+configuration’?

Otherwise LGTM!

Thanks,
Ludo’.




Information forwarded to guix-patches <at> gnu.org:
bug#50873; Package guix-patches. (Wed, 13 Oct 2021 09:27:02 GMT) Full text and rfc822 format available.

Message #80 received at 50873 <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: Oleg Pykhalov <go.wigust <at> gmail.com>
Cc: 50873 <at> debbugs.gnu.org, Xinglu Chen <public <at> yoctocell.xyz>,
 Andrew Tropin <andrew <at> trop.in>
Subject: Re: bug#50873: [PATCH 0/5] Fixes to ‘guix home
 import’
Date: Wed, 13 Oct 2021 11:25:50 +0200
Hi Xinglu and all!

It all LGTM, except for the issues that Oleg reports.

Xinglu, could you send one last version of this patch series addressing
Oleg’s comments?

Thanks,
Ludo’.




Information forwarded to guix-patches <at> gnu.org:
bug#50873; Package guix-patches. (Fri, 29 Oct 2021 07:37:01 GMT) Full text and rfc822 format available.

Message #83 received at 50873 <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: Oleg Pykhalov <go.wigust <at> gmail.com>
Cc: Xinglu Chen <public <at> yoctocell.xyz>, 50873 <at> debbugs.gnu.org,
 Andrew Tropin <andrew <at> trop.in>
Subject: Re: bug#50873: [PATCH 0/5] Fixes to ‘guix home
 import’
Date: Fri, 29 Oct 2021 09:36:33 +0200
Hello!

It’s been a month already.  Oleg, perhaps you could make those final
modifications on behalf on Xinglu so we can move forward?  We’re almost
there!

Thanks,
Ludo’.

Ludovic Courtès <ludo <at> gnu.org> skribis:

> Hi Xinglu and all!
>
> It all LGTM, except for the issues that Oleg reports.
>
> Xinglu, could you send one last version of this patch series addressing
> Oleg’s comments?
>
> Thanks,
> Ludo’.




Information forwarded to guix-patches <at> gnu.org:
bug#50873; Package guix-patches. (Fri, 29 Oct 2021 13:38:02 GMT) Full text and rfc822 format available.

Message #86 received at 50873 <at> debbugs.gnu.org (full text, mbox):

From: Xinglu Chen <public <at> yoctocell.xyz>
To: Ludovic Courtès <ludo <at> gnu.org>
Cc: Oleg Pykhalov <go.wigust <at> gmail.com>, 50873 <at> debbugs.gnu.org,
 Andrew Tropin <andrew <at> trop.in>
Subject: Re: bug#50873: [PATCH 0/5] Fixes to ‘guix home
 import’
Date: Fri, 29 Oct 2021 15:37:03 +0200
[Message part 1 (text/plain, inline)]
Hi, (sorry for taking so long to get to this!)

On Wed, Oct 13 2021, Ludovic Courtès wrote:

> Hello,
>
> Xinglu Chen <public <at> yoctocell.xyz> skribis:
>
>> Copy the appropriate the relevant configuration files to the destination
>> directory, and call ‘local-file’ on them.
>>
>> Without this, ‘guix home import’ will generate a service declaration like this
>>
>>   (service
>>    home-bash-service-type
>>    (home-bash-configuration
>>     (bashrc
>>      (list (slurp-file-gexp
>>             (local-file "/home/yoctocell/.bashrc"))))))
>>
>> but when running ‘guix home reconfigure’, the ~/.bashrc file would be moved, so
>> when running ‘guix home reconfigure’ for the second time, it would read the
>> ~/.bashrc which is itself a symlink to a file the store.
>
> Ooh, good catch!
>
>> * guix/scripts/home/import.scm (%destination-directory): New parameter.
>> (generate-bash-module+configuration): Adjust accordingly.
>> (modules+configurations): Copy the user’s configuration file to
>> ‘%destination-directory’.
>> * guix/scripts/home.scm (process-command): Adjust accordingly; create
>> ‘%destination-directory’ if it doesn’t exist.
>
> [...]
>
>> +(define %destination-directory
>> +  (make-parameter (string-append (getenv "HOME") "/src/guix-config")))
>
> Instead of making it a parameter, with a default value that looks fishy
> but is never actually used :-), can we make it an explicit parameter of
> ‘generate-bash-module+configuration’?

Ah, that would be a good idea.  :-)
  
[signature.asc (application/pgp-signature, inline)]

Information forwarded to guix-patches <at> gnu.org:
bug#50873; Package guix-patches. (Fri, 29 Oct 2021 13:49:02 GMT) Full text and rfc822 format available.

Message #89 received at 50873 <at> debbugs.gnu.org (full text, mbox):

From: Xinglu Chen <public <at> yoctocell.xyz>
To: Oleg Pykhalov <go.wigust <at> gmail.com>
Cc: Ludovic Courtès <ludo <at> gnu.org>, 50873 <at> debbugs.gnu.org,
 Andrew Tropin <andrew <at> trop.in>
Subject: Re: bug#50873: [PATCH 0/5] Fixes to ‘guix home
 import’
Date: Fri, 29 Oct 2021 15:47:51 +0200
[Message part 1 (text/plain, inline)]
On Mon, Oct 11 2021, Oleg Pykhalov wrote:

> Hi,
>
> Xinglu Chen <public <at> yoctocell.xyz> writes:
>
> […]
>
>> +;; Helpers for checking and generating home environments.
>> +
>> +(%destination-directory "/tmp/guix-config")
>> +(mkdir-p (%destination-directory))
>> +
>> +(define %temporary-home-directory "/tmp/guix-home-import-test")
>
> Better use temporary directory like in tests/opam.scm.
>
> --8<---------------cut here---------------start------------->8---
> (define-module ...
>   #:use-module ((guix build syscalls) #:select (mkdtemp!))
>   ...)
>
> (mkdtemp! "/tmp/guix-home-import-test.XXXXXX")
> --8<---------------cut here---------------end--------------->8---

Good idea.  Out of curiosity: is there any difference between ‘mkdtemp!’
and ‘mkdtemp’ that’s part of Guile?

>> +
>> +(define-syntax-rule (define-home-environment-matcher name pattern)
>> +  (define (name obj)
>> +    (match obj
>> +      (pattern #t)
>> +      (x (pk 'fail x #f)))))
>> +
>> +(define (create-temporary-home files-alist)
>> +  "Create a temporary home directory in '%temporary-home-directory'.
>> +FILES-ALIST is an association list of files and the content of the
>> +corresponding file."
>> +  (define (create-file file content)
>> +    (let ((absolute-path (string-append %temporary-home-directory "/" file)))
>> +      (unless (file-exists? absolute-path)
>> +        (mkdir-p (pk (dirname absolute-path))))
>> +      (call-with-output-file (pk absolute-path)
>> +        (cut display content <>))))
>
> Do we need those 'pk' calls?

Nope, just some leftover stuff that I forgot to remove…

>> +(define-home-environment-matcher match-home-environment-bash-service
>> +  ('begin
>> +    ('use-modules
>> +     ('gnu 'home)
>> +     ('gnu 'packages)
>> +     ('gnu 'home 'services 'shells))
>> +    ('home-environment
>> +     ('packages
>> +      ('map 'specification->package
>> +            ('list)))
>> +     ('services
>> +      ('list ('service
>> +              'home-bash-service-type
>> +              ('home-bash-configuration
>> +               ('bashrc
>> +                ('list ('local-file "/tmp/guix-config/.bashrc"))))))))))
>
> We should use '%temporary-home-directory' if we use 'mkdtemp!'.

I don’t think so, the ‘bashrc’ file will be copied _from_
‘%temporary-home-directory’ to ‘%destination-directory’, so this should
be ‘%destination-directory’.

>> +
>> +(test-assert "manifest->code: No services"
>> +  (eval-test-with-home-environment
>> +   '()
>> +   (make-manifest (list guile-2.0.9 gcc glibc))
>> +   match-home-environment-no-services))
>> +
>> +(test-assert "manifest->code: No packages nor services"
>> +  (eval-test-with-home-environment
>> +   '()
>> +   (make-manifest '())
>> +   match-home-environment-no-services-nor-packages))
>> +
>> +(test-assert "manifest->code: Bash service"
>> +  (eval-test-with-home-environment
>> +   '((".bashrc" . "echo 'hello guix'"))
>> +   (make-manifest '())
>> +   match-home-environment-bash-service))
>> +
>> +(test-end "home-import")
>
> I tried to use 'guix home import /tmp/foo', where '/tmp/foo' is an empty
> directory.  Then a pasted the generated code to '/tmp/foo/home.scm'
> file.
>
> --8<---------------cut here---------------start------------->8---
> oleg <at> guixsd ~/src/guix [env]$ ./pre-inst-env guix home build /tmp/foo/home.scm
> /tmp/foo/home.scm:487:11: error: service: unbound variable
> hint: Did you forget `(use-modules (gnu services))'?
> --8<---------------cut here---------------end--------------->8---
>
> OK, added missing (use-modules (gnu services)).
>
> --8<---------------cut here---------------start------------->8---
> oleg <at> guixsd ~/src/guix [env]$ ./pre-inst-env guix home build /tmp/foo/home.scm
> /tmp/foo/home.scm:491:29: error: local-file: unbound variable
> hint: Did you forget `(use-modules (guix gexp))'?
> --8<---------------cut here---------------end--------------->8---
>
> OK, added missing (use-modules (guix gexp))
>
> --8<---------------cut here---------------start------------->8---
> oleg <at> guixsd ~/src/guix [env]$
> oleg <at> guixsd ~/src/guix [env]$ ./pre-inst-env guix home build /tmp/foo/home.scm
> guix home: error: invalid name: `.bashrc'
> --8<---------------cut here---------------end--------------->8---
>
> Now, I need to rename .bashrc to dot-bashrc and .bash_profile to
> dot-bash_profile.  Maybe we should save all dot file with a 'dot-'
> prefix by default?

Ah, thanks for catching this!  I think it would be better to call
‘local-file’ with the optional ‘name’ argument like this:

  (local-file "/some/path/.bashrc" "bashrc")

That also means that the “/some/path/” part won’t end up as part of the
/gnu/store/… file name.
[signature.asc (application/pgp-signature, inline)]

Information forwarded to guix-patches <at> gnu.org:
bug#50873; Package guix-patches. (Sat, 30 Oct 2021 10:43:01 GMT) Full text and rfc822 format available.

Message #92 received at 50873 <at> debbugs.gnu.org (full text, mbox):

From: Xinglu Chen <public <at> yoctocell.xyz>
To: 50873 <at> debbugs.gnu.org, Oleg Pykhalov <go.wigust <at> gmail.com>, Andrew
 Tropin <andrew <at> trop.in>, Ludovic Courtès <ludo <at> gnu.org>
Subject: [PATCH v3 0/8] Fixes to ‘guix home
 import’
Date: Sat, 30 Oct 2021 12:42:21 +0200
[Message part 1 (text/plain, inline)]
Changes since v2:

* Call ‘local-file’ with a ‘name’ argument to make the /gnu/store/… file
  name more readable.

* Import some missing modules.

* Remove the ‘%destination-directory’ parameter, and instead pass the
  directory to ‘generate-bash-configuration+modules’.

* Other minor cleanups.

Xinglu Chen (8):
  guix home: import: Make the user to specify a destination directory.
  guix home: import: Allow multiple modules to be imported for each
    service.
  guix home: import: Fix module name for Bash service.
  guix home: import: Don’t use 'slurp-file-gexp'.
  guix home: import: Delete duplicate modules when importing.
  doc: Document the ‘guix home import’ subcommand.
  Add tests for ‘guix home import’.
  guix home: import: Call ‘local-file’ with ‘name’ argument.

 Makefile.am                  |   1 +
 doc/guix.texi                |  32 +++++++
 guix/scripts/home.scm        |  24 +++--
 guix/scripts/home/import.scm | 137 ++++++++++++++++----------
 tests/home-import.scm        | 180 +++++++++++++++++++++++++++++++++++
 5 files changed, 313 insertions(+), 61 deletions(-)
 create mode 100644 tests/home-import.scm


base-commit: c6adc0947396daa6d85ab08837f9cbc86f4d8722
-- 
2.33.0



[signature.asc (application/pgp-signature, inline)]

Information forwarded to guix-patches <at> gnu.org:
bug#50873; Package guix-patches. (Sat, 30 Oct 2021 10:43:02 GMT) Full text and rfc822 format available.

Message #95 received at 50873 <at> debbugs.gnu.org (full text, mbox):

From: Xinglu Chen <public <at> yoctocell.xyz>
To: 50873 <at> debbugs.gnu.org, Oleg Pykhalov <go.wigust <at> gmail.com>, Andrew
 Tropin <andrew <at> trop.in>, Ludovic Courtès <ludo <at> gnu.org>
Subject: [PATCH v3 1/8] guix home: import: Make the user to specify a
 destination directory.
Date: Sat, 30 Oct 2021 12:42:27 +0200
Copy the appropriate the relevant configuration files to the destination
directory, and call ‘local-file’ on them.

Without this, ‘guix home import’ will generate a service declaration like this

  (service
   home-bash-service-type
   (home-bash-configuration
    (bashrc
     (list (slurp-file-gexp
            (local-file "/home/yoctocell/.bashrc"))))))

but when running ‘guix home reconfigure’, the ~/.bashrc file would be moved, so
when running ‘guix home reconfigure’ for the second time, it would read the
~/.bashrc which is itself a symlink to a file the store.

* guix/scripts/home/import.scm (generate-bash-module+configuration): Take
‘destination-directory’ parameter
(modules+configurations): Copy the user’s configuration file to
‘%destination-directory’.
* guix/scripts/home.scm (process-command): Adjust accordingly; create
‘destination’ if it doesn’t exist.
---
 guix/scripts/home.scm        | 24 ++++++----
 guix/scripts/home/import.scm | 86 +++++++++++++++++++++---------------
 2 files changed, 65 insertions(+), 45 deletions(-)

diff --git a/guix/scripts/home.scm b/guix/scripts/home.scm
index 55e7b436c1..3f48b98ed4 100644
--- a/guix/scripts/home.scm
+++ b/guix/scripts/home.scm
@@ -40,6 +40,7 @@ (define-module (guix scripts home)
   #:autoload   (guix scripts pull) (channel-commit-hyperlink)
   #:use-module (guix scripts home import)
   #:use-module ((guix status) #:select (with-status-verbosity))
+  #:use-module ((guix build utils) #:select (mkdir-p))
   #:use-module (guix gexp)
   #:use-module (guix monads)
   #:use-module (srfi srfi-1)
@@ -260,15 +261,20 @@ (define-syntax-rule (with-store* store exp ...)
      (apply search args))
     ((import)
      (let* ((profiles (delete-duplicates
-                      (match (filter-map (match-lambda
-                                           (('profile . p) p)
-                                           (_              #f))
-                                         opts)
-                        (() (list %current-profile))
-                        (lst (reverse lst)))))
-           (manifest (concatenate-manifests
-                      (map profile-manifest profiles))))
-       (import-manifest manifest (current-output-port))))
+                       (match (filter-map (match-lambda
+                                            (('profile . p) p)
+                                            (_              #f))
+                                          opts)
+                         (() (list %current-profile))
+                         (lst (reverse lst)))))
+            (manifest (concatenate-manifests
+                       (map profile-manifest profiles)))
+            (destination (match args
+                           ((destination) destination)
+                           (_ (leave (G_ "wrong number of arguments~%"))))))
+       (unless (file-exists? destination)
+         (mkdir-p destination))
+       (import-manifest manifest destination (current-output-port))))
     ((describe)
      (match (generation-number %guix-home)
        (0
diff --git a/guix/scripts/home/import.scm b/guix/scripts/home/import.scm
index 611f580e85..c7c60e95e8 100644
--- a/guix/scripts/home/import.scm
+++ b/guix/scripts/home/import.scm
@@ -36,49 +36,61 @@ (define-module (guix scripts home import)
 ;;;
 ;;; Code:
 
+(define (generate-bash-configuration+modules destination-directory)
+  (define (destination-append path)
+    (string-append destination-directory "/" path))
 
-(define (generate-bash-module+configuration)
-  (let ((rc (string-append (getenv "HOME") "/.bashrc"))
-        (profile (string-append (getenv "HOME") "/.bash_profile"))
-        (logout (string-append (getenv "HOME") "/.bash_logout")))
-    `((gnu home services bash)
+  (let ((rc (destination-append ".bashrc"))
+        (profile (destination-append ".bash_profile"))
+        (logout (destination-append ".bash_logout")))
+    `((gnu home-services bash)
       (service home-bash-service-type
-                 (home-bash-configuration
-                  ,@(if (file-exists? rc)
-                        `((bashrc
-                           (list (local-file ,rc))))
-                        '())
-                  ,@(if (file-exists? profile)
-                        `((bash-profile
-                           (list (local-file ,profile))))
-                        '())
-                  ,@(if (file-exists? logout)
-                        `((bash-logout
-                           (list (local-file ,logout))))
-                        '()))))))
-
+               (home-bash-configuration
+                ,@(if (file-exists? rc)
+                      `((bashrc
+                         (list (slurp-file-gexp
+                                (local-file ,rc)))))
+                      '())
+                ,@(if (file-exists? profile)
+                      `((bash-profile
+                         (list (slurp-file-gexp
+                                (local-file ,profile)))))
+                      '())
+                ,@(if (file-exists? logout)
+                      `((bash-logout
+                         (list (slurp-file-gexp
+                                (local-file ,logout)))))
+                      '()))))))
 
 (define %files-configurations-alist
   `((".bashrc" . ,generate-bash-module+configuration)
     (".bash_profile" . ,generate-bash-module+configuration)
     (".bash_logout" . ,generate-bash-module+configuration)))
 
-(define (modules+configurations)
-  (let ((configurations (delete-duplicates
-                         (filter-map (match-lambda
-                                ((file . proc)
-                                 (if (file-exists?
-                                      (string-append (getenv "HOME") "/" file))
-                                     proc
-                                     #f)))
-                                     %files-configurations-alist)
-                         (lambda (x y)
-                           (equal? (procedure-name x) (procedure-name y))))))
-    (map (lambda (proc) (proc)) configurations)))
+(define (configurations+modules destination-directory)
+  "Return a list of procedures which when called, generate code for a home
+service declaration."
+  (define configurations
+    (delete-duplicates
+     (filter-map (match-lambda
+                   ((file . proc)
+                    (let ((absolute-path (string-append (getenv "HOME")
+                                                        "/" file)))
+                      (and (file-exists? absolute-path)
+                           (begin
+                             (copy-file absolute-path
+                                        (string-append
+                                         destination-directory "/" file))
+                             proc)))))
+                 %files+configurations-alist)
+     (lambda (x y)
+       (equal? (procedure-name x) (procedure-name y)))))
+  
+  (map (lambda (proc) (proc destination-directory)) configurations))
 
 ;; Based on `manifest->code' from (guix profiles)
 ;; MAYBE: Upstream it?
-(define* (manifest->code manifest
+(define* (manifest->code manifest destination-directory
                          #:key
                          (entry-package-version (const ""))
                          (home-environment? #f))
@@ -129,7 +141,8 @@ (define (qualified-name entry)
                                                    ":" output))))
                         (manifest-entries manifest))))
         (if home-environment?
-            (let ((modules+configurations (modules+configurations)))
+            (let ((configurations+modules
+                   (configurations+modules destination-directory)))
               `(begin
                (use-modules (gnu home)
                             (gnu packages)
@@ -171,7 +184,8 @@ (define name
                              (options->transformation ',options))))
                        transformation-procedures)))
         (if home-environment?
-            (let ((modules+configurations (modules+configurations)))
+            (let ((configurations+modules
+                   (configurations+modules destination-directory)))
               `(begin
                  (use-modules (guix transformations)
                               (gnu home)
@@ -204,7 +218,7 @@ (define* (home-environment-template #:key (packages #f) (specs #f) services)
      (services (list ,@services))))
 
 (define* (import-manifest
-          manifest
+          manifest destination-directory
           #:optional (port (current-output-port)))
   "Write to PORT a <home-environment> corresponding to MANIFEST."
   (define (version-spec entry)
@@ -227,7 +241,7 @@ (define (version-spec entry)
                (version-unique-prefix (manifest-entry-version entry)
                                       versions)))))))
 
-  (match (manifest->code manifest
+  (match (manifest->code manifest destination-directory
                          #:entry-package-version version-spec
                          #:home-environment? #t)
     (('begin exp ...)
-- 
2.33.0







Information forwarded to guix-patches <at> gnu.org:
bug#50873; Package guix-patches. (Sat, 30 Oct 2021 10:43:02 GMT) Full text and rfc822 format available.

Message #98 received at 50873 <at> debbugs.gnu.org (full text, mbox):

From: Xinglu Chen <public <at> yoctocell.xyz>
To: 50873 <at> debbugs.gnu.org, Oleg Pykhalov <go.wigust <at> gmail.com>, Andrew
 Tropin <andrew <at> trop.in>, Ludovic Courtès <ludo <at> gnu.org>
Subject: [PATCH v3 2/8] guix home: import: Allow multiple modules to be
 imported for each service.
Date: Sat, 30 Oct 2021 12:42:32 +0200
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 | 34 +++++++++++++++++++---------------
 1 file changed, 19 insertions(+), 15 deletions(-)

diff --git a/guix/scripts/home/import.scm b/guix/scripts/home/import.scm
index c7c60e95e8..533abdbb8d 100644
--- a/guix/scripts/home/import.scm
+++ b/guix/scripts/home/import.scm
@@ -43,8 +43,7 @@ (define (destination-append 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
@@ -60,12 +59,15 @@ (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 %files+configurations-alist
+  `((".bashrc" . ,generate-bash-configuration+modules)
+    (".bash_profile" . ,generate-bash-configuration+modules)
+    (".bash_logout" . ,generate-bash-configuration+modules)))
 
 (define (configurations+modules destination-directory)
   "Return a list of procedures which when called, generate code for a home
@@ -144,12 +146,13 @@ (define (qualified-name entry)
             (let ((configurations+modules
                    (configurations+modules destination-directory)))
               `(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)
+                              (gnu services)
+                              ,@(concatenate (map cdr configurations+modules)))
+                 ,(home-environment-template
+                   #:specs specs
+                   #:services (map first configurations+modules))))
             `(begin
                (use-modules (gnu packages))
 
@@ -190,13 +193,14 @@ (define name
                  (use-modules (guix transformations)
                               (gnu home)
                               (gnu packages)
-                              ,@(map first modules+configurations))
+                              (gnu services)
+                              ,@(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))
-- 
2.33.0







Information forwarded to guix-patches <at> gnu.org:
bug#50873; Package guix-patches. (Sat, 30 Oct 2021 10:43:03 GMT) Full text and rfc822 format available.

Message #101 received at 50873 <at> debbugs.gnu.org (full text, mbox):

From: Xinglu Chen <public <at> yoctocell.xyz>
To: 50873 <at> debbugs.gnu.org, Oleg Pykhalov <go.wigust <at> gmail.com>, Andrew
 Tropin <andrew <at> trop.in>, Ludovic Courtès <ludo <at> gnu.org>
Subject: [PATCH v3 6/8] doc: Document the ‘guix home import’ subcommand.
Date: Sat, 30 Oct 2021 12:42:39 +0200
* doc/guix.texi (Invoking guix home): Document ‘guix home import’.
---
 doc/guix.texi | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)

diff --git a/doc/guix.texi b/doc/guix.texi
index 22215214e0..3c069912cb 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -36509,6 +36509,38 @@
 $ guix home list-generations 10d
 @end example
 
+@item import
+Generate a @dfn{home environment} from the packages in the default
+profile and configuration files found in the user's home directory.  The
+configuration files will be copied to the specified directory.  Note
+that not every home service that exists is supported (@pxref{Home
+Services}).
+
+@example
+$ guix home import ~/guix-config
+;; This "home-environment" file can be passed to 'guix home reconfigure'
+;; to reproduce the content of your profile.  This is "symbolic": it only
+;; specifies package names.  To reproduce the exact same profile, you also
+;; need to capture the channels being used, as returned by "guix describe".
+;; See the "Replicating Guix" section in the manual.
+
+(use-modules
+  (gnu home)
+  (gnu packages)
+  (gnu home services shells))
+
+(home-environment
+  (packages
+    (map specification->package
+         (list "glibc-locales" "nss-certs" "nss")))
+  (services
+    (list (service
+            home-bash-service-type
+            (home-bash-configuration
+              (bashrc
+                (list (local-file "/tmp/guix-config/.bashrc"))))))))
+@end example
+
 @end table
 
 @var{options} can contain any of the common build options (@pxref{Common
-- 
2.33.0







Information forwarded to guix-patches <at> gnu.org:
bug#50873; Package guix-patches. (Sat, 30 Oct 2021 10:43:03 GMT) Full text and rfc822 format available.

Message #104 received at 50873 <at> debbugs.gnu.org (full text, mbox):

From: Xinglu Chen <public <at> yoctocell.xyz>
To: 50873 <at> debbugs.gnu.org, Oleg Pykhalov <go.wigust <at> gmail.com>, Andrew
 Tropin <andrew <at> trop.in>, Ludovic Courtès <ludo <at> gnu.org>
Subject: [PATCH v3 3/8] guix home: import: Fix module name for Bash service.
Date: Sat, 30 Oct 2021 12:42:34 +0200
* guix/scripts/home/import.scm (generate-bash-configuration+modules): Change
(gnu home-services bash) to (gnu home-services shells); add (guix gexp).
---
 guix/scripts/home/import.scm | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/guix/scripts/home/import.scm b/guix/scripts/home/import.scm
index 533abdbb8d..f20088aa88 100644
--- a/guix/scripts/home/import.scm
+++ b/guix/scripts/home/import.scm
@@ -60,7 +60,8 @@ (define (destination-append path)
                          (list (slurp-file-gexp
                                 (local-file ,logout)))))
                       '())))
-      (gnu home-services bash))))
+      (guix gexp)
+      (gnu home services shells))))
 
 
 
-- 
2.33.0







Information forwarded to guix-patches <at> gnu.org:
bug#50873; Package guix-patches. (Sat, 30 Oct 2021 10:43:03 GMT) Full text and rfc822 format available.

Message #107 received at 50873 <at> debbugs.gnu.org (full text, mbox):

From: Xinglu Chen <public <at> yoctocell.xyz>
To: 50873 <at> debbugs.gnu.org, Oleg Pykhalov <go.wigust <at> gmail.com>, Andrew
 Tropin <andrew <at> trop.in>, Ludovic Courtès <ludo <at> gnu.org>
Subject: [PATCH v3 4/8] guix home: import: Don’t use 'slurp-file-gexp'.
Date: Sat, 30 Oct 2021 12:42:35 +0200
‘slurp-file-gexp’ is not a bound procedure.

* guix/scripts/home/import.scm (generate-bash-configuration+modules): Don’t
  use ‘slurp-file-gexp’.
---
 guix/scripts/home/import.scm | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/guix/scripts/home/import.scm b/guix/scripts/home/import.scm
index f20088aa88..0e7c454f45 100644
--- a/guix/scripts/home/import.scm
+++ b/guix/scripts/home/import.scm
@@ -47,24 +47,19 @@ (define (destination-append path)
                (home-bash-configuration
                 ,@(if (file-exists? rc)
                       `((bashrc
-                         (list (slurp-file-gexp
-                                (local-file ,rc)))))
+                         (list (local-file ,rc))))
                       '())
                 ,@(if (file-exists? profile)
                       `((bash-profile
-                         (list (slurp-file-gexp
-                                (local-file ,profile)))))
+                         (list (local-file ,profile))))
                       '())
                 ,@(if (file-exists? logout)
                       `((bash-logout
-                         (list (slurp-file-gexp
-                                (local-file ,logout)))))
+                         (list (local-file ,logout))))
                       '())))
       (guix gexp)
       (gnu home services shells))))
 
-
-
 (define %files+configurations-alist
   `((".bashrc" . ,generate-bash-configuration+modules)
     (".bash_profile" . ,generate-bash-configuration+modules)
-- 
2.33.0







Information forwarded to guix-patches <at> gnu.org:
bug#50873; Package guix-patches. (Sat, 30 Oct 2021 10:43:04 GMT) Full text and rfc822 format available.

Message #110 received at 50873 <at> debbugs.gnu.org (full text, mbox):

From: Xinglu Chen <public <at> yoctocell.xyz>
To: 50873 <at> debbugs.gnu.org, Oleg Pykhalov <go.wigust <at> gmail.com>, Andrew
 Tropin <andrew <at> trop.in>, Ludovic Courtès <ludo <at> gnu.org>
Subject: [PATCH v3 7/8] Add tests for ‘guix home import’.
Date: Sat, 30 Oct 2021 12:42:41 +0200
* tests/home-import.scm: New file.
* Makefile.am (SCM_TESTS): Add it.
---
 Makefile.am                  |   1 +
 guix/scripts/home/import.scm |   7 +-
 tests/home-import.scm        | 179 +++++++++++++++++++++++++++++++++++
 3 files changed, 186 insertions(+), 1 deletion(-)
 create mode 100644 tests/home-import.scm

diff --git a/Makefile.am b/Makefile.am
index 239387c2f4..d608b08899 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -475,6 +475,7 @@ SCM_TESTS =					\
   tests/graph.scm				\
   tests/gremlin.scm				\
   tests/hackage.scm				\
+  tests/home-import.scm				\
   tests/import-git.scm				\
   tests/import-utils.scm			\
   tests/inferior.scm				\
diff --git a/guix/scripts/home/import.scm b/guix/scripts/home/import.scm
index f0ae233b75..6e3ed065d5 100644
--- a/guix/scripts/home/import.scm
+++ b/guix/scripts/home/import.scm
@@ -27,7 +27,10 @@ (define-module (guix scripts home import)
   #:use-module (ice-9 pretty-print)
   #:use-module (srfi srfi-1)
   #:use-module (srfi srfi-26)
-  #:export (import-manifest))
+  #:export (import-manifest
+
+            ;; For tests.
+            manifest->code))
 
 ;;; Commentary:
 ;;;
@@ -36,6 +39,8 @@ (define-module (guix scripts home import)
 ;;;
 ;;; Code:
 
+
+
 (define (generate-bash-configuration+modules destination-directory)
   (define (destination-append path)
     (string-append destination-directory "/" path))
diff --git a/tests/home-import.scm b/tests/home-import.scm
new file mode 100644
index 0000000000..a4e71fa698
--- /dev/null
+++ b/tests/home-import.scm
@@ -0,0 +1,179 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2021 Xinglu Chen <public <at> yoctocell.xyz
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (test-home-import)
+  #:use-module (guix scripts home import)
+  #:use-module (guix utils)
+  #:use-module (guix build utils)
+  #:use-module (guix packages)
+  #:use-module (ice-9 match)
+  #:use-module ((guix profiles) #:hide (manifest->code))
+  #:use-module ((guix build syscalls) #:select (mkdtemp!))
+  #:use-module (gnu packages)
+  #:use-module (srfi srfi-1)
+  #:use-module (srfi srfi-26)
+  #:use-module (srfi srfi-64))
+
+;; Test the (guix scripts home import) tools.
+
+(test-begin "home-import")
+
+;; Example manifest entries.
+
+(define guile-2.0.9
+  (manifest-entry
+    (name "guile")
+    (version "2.0.9")
+    (item "/gnu/store/...")))
+
+(define glibc
+  (manifest-entry
+    (name "glibc")
+    (version "2.19")
+    (item "/gnu/store/...")))
+
+(define gcc
+  (manifest-entry
+    (name "gcc")
+    (version "10.3.0")
+    (item "/gnu/store/...")))
+
+;; Helpers for checking and generating home environments.
+
+(define %destination-directory "/tmp/guix-config")
+(mkdir-p %destination-directory)
+
+(define %temporary-home-directory (mkdtemp! "/tmp/guix-home-import.XXXXXX"))
+
+(define-syntax-rule (define-home-environment-matcher name pattern)
+  (define (name obj)
+    (match obj
+      (pattern #t)
+      (x (pk 'fail x #f)))))
+
+(define (create-temporary-home files-alist)
+  "Create a temporary home directory in '%temporary-home-directory'.
+FILES-ALIST is an association list of files and the content of the
+corresponding file."
+  (define (create-file file content)
+    (let ((absolute-path (string-append %temporary-home-directory "/" file)))
+      (unless (file-exists? absolute-path)
+        (mkdir-p (dirname absolute-path)))
+      (call-with-output-file absolute-path
+        (cut display content <>))))
+
+  (for-each (match-lambda
+              ((file . content) (create-file file content)))
+            files-alist))
+
+;; Copied from (guix profiles)
+(define (version-spec entry)
+  (let ((name (manifest-entry-name entry)))
+    (match (map package-version (find-packages-by-name name))
+      ((_)
+       ;; A single version of NAME is available, so do not specify the
+       ;; version number, even if the available version doesn't match ENTRY.
+       "")
+      (versions
+       ;; If ENTRY uses the latest version, don't specify any version.
+       ;; Otherwise return the shortest unique version prefix.  Note that
+       ;; this is based on the currently available packages, which could
+       ;; differ from the packages available in the revision that was used
+       ;; to build MANIFEST.
+       (let ((current (manifest-entry-version entry)))
+         (if (every (cut version>? current <>)
+                    (delete current versions))
+             ""
+             (version-unique-prefix (manifest-entry-version entry)
+                                    versions)))))))
+
+(define (eval-test-with-home-environment files-alist manifest matcher)
+  (create-temporary-home files-alist)
+  (setenv "HOME" %temporary-home-directory)
+  (mkdir-p %temporary-home-directory)
+  (let* ((home-environment (manifest->code manifest %destination-directory
+                                           #:entry-package-version version-spec
+                                           #:home-environment? #t))
+         (result (matcher home-environment)))
+    (delete-file-recursively %temporary-home-directory)
+    result))
+
+(define-home-environment-matcher match-home-environment-no-services
+  ('begin
+    ('use-modules
+     ('gnu 'home)
+     ('gnu 'packages)
+     ('gnu 'services))
+    ('home-environment
+     ('packages
+      ('map 'specification->package
+            ('list "guile <at> 2.0.9" "gcc" "glibc <at> 2.19")))
+     ('services
+      ('list)))))
+
+(define-home-environment-matcher match-home-environment-no-services-nor-packages
+  ('begin
+    ('use-modules
+     ('gnu 'home)
+     ('gnu 'packages)
+     ('gnu 'services))
+    ('home-environment
+     ('packages
+      ('map 'specification->package
+            ('list)))
+     ('services
+      ('list)))))
+
+(define-home-environment-matcher match-home-environment-bash-service
+  ('begin
+    ('use-modules
+     ('gnu 'home)
+     ('gnu 'packages)
+     ('gnu 'services)
+     ('guix 'gexp)
+     ('gnu 'home 'services 'shells))
+    ('home-environment
+     ('packages
+      ('map 'specification->package
+            ('list)))
+     ('services
+      ('list ('service
+              'home-bash-service-type
+              ('home-bash-configuration
+               ('bashrc
+                ('list ('local-file "/tmp/guix-config/.bashrc"))))))))))
+
+(test-assert "manifest->code: No services"
+  (eval-test-with-home-environment
+   '()
+   (make-manifest (list guile-2.0.9 gcc glibc))
+   match-home-environment-no-services))
+
+(test-assert "manifest->code: No packages nor services"
+  (eval-test-with-home-environment
+   '()
+   (make-manifest '())
+   match-home-environment-no-services-nor-packages))
+
+(test-assert "manifest->code: Bash service"
+  (eval-test-with-home-environment
+   '((".bashrc" . "echo 'hello guix'"))
+   (make-manifest '())
+   match-home-environment-bash-service))
+
+(test-end "home-import")
-- 
2.33.0







Information forwarded to guix-patches <at> gnu.org:
bug#50873; Package guix-patches. (Sat, 30 Oct 2021 10:43:04 GMT) Full text and rfc822 format available.

Message #113 received at 50873 <at> debbugs.gnu.org (full text, mbox):

From: Xinglu Chen <public <at> yoctocell.xyz>
To: 50873 <at> debbugs.gnu.org, Oleg Pykhalov <go.wigust <at> gmail.com>, Andrew
 Tropin <andrew <at> trop.in>, Ludovic Courtès <ludo <at> gnu.org>
Subject: [PATCH v3 5/8] guix home: import: Delete duplicate modules when
 importing.
Date: Sat, 30 Oct 2021 12:42:37 +0200
Two different services might require the same module(s), so delete duplicates
when generating the ‘use-modules’ form.

* import.scm (manifest->code): Delete duplicate modules.
---
 guix/scripts/home/import.scm | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/guix/scripts/home/import.scm b/guix/scripts/home/import.scm
index 0e7c454f45..f0ae233b75 100644
--- a/guix/scripts/home/import.scm
+++ b/guix/scripts/home/import.scm
@@ -145,7 +145,8 @@ (define (qualified-name entry)
                  (use-modules (gnu home)
                               (gnu packages)
                               (gnu services)
-                              ,@(concatenate (map cdr configurations+modules)))
+                              ,@((compose delete-duplicates concatenate)
+                                 (map cdr configurations+modules)))
                  ,(home-environment-template
                    #:specs specs
                    #:services (map first configurations+modules))))
@@ -190,7 +191,8 @@ (define name
                               (gnu home)
                               (gnu packages)
                               (gnu services)
-                              ,@(concatenate (map cdr configurations+modules)))
+                              ,@((compose delete-duplicates concatenate)
+                                 (map cdr configurations+modules)))
 
                  ,@transformations
 
-- 
2.33.0







Information forwarded to guix-patches <at> gnu.org:
bug#50873; Package guix-patches. (Sat, 30 Oct 2021 10:44:02 GMT) Full text and rfc822 format available.

Message #116 received at 50873 <at> debbugs.gnu.org (full text, mbox):

From: Xinglu Chen <public <at> yoctocell.xyz>
To: 50873 <at> debbugs.gnu.org, Oleg Pykhalov <go.wigust <at> gmail.com>, Andrew
 Tropin <andrew <at> trop.in>, Ludovic Courtès <ludo <at> gnu.org>
Subject: [PATCH v3 8/8] guix home: import: Call ‘local-file’ with ‘name’ 
Date: Sat, 30 Oct 2021 12:42:44 +0200
Set the name of the file to just the basename of the file passed to
‘local-file’.

* guix/scripts/home/import.scm (basename+remove-dots): New procedure.
(generate-bash-configuration+modules): Use it.
* tests/home-import.scm (match-home-environment-bash-service): Adjust
accordingly.
---
 guix/scripts/home/import.scm | 20 ++++++++++++++++----
 tests/home-import.scm        |  3 ++-
 2 files changed, 18 insertions(+), 5 deletions(-)

diff --git a/guix/scripts/home/import.scm b/guix/scripts/home/import.scm
index 6e3ed065d5..a0022458f6 100644
--- a/guix/scripts/home/import.scm
+++ b/guix/scripts/home/import.scm
@@ -39,7 +39,16 @@ (define-module (guix scripts home import)
 ;;;
 ;;; Code:
 
-
+(define (basename+remove-dots file-name)
+  "Remove the dot from the dotfile FILE-NAME; replace the other dots in
+FILE-NAME with \"-\", and return the basename of it."
+  (string-map (match-lambda
+                (#\. #\-)
+                (c c))
+              (let ((base (basename file-name)))
+                (if (string-prefix? "." base)
+                    (string-drop base 1)
+                    base))))
 
 (define (generate-bash-configuration+modules destination-directory)
   (define (destination-append path)
@@ -52,15 +61,18 @@ (define (destination-append path)
                (home-bash-configuration
                 ,@(if (file-exists? rc)
                       `((bashrc
-                         (list (local-file ,rc))))
+                         (list (local-file ,rc
+                                           ,(basename+remove-dots rc)))))
                       '())
                 ,@(if (file-exists? profile)
                       `((bash-profile
-                         (list (local-file ,profile))))
+                         (list (local-file ,profile
+                                           ,(basename+remove-dots profile)))))
                       '())
                 ,@(if (file-exists? logout)
                       `((bash-logout
-                         (list (local-file ,logout))))
+                         (list (local-file ,logout
+                                           ,(basename+remove-dots logout)))))
                       '())))
       (guix gexp)
       (gnu home services shells))))
diff --git a/tests/home-import.scm b/tests/home-import.scm
index a4e71fa698..d2f5728e3c 100644
--- a/tests/home-import.scm
+++ b/tests/home-import.scm
@@ -156,7 +156,8 @@ (define-home-environment-matcher match-home-environment-bash-service
               'home-bash-service-type
               ('home-bash-configuration
                ('bashrc
-                ('list ('local-file "/tmp/guix-config/.bashrc"))))))))))
+                ('list ('local-file "/tmp/guix-config/.bashrc"
+                                    "bashrc"))))))))))
 
 (test-assert "manifest->code: No services"
   (eval-test-with-home-environment
-- 
2.33.0







Information forwarded to guix-patches <at> gnu.org:
bug#50873; Package guix-patches. (Sat, 30 Oct 2021 11:51:01 GMT) Full text and rfc822 format available.

Message #119 received at 50873 <at> debbugs.gnu.org (full text, mbox):

From: Julien Lepiller <julien <at> lepiller.eu>
To: Xinglu Chen <public <at> yoctocell.xyz>
Cc: Oleg Pykhalov <go.wigust <at> gmail.com>,
 Ludovic Courtès <ludo <at> gnu.org>, 50873 <at> debbugs.gnu.org,
 Andrew Tropin <andrew <at> trop.in>
Subject: Re: [bug#50873] [PATCH v3 3/8] guix home: import: Fix module name
 for Bash service.
Date: Sat, 30 Oct 2021 13:50:29 +0200
Le Sat, 30 Oct 2021 12:42:34 +0200,
Xinglu Chen <public <at> yoctocell.xyz> a écrit :

> * guix/scripts/home/import.scm (generate-bash-configuration+modules):
> Change (gnu home-services bash) to (gnu home-services shells); add
> (guix gexp). ---
>  guix/scripts/home/import.scm | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/guix/scripts/home/import.scm
> b/guix/scripts/home/import.scm index 533abdbb8d..f20088aa88 100644
> --- a/guix/scripts/home/import.scm
> +++ b/guix/scripts/home/import.scm
> @@ -60,7 +60,8 @@ (define (destination-append path)
>                           (list (slurp-file-gexp
>                                  (local-file ,logout)))))
>                        '())))
> -      (gnu home-services bash))))
> +      (guix gexp)
> +      (gnu home services shells))))
>  
>  
>  

I got bit by this one yesterday, it's great you could fix it! :)




Information forwarded to guix-patches <at> gnu.org:
bug#50873; Package guix-patches. (Sat, 30 Oct 2021 14:18:01 GMT) Full text and rfc822 format available.

Message #122 received at 50873 <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: Xinglu Chen <public <at> yoctocell.xyz>
Cc: Oleg Pykhalov <go.wigust <at> gmail.com>, 50873 <at> debbugs.gnu.org,
 Andrew Tropin <andrew <at> trop.in>
Subject: Re: bug#50873: [PATCH 0/5] Fixes to ‘guix home
 import’
Date: Sat, 30 Oct 2021 16:17:02 +0200
Hi,

Xinglu Chen <public <at> yoctocell.xyz> skribis:

> On Mon, Oct 11 2021, Oleg Pykhalov wrote:
>
>> Hi,
>>
>> Xinglu Chen <public <at> yoctocell.xyz> writes:
>>
>> […]
>>
>>> +;; Helpers for checking and generating home environments.
>>> +
>>> +(%destination-directory "/tmp/guix-config")
>>> +(mkdir-p (%destination-directory))
>>> +
>>> +(define %temporary-home-directory "/tmp/guix-home-import-test")
>>
>> Better use temporary directory like in tests/opam.scm.
>>
>> --8<---------------cut here---------------start------------->8---
>> (define-module ...
>>   #:use-module ((guix build syscalls) #:select (mkdtemp!))
>>   ...)
>>
>> (mkdtemp! "/tmp/guix-home-import-test.XXXXXX")
>> --8<---------------cut here---------------end--------------->8---
>
> Good idea.  Out of curiosity: is there any difference between ‘mkdtemp!’
> and ‘mkdtemp’ that’s part of Guile?

‘mkdtemp’ is new in Guile 3.0.6 but Guix can be built with an older
version.

Ludo’.




Information forwarded to guix-patches <at> gnu.org:
bug#50873; Package guix-patches. (Sat, 30 Oct 2021 14:23:01 GMT) Full text and rfc822 format available.

Message #125 received at 50873 <at> debbugs.gnu.org (full text, mbox):

From: Liliana Marie Prikler <liliana.prikler <at> gmail.com>
To: Xinglu Chen <public <at> yoctocell.xyz>, 50873 <at> debbugs.gnu.org, Oleg Pykhalov
 <go.wigust <at> gmail.com>, Andrew Tropin <andrew <at> trop.in>, Ludovic
 Courtès <ludo <at> gnu.org>
Subject: Re: [PATCH v3 1/8] guix home: import: Make the user to specify a
 destination directory.
Date: Sat, 30 Oct 2021 16:22:14 +0200
Hi,

Am Samstag, den 30.10.2021, 12:42 +0200 schrieb Xinglu Chen:
> Copy the appropriate the relevant configuration files to the
> destination directory, and call ‘local-file’ on them.
The name "destination directory" (especially in the form destination-
directory) is both overly verbose and not really explanatory at all. 
Perhaps you might want to instead use "prefix" and have some reasonable
default like ~/.config/guix/home – alternatively, since all these files
are used in the same sense as /etc/skel, you could name it "skeleton"
with an explanation along the lines of

  Existing configuration will be copied to SKELETON (default 
  $HOME/.config/guix-home/skel).  The name of this folder can be 
  specified via --skeleton=DIRECTORY.  If --no-create-skeleton is 
  passed, /etc/skel will be used instead to at least initialize a bare-
  bones bash-service.

WDYT?





Information forwarded to guix-patches <at> gnu.org:
bug#50873; Package guix-patches. (Sat, 30 Oct 2021 23:02:01 GMT) Full text and rfc822 format available.

Message #128 received at 50873 <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: Xinglu Chen <public <at> yoctocell.xyz>
Cc: Oleg Pykhalov <go.wigust <at> gmail.com>, 50873 <at> debbugs.gnu.org,
 Andrew Tropin <andrew <at> trop.in>
Subject: Re: bug#50873: [PATCH 0/5] Fixes to ‘guix home
 import’
Date: Sun, 31 Oct 2021 01:01:30 +0200
Hi!

Xinglu Chen <public <at> yoctocell.xyz> skribis:

>   guix home: import: Make the user to specify a destination directory.
>   guix home: import: Allow multiple modules to be imported for each
>     service.
>   guix home: import: Fix module name for Bash service.
>   guix home: import: Don’t use 'slurp-file-gexp'.
>   guix home: import: Delete duplicate modules when importing.
>   doc: Document the ‘guix home import’ subcommand.
>   Add tests for ‘guix home import’.
>   guix home: import: Call ‘local-file’ with ‘name’ argument.

That’s a nice improvement.  In the interest of moving forward, I applied
the whole series and followed up with a few changes:

  c4ac8cf4f6 doc: Mention 'guix home reconfigure' upfront.
  971a69d8e3 doc: Avoid misuse of @ref.
  7711a6c3f4 doc: Mention "guix home import" upfront.
  6f4ca78761 home: import: Avoid duplication of 'manifest->code'.
  96728c54df home: import: Factorize triplicated 'version-spec' procedure.
  f3933ae40d home: import: Clarify "destination directory".
  341fba217f home: import: Compare procedures with 'eq?'.

Part of it is about removing duplicated code, in particular
‘manifest->code’.  It’s important to factorize non-trivial code like
this.

The last commits improve documentation so users learn about ‘guix home
import’ when they get started.

It’s really nice to have this tool!  I find it perhaps a bit confusing
to have to specify a target directory to ‘guix home import’; simply
trying to document it shows that it’s non-obvious.

I wonder if the argument should be optional (in which case the files
wouldn’t be copied).  But then people are likely to run into the
problems this addresses.

Or perhaps it would be more consistent to have:

  guix home import ~/foo

create ~/foo/config.scm, instead of printing it to stdout?

The documentation would be clearer: “populate ~/foo with all the
configuration files of your home environment.”  Thoughts?

Ludo’.




bug closed, send any further explanations to 50873 <at> debbugs.gnu.org and Xinglu Chen <public <at> yoctocell.xyz> Request was from Ludovic Courtès <ludo <at> gnu.org> to control <at> debbugs.gnu.org. (Sat, 30 Oct 2021 23:02:02 GMT) Full text and rfc822 format available.

Information forwarded to guix-patches <at> gnu.org:
bug#50873; Package guix-patches. (Sun, 31 Oct 2021 17:39:02 GMT) Full text and rfc822 format available.

Message #133 received at 50873 <at> debbugs.gnu.org (full text, mbox):

From: Xinglu Chen <public <at> yoctocell.xyz>
To: Ludovic Courtès <ludo <at> gnu.org>
Cc: Oleg Pykhalov <go.wigust <at> gmail.com>, 50873 <at> debbugs.gnu.org,
 Andrew Tropin <andrew <at> trop.in>
Subject: Re: [bug#50873] [PATCH 0/5] Fixes to ‘guix home
 import’
Date: Sun, 31 Oct 2021 18:38:37 +0100
[Message part 1 (text/plain, inline)]
Hi,

On Sun, Oct 31 2021, Ludovic Courtès wrote:

> Hi!
>
> Xinglu Chen <public <at> yoctocell.xyz> skribis:
>
>>   guix home: import: Make the user to specify a destination directory.
>>   guix home: import: Allow multiple modules to be imported for each
>>     service.
>>   guix home: import: Fix module name for Bash service.
>>   guix home: import: Don’t use 'slurp-file-gexp'.
>>   guix home: import: Delete duplicate modules when importing.
>>   doc: Document the ‘guix home import’ subcommand.
>>   Add tests for ‘guix home import’.
>>   guix home: import: Call ‘local-file’ with ‘name’ argument.
>
> That’s a nice improvement.  In the interest of moving forward, I applied
> the whole series and followed up with a few changes:
>
>   c4ac8cf4f6 doc: Mention 'guix home reconfigure' upfront.
>   971a69d8e3 doc: Avoid misuse of @ref.
>   7711a6c3f4 doc: Mention "guix home import" upfront.
>   6f4ca78761 home: import: Avoid duplication of 'manifest->code'.
>   96728c54df home: import: Factorize triplicated 'version-spec' procedure.
>   f3933ae40d home: import: Clarify "destination directory".
>   341fba217f home: import: Compare procedures with 'eq?'.
>
> Part of it is about removing duplicated code, in particular
> ‘manifest->code’.  It’s important to factorize non-trivial code like
> this.
>
> The last commits improve documentation so users learn about ‘guix home
> import’ when they get started.

Thanks for taking care of this!

> It’s really nice to have this tool!  I find it perhaps a bit confusing
> to have to specify a target directory to ‘guix home import’; simply
> trying to document it shows that it’s non-obvious.
>
> I wonder if the argument should be optional (in which case the files
> wouldn’t be copied).  But then people are likely to run into the
> problems this addresses.

Yeah, that could be a bit confusing for people.

> Or perhaps it would be more consistent to have:
>
>   guix home import ~/foo
>
> create ~/foo/config.scm, instead of printing it to stdout?
>
> The documentation would be clearer: “populate ~/foo with all the
> configuration files of your home environment.”  Thoughts?

I originally made it to print to stdout because that’s what the ‘guix
import’ commands do, but it could make sense to just populate a file
directly.  I don’t really have a strong opinion on this, so if nobody
has any objections, I could send a patch for this.  :-)
[signature.asc (application/pgp-signature, inline)]

Information forwarded to guix-patches <at> gnu.org:
bug#50873; Package guix-patches. (Mon, 01 Nov 2021 06:32:02 GMT) Full text and rfc822 format available.

Message #136 received at 50873 <at> debbugs.gnu.org (full text, mbox):

From: Andrew Tropin <andrew <at> trop.in>
To: Xinglu Chen <public <at> yoctocell.xyz>, Ludovic Courtès
 <ludo <at> gnu.org>
Cc: Oleg Pykhalov <go.wigust <at> gmail.com>, 50873 <at> debbugs.gnu.org
Subject: Re: [bug#50873] [PATCH 0/5] Fixes to ‘guix home
 import’
Date: Mon, 01 Nov 2021 09:31:37 +0300
[Message part 1 (text/plain, inline)]
On 2021-10-31 18:38, Xinglu Chen wrote:

> Hi,
>
> On Sun, Oct 31 2021, Ludovic Courtès wrote:
>
>> Hi!
>>
>> Xinglu Chen <public <at> yoctocell.xyz> skribis:
>>
>>>   guix home: import: Make the user to specify a destination directory.
>>>   guix home: import: Allow multiple modules to be imported for each
>>>     service.
>>>   guix home: import: Fix module name for Bash service.
>>>   guix home: import: Don’t use 'slurp-file-gexp'.
>>>   guix home: import: Delete duplicate modules when importing.
>>>   doc: Document the ‘guix home import’ subcommand.
>>>   Add tests for ‘guix home import’.
>>>   guix home: import: Call ‘local-file’ with ‘name’ argument.
>>
>> That’s a nice improvement.  In the interest of moving forward, I applied
>> the whole series and followed up with a few changes:
>>
>>   c4ac8cf4f6 doc: Mention 'guix home reconfigure' upfront.
>>   971a69d8e3 doc: Avoid misuse of @ref.
>>   7711a6c3f4 doc: Mention "guix home import" upfront.
>>   6f4ca78761 home: import: Avoid duplication of 'manifest->code'.
>>   96728c54df home: import: Factorize triplicated 'version-spec' procedure.
>>   f3933ae40d home: import: Clarify "destination directory".
>>   341fba217f home: import: Compare procedures with 'eq?'.
>>
>> Part of it is about removing duplicated code, in particular
>> ‘manifest->code’.  It’s important to factorize non-trivial code like
>> this.
>>
>> The last commits improve documentation so users learn about ‘guix home
>> import’ when they get started.
>
> Thanks for taking care of this!
>
>> It’s really nice to have this tool!  I find it perhaps a bit confusing
>> to have to specify a target directory to ‘guix home import’; simply
>> trying to document it shows that it’s non-obvious.
>>
>> I wonder if the argument should be optional (in which case the files
>> wouldn’t be copied).  But then people are likely to run into the
>> problems this addresses.
>
> Yeah, that could be a bit confusing for people.
>
>> Or perhaps it would be more consistent to have:
>>
>>   guix home import ~/foo
>>
>> create ~/foo/config.scm, instead of printing it to stdout?

It's a good idea.  home.scm or home-config.scm can be another option to
make it clearer that it's not a system config. 

>>
>> The documentation would be clearer: “populate ~/foo with all the
>> configuration files of your home environment.”  Thoughts?
>
> I originally made it to print to stdout because that’s what the ‘guix
> import’ commands do, but it could make sense to just populate a file
> directly.  I don’t really have a strong opinion on this, so if nobody
> has any objections, I could send a patch for this.  :-)

-- 
Best regards,
Andrew Tropin
[signature.asc (application/pgp-signature, inline)]

Information forwarded to guix-patches <at> gnu.org:
bug#50873; Package guix-patches. (Sat, 06 Nov 2021 17:01:02 GMT) Full text and rfc822 format available.

Message #139 received at 50873 <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: Andrew Tropin <andrew <at> trop.in>
Cc: Oleg Pykhalov <go.wigust <at> gmail.com>, 50873 <at> debbugs.gnu.org,
 Xinglu Chen <public <at> yoctocell.xyz>
Subject: Re: [bug#50873] [PATCH 0/5] Fixes to ‘guix home
 import’
Date: Sat, 06 Nov 2021 18:00:17 +0100
Hi,

Andrew Tropin <andrew <at> trop.in> skribis:

>>> Or perhaps it would be more consistent to have:
>>>
>>>   guix home import ~/foo
>>>
>>> create ~/foo/config.scm, instead of printing it to stdout?
>
> It's a good idea.  home.scm or home-config.scm can be another option to
> make it clearer that it's not a system config. 

Yes, or even ‘home-configuration.scm’, in keeping with the
no-abbreviation policy.  :-)

If Xinglu or someone else wants to make this change, I’ll happily
review/apply!

Thanks,
Ludo’.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sun, 05 Dec 2021 12:24:14 GMT) Full text and rfc822 format available.

This bug report was last modified 2 years and 136 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.