* [bug#50873] [PATCH 0/5] Fixes to ‘guix home import’ @ 2021-09-28 17:33 Xinglu Chen 2021-09-28 17:35 ` [bug#50873] [PATCH 1/5] guix home: import: Make the user to specify a destination directory Xinglu Chen ` (7 more replies) 0 siblings, 8 replies; 44+ messages in thread From: Xinglu Chen @ 2021-09-28 17:33 UTC (permalink / raw) To: 50873; +Cc: Ludovic Courtès, Andrew Tropin [-- Attachment #1: Type: text/plain, Size: 1044 bytes --] 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 [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 861 bytes --] ^ permalink raw reply [flat|nested] 44+ messages in thread
* [bug#50873] [PATCH 1/5] guix home: import: Make the user to specify a destination directory. 2021-09-28 17:33 [bug#50873] [PATCH 0/5] Fixes to ‘guix home import’ Xinglu Chen @ 2021-09-28 17:35 ` Xinglu Chen 2021-09-28 17:35 ` [bug#50873] [PATCH 2/5] guix home: import: Allow multiple modules to be imported for each service Xinglu Chen ` (6 subsequent siblings) 7 siblings, 0 replies; 44+ messages in thread From: Xinglu Chen @ 2021-09-28 17:35 UTC (permalink / raw) To: 50873; +Cc: Ludovic Courtès, Andrew Tropin 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 ^ permalink raw reply related [flat|nested] 44+ messages in thread
* [bug#50873] [PATCH 2/5] guix home: import: Allow multiple modules to be imported for each service. 2021-09-28 17:33 [bug#50873] [PATCH 0/5] Fixes to ‘guix home import’ Xinglu Chen 2021-09-28 17:35 ` [bug#50873] [PATCH 1/5] guix home: import: Make the user to specify a destination directory Xinglu Chen @ 2021-09-28 17:35 ` Xinglu Chen 2021-09-28 17:35 ` [bug#50873] [PATCH 3/5] guix home: import: Fix module name for Bash service Xinglu Chen ` (5 subsequent siblings) 7 siblings, 0 replies; 44+ messages in thread From: Xinglu Chen @ 2021-09-28 17:35 UTC (permalink / raw) To: 50873; +Cc: Ludovic Courtès, Andrew Tropin 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 ^ permalink raw reply related [flat|nested] 44+ messages in thread
* [bug#50873] [PATCH 3/5] guix home: import: Fix module name for Bash service. 2021-09-28 17:33 [bug#50873] [PATCH 0/5] Fixes to ‘guix home import’ Xinglu Chen 2021-09-28 17:35 ` [bug#50873] [PATCH 1/5] guix home: import: Make the user to specify a destination directory Xinglu Chen 2021-09-28 17:35 ` [bug#50873] [PATCH 2/5] guix home: import: Allow multiple modules to be imported for each service Xinglu Chen @ 2021-09-28 17:35 ` Xinglu Chen 2021-09-28 17:36 ` [bug#50873] [PATCH 4/5] guix home: import: Delete duplicate modules when importing Xinglu Chen ` (4 subsequent siblings) 7 siblings, 0 replies; 44+ messages in thread From: Xinglu Chen @ 2021-09-28 17:35 UTC (permalink / raw) To: 50873; +Cc: Ludovic Courtès, Andrew Tropin * 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 ^ permalink raw reply related [flat|nested] 44+ messages in thread
* [bug#50873] [PATCH 4/5] guix home: import: Delete duplicate modules when importing. 2021-09-28 17:33 [bug#50873] [PATCH 0/5] Fixes to ‘guix home import’ Xinglu Chen ` (2 preceding siblings ...) 2021-09-28 17:35 ` [bug#50873] [PATCH 3/5] guix home: import: Fix module name for Bash service Xinglu Chen @ 2021-09-28 17:36 ` Xinglu Chen 2021-09-28 17:36 ` [bug#50873] [PATCH 5/5] doc: Document the ‘guix home import’ subcommand Xinglu Chen ` (3 subsequent siblings) 7 siblings, 0 replies; 44+ messages in thread From: Xinglu Chen @ 2021-09-28 17:36 UTC (permalink / raw) To: 50873; +Cc: Ludovic Courtès, Andrew Tropin 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 ^ permalink raw reply related [flat|nested] 44+ messages in thread
* [bug#50873] [PATCH 5/5] doc: Document the ‘guix home import’ subcommand. 2021-09-28 17:33 [bug#50873] [PATCH 0/5] Fixes to ‘guix home import’ Xinglu Chen ` (3 preceding siblings ...) 2021-09-28 17:36 ` [bug#50873] [PATCH 4/5] guix home: import: Delete duplicate modules when importing Xinglu Chen @ 2021-09-28 17:36 ` Xinglu Chen 2021-09-30 7:08 ` Andrew Tropin 2021-09-28 20:52 ` [bug#50873] [PATCH 0/2] Add pn Antero Mejr via Guix-patches via ` (2 subsequent siblings) 7 siblings, 1 reply; 44+ messages in thread From: Xinglu Chen @ 2021-09-28 17:36 UTC (permalink / raw) To: 50873; +Cc: Ludovic Courtès, Andrew Tropin * 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 ^ permalink raw reply related [flat|nested] 44+ messages in thread
* [bug#50873] [PATCH 5/5] doc: Document the ‘guix home import’ subcommand. 2021-09-28 17:36 ` [bug#50873] [PATCH 5/5] doc: Document the ‘guix home import’ subcommand Xinglu Chen @ 2021-09-30 7:08 ` Andrew Tropin 2021-10-01 5:08 ` Xinglu Chen 0 siblings, 1 reply; 44+ messages in thread From: Andrew Tropin @ 2021-09-30 7:08 UTC (permalink / raw) To: Xinglu Chen, 50873; +Cc: Ludovic Courtès [-- Attachment #1: Type: text/plain, Size: 2128 bytes --] 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 [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 832 bytes --] ^ permalink raw reply [flat|nested] 44+ messages in thread
* [bug#50873] [PATCH 5/5] doc: Document the ‘guix home import’ subcommand. 2021-09-30 7:08 ` Andrew Tropin @ 2021-10-01 5:08 ` Xinglu Chen 2021-10-02 15:10 ` [bug#50873] [PATCH 0/5] Fixes to ‘guix home import’ Ludovic Courtès 0 siblings, 1 reply; 44+ messages in thread From: Xinglu Chen @ 2021-10-01 5:08 UTC (permalink / raw) To: Andrew Tropin, 50873; +Cc: Ludovic Courtès [-- Attachment #1: Type: text/plain, Size: 2281 bytes --] 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. :-) [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 861 bytes --] ^ permalink raw reply [flat|nested] 44+ messages in thread
* [bug#50873] [PATCH 0/5] Fixes to ‘guix home import’ 2021-10-01 5:08 ` Xinglu Chen @ 2021-10-02 15:10 ` Ludovic Courtès 0 siblings, 0 replies; 44+ messages in thread From: Ludovic Courtès @ 2021-10-02 15:10 UTC (permalink / raw) To: Xinglu Chen; +Cc: 50873, Andrew Tropin Hi, Xinglu Chen <public@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’. ^ permalink raw reply [flat|nested] 44+ messages in thread
* [bug#50873] [PATCH 0/2] Add pn. 2021-09-28 17:33 [bug#50873] [PATCH 0/5] Fixes to ‘guix home import’ Xinglu Chen ` (4 preceding siblings ...) 2021-09-28 17:36 ` [bug#50873] [PATCH 5/5] doc: Document the ‘guix home import’ subcommand Xinglu Chen @ 2021-09-28 20:52 ` Antero Mejr via Guix-patches via 2021-09-28 20:52 ` [bug#50873] [PATCH 1/2] gnu: Add libphonenumber Antero Mejr via Guix-patches via 2021-09-28 20:52 ` [bug#50873] [PATCH 2/2] gnu: Add pn Antero Mejr via Guix-patches via 2021-10-02 15:13 ` [bug#50873] [PATCH 0/5] Fixes to ‘guix home import’ Ludovic Courtès 2021-10-10 10:19 ` [bug#50873] [PATCH 0/7] " Xinglu Chen 7 siblings, 2 replies; 44+ messages in thread From: Antero Mejr via Guix-patches via @ 2021-09-28 20:52 UTC (permalink / raw) To: 50873; +Cc: Antero Mejr 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 ^ permalink raw reply [flat|nested] 44+ messages in thread
* [bug#50873] [PATCH 1/2] gnu: Add libphonenumber. 2021-09-28 20:52 ` [bug#50873] [PATCH 0/2] Add pn Antero Mejr via Guix-patches via @ 2021-09-28 20:52 ` Antero Mejr via Guix-patches via 2021-09-28 20:52 ` [bug#50873] [PATCH 2/2] gnu: Add pn Antero Mejr via Guix-patches via 1 sibling, 0 replies; 44+ messages in thread From: Antero Mejr via Guix-patches via @ 2021-09-28 20:52 UTC (permalink / raw) To: 50873; +Cc: Antero Mejr * 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@gmail.com> ;;; Copyright © 2020 Vincent Legoll <vincent.legoll@gmail.com> ;;; Copyright © 2021 LibreMiami <packaging-guix@libremiami.org> +;;; Copyright © 2021 Antero Mejr <antero@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 ^ permalink raw reply related [flat|nested] 44+ messages in thread
* [bug#50873] [PATCH 2/2] gnu: Add pn. 2021-09-28 20:52 ` [bug#50873] [PATCH 0/2] Add pn Antero Mejr via Guix-patches via 2021-09-28 20:52 ` [bug#50873] [PATCH 1/2] gnu: Add libphonenumber Antero Mejr via Guix-patches via @ 2021-09-28 20:52 ` Antero Mejr via Guix-patches via 1 sibling, 0 replies; 44+ messages in thread From: Antero Mejr via Guix-patches via @ 2021-09-28 20:52 UTC (permalink / raw) To: 50873; +Cc: Antero Mejr * 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 ^ permalink raw reply related [flat|nested] 44+ messages in thread
* [bug#50873] [PATCH 0/5] Fixes to ‘guix home import’ 2021-09-28 17:33 [bug#50873] [PATCH 0/5] Fixes to ‘guix home import’ Xinglu Chen ` (5 preceding siblings ...) 2021-09-28 20:52 ` [bug#50873] [PATCH 0/2] Add pn Antero Mejr via Guix-patches via @ 2021-10-02 15:13 ` Ludovic Courtès 2021-10-02 18:45 ` Xinglu Chen 2021-10-10 10:19 ` [bug#50873] [PATCH 0/7] " Xinglu Chen 7 siblings, 1 reply; 44+ messages in thread From: Ludovic Courtès @ 2021-10-02 15:13 UTC (permalink / raw) To: Xinglu Chen; +Cc: 50873, Andrew Tropin Xinglu Chen <public@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’. ^ permalink raw reply [flat|nested] 44+ messages in thread
* [bug#50873] [PATCH 0/5] Fixes to ‘guix home import’ 2021-10-02 15:13 ` [bug#50873] [PATCH 0/5] Fixes to ‘guix home import’ Ludovic Courtès @ 2021-10-02 18:45 ` Xinglu Chen 0 siblings, 0 replies; 44+ messages in thread From: Xinglu Chen @ 2021-10-02 18:45 UTC (permalink / raw) To: Ludovic Courtès; +Cc: 50873, Andrew Tropin [-- Attachment #1: Type: text/plain, Size: 1209 bytes --] On Sat, Oct 02 2021, Ludovic Courtès wrote: > Xinglu Chen <public@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! :-) [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 861 bytes --] ^ permalink raw reply [flat|nested] 44+ messages in thread
* [bug#50873] [PATCH 0/7] Fixes to ‘guix home import’ 2021-09-28 17:33 [bug#50873] [PATCH 0/5] Fixes to ‘guix home import’ Xinglu Chen ` (6 preceding siblings ...) 2021-10-02 15:13 ` [bug#50873] [PATCH 0/5] Fixes to ‘guix home import’ Ludovic Courtès @ 2021-10-10 10:19 ` Xinglu Chen 2021-10-10 10:20 ` [bug#50873] [PATCH 1/7] guix home: import: Make the user to specify a destination directory Xinglu Chen ` (7 more replies) 7 siblings, 8 replies; 44+ messages in thread From: Xinglu Chen @ 2021-10-10 10:19 UTC (permalink / raw) To: 50873; +Cc: Oleg Pykhalov, Ludovic Courtès, Andrew Tropin [-- Attachment #1: Type: text/plain, Size: 1008 bytes --] 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 [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 861 bytes --] ^ permalink raw reply [flat|nested] 44+ messages in thread
* [bug#50873] [PATCH 1/7] guix home: import: Make the user to specify a destination directory. 2021-10-10 10:19 ` [bug#50873] [PATCH 0/7] " Xinglu Chen @ 2021-10-10 10:20 ` Xinglu Chen 2021-10-13 9:24 ` [bug#50873] [PATCH 0/5] Fixes to ‘guix home import’ Ludovic Courtès 2021-10-10 10:20 ` [bug#50873] [PATCH 2/7] guix home: import: Allow multiple modules to be imported for each service Xinglu Chen ` (6 subsequent siblings) 7 siblings, 1 reply; 44+ messages in thread From: Xinglu Chen @ 2021-10-10 10:20 UTC (permalink / raw) To: 50873; +Cc: Oleg Pykhalov, Ludovic Courtès, Andrew Tropin 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 ^ permalink raw reply related [flat|nested] 44+ messages in thread
* [bug#50873] [PATCH 0/5] Fixes to ‘guix home import’ 2021-10-10 10:20 ` [bug#50873] [PATCH 1/7] guix home: import: Make the user to specify a destination directory Xinglu Chen @ 2021-10-13 9:24 ` Ludovic Courtès 2021-10-29 13:37 ` Xinglu Chen 0 siblings, 1 reply; 44+ messages in thread From: Ludovic Courtès @ 2021-10-13 9:24 UTC (permalink / raw) To: Xinglu Chen; +Cc: Oleg Pykhalov, 50873, Andrew Tropin Hello, Xinglu Chen <public@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’. ^ permalink raw reply [flat|nested] 44+ messages in thread
* [bug#50873] [PATCH 0/5] Fixes to ‘guix home import’ 2021-10-13 9:24 ` [bug#50873] [PATCH 0/5] Fixes to ‘guix home import’ Ludovic Courtès @ 2021-10-29 13:37 ` Xinglu Chen 0 siblings, 0 replies; 44+ messages in thread From: Xinglu Chen @ 2021-10-29 13:37 UTC (permalink / raw) To: Ludovic Courtès; +Cc: Oleg Pykhalov, 50873, Andrew Tropin [-- Attachment #1: Type: text/plain, Size: 1571 bytes --] Hi, (sorry for taking so long to get to this!) On Wed, Oct 13 2021, Ludovic Courtès wrote: > Hello, > > Xinglu Chen <public@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. :-) [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 861 bytes --] ^ permalink raw reply [flat|nested] 44+ messages in thread
* [bug#50873] [PATCH 2/7] guix home: import: Allow multiple modules to be imported for each service. 2021-10-10 10:19 ` [bug#50873] [PATCH 0/7] " Xinglu Chen 2021-10-10 10:20 ` [bug#50873] [PATCH 1/7] guix home: import: Make the user to specify a destination directory Xinglu Chen @ 2021-10-10 10:20 ` Xinglu Chen 2021-10-10 10:20 ` [bug#50873] [PATCH 3/7] guix home: import: Fix module name for Bash service Xinglu Chen ` (5 subsequent siblings) 7 siblings, 0 replies; 44+ messages in thread From: Xinglu Chen @ 2021-10-10 10:20 UTC (permalink / raw) To: 50873; +Cc: Oleg Pykhalov, Ludovic Courtès, Andrew Tropin 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 ^ permalink raw reply related [flat|nested] 44+ messages in thread
* [bug#50873] [PATCH 3/7] guix home: import: Fix module name for Bash service. 2021-10-10 10:19 ` [bug#50873] [PATCH 0/7] " Xinglu Chen 2021-10-10 10:20 ` [bug#50873] [PATCH 1/7] guix home: import: Make the user to specify a destination directory Xinglu Chen 2021-10-10 10:20 ` [bug#50873] [PATCH 2/7] guix home: import: Allow multiple modules to be imported for each service Xinglu Chen @ 2021-10-10 10:20 ` Xinglu Chen 2021-10-10 10:20 ` [bug#50873] [PATCH 4/7] guix home: import: Don’t use 'slurp-file-gexp' Xinglu Chen ` (4 subsequent siblings) 7 siblings, 0 replies; 44+ messages in thread From: Xinglu Chen @ 2021-10-10 10:20 UTC (permalink / raw) To: 50873; +Cc: Oleg Pykhalov, Ludovic Courtès, Andrew Tropin * 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 ^ permalink raw reply related [flat|nested] 44+ messages in thread
* [bug#50873] [PATCH 4/7] guix home: import: Don’t use 'slurp-file-gexp'. 2021-10-10 10:19 ` [bug#50873] [PATCH 0/7] " Xinglu Chen ` (2 preceding siblings ...) 2021-10-10 10:20 ` [bug#50873] [PATCH 3/7] guix home: import: Fix module name for Bash service Xinglu Chen @ 2021-10-10 10:20 ` Xinglu Chen 2021-10-10 10:20 ` [bug#50873] [PATCH 5/7] guix home: import: Delete duplicate modules when importing Xinglu Chen ` (3 subsequent siblings) 7 siblings, 0 replies; 44+ messages in thread From: Xinglu Chen @ 2021-10-10 10:20 UTC (permalink / raw) To: 50873; +Cc: Oleg Pykhalov, Ludovic Courtès, Andrew Tropin ‘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 ^ permalink raw reply related [flat|nested] 44+ messages in thread
* [bug#50873] [PATCH 5/7] guix home: import: Delete duplicate modules when importing. 2021-10-10 10:19 ` [bug#50873] [PATCH 0/7] " Xinglu Chen ` (3 preceding siblings ...) 2021-10-10 10:20 ` [bug#50873] [PATCH 4/7] guix home: import: Don’t use 'slurp-file-gexp' Xinglu Chen @ 2021-10-10 10:20 ` Xinglu Chen 2021-10-10 10:20 ` [bug#50873] [PATCH 6/7] doc: Document the ‘guix home import’ subcommand Xinglu Chen ` (2 subsequent siblings) 7 siblings, 0 replies; 44+ messages in thread From: Xinglu Chen @ 2021-10-10 10:20 UTC (permalink / raw) To: 50873; +Cc: Oleg Pykhalov, Ludovic Courtès, Andrew Tropin 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 ^ permalink raw reply related [flat|nested] 44+ messages in thread
* [bug#50873] [PATCH 6/7] doc: Document the ‘guix home import’ subcommand. 2021-10-10 10:19 ` [bug#50873] [PATCH 0/7] " Xinglu Chen ` (4 preceding siblings ...) 2021-10-10 10:20 ` [bug#50873] [PATCH 5/7] guix home: import: Delete duplicate modules when importing Xinglu Chen @ 2021-10-10 10:20 ` Xinglu Chen 2021-10-10 10:20 ` [bug#50873] [PATCH 7/7] Add tests for ‘guix home import’ Xinglu Chen 2021-10-30 10:42 ` [bug#50873] [PATCH v3 0/8] " Xinglu Chen 7 siblings, 0 replies; 44+ messages in thread From: Xinglu Chen @ 2021-10-10 10:20 UTC (permalink / raw) To: 50873; +Cc: Oleg Pykhalov, Ludovic Courtès, Andrew Tropin * 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 ^ permalink raw reply related [flat|nested] 44+ messages in thread
* [bug#50873] [PATCH 7/7] Add tests for ‘guix home import’. 2021-10-10 10:19 ` [bug#50873] [PATCH 0/7] " Xinglu Chen ` (5 preceding siblings ...) 2021-10-10 10:20 ` [bug#50873] [PATCH 6/7] doc: Document the ‘guix home import’ subcommand Xinglu Chen @ 2021-10-10 10:20 ` Xinglu Chen 2021-10-11 13:00 ` [bug#50873] [PATCH 0/5] Fixes to " Oleg Pykhalov 2021-10-30 10:42 ` [bug#50873] [PATCH v3 0/8] " Xinglu Chen 7 siblings, 1 reply; 44+ messages in thread From: Xinglu Chen @ 2021-10-10 10:20 UTC (permalink / raw) To: 50873; +Cc: Oleg Pykhalov, Ludovic Courtès, Andrew Tropin * 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@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@2.0.9" "gcc" "glibc@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 ^ permalink raw reply related [flat|nested] 44+ messages in thread
* [bug#50873] [PATCH 0/5] Fixes to ‘guix home import’ 2021-10-10 10:20 ` [bug#50873] [PATCH 7/7] Add tests for ‘guix home import’ Xinglu Chen @ 2021-10-11 13:00 ` Oleg Pykhalov 2021-10-13 9:25 ` Ludovic Courtès 2021-10-29 13:47 ` Xinglu Chen 0 siblings, 2 replies; 44+ messages in thread From: Oleg Pykhalov @ 2021-10-11 13:00 UTC (permalink / raw) To: Xinglu Chen; +Cc: Ludovic Courtès, 50873, Andrew Tropin [-- Attachment #1: Type: text/plain, Size: 4000 bytes --] Hi, Xinglu Chen <public@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@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@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@guixsd ~/src/guix [env]$ oleg@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. [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 861 bytes --] ^ permalink raw reply [flat|nested] 44+ messages in thread
* [bug#50873] [PATCH 0/5] Fixes to ‘guix home import’ 2021-10-11 13:00 ` [bug#50873] [PATCH 0/5] Fixes to " Oleg Pykhalov @ 2021-10-13 9:25 ` Ludovic Courtès 2021-10-29 7:36 ` Ludovic Courtès 2021-10-29 13:47 ` Xinglu Chen 1 sibling, 1 reply; 44+ messages in thread From: Ludovic Courtès @ 2021-10-13 9:25 UTC (permalink / raw) To: Oleg Pykhalov; +Cc: 50873, Xinglu Chen, Andrew Tropin 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’. ^ permalink raw reply [flat|nested] 44+ messages in thread
* [bug#50873] [PATCH 0/5] Fixes to ‘guix home import’ 2021-10-13 9:25 ` Ludovic Courtès @ 2021-10-29 7:36 ` Ludovic Courtès 0 siblings, 0 replies; 44+ messages in thread From: Ludovic Courtès @ 2021-10-29 7:36 UTC (permalink / raw) To: Oleg Pykhalov; +Cc: Xinglu Chen, 50873, Andrew Tropin 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@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’. ^ permalink raw reply [flat|nested] 44+ messages in thread
* [bug#50873] [PATCH 0/5] Fixes to ‘guix home import’ 2021-10-11 13:00 ` [bug#50873] [PATCH 0/5] Fixes to " Oleg Pykhalov 2021-10-13 9:25 ` Ludovic Courtès @ 2021-10-29 13:47 ` Xinglu Chen 2021-10-30 14:17 ` Ludovic Courtès 1 sibling, 1 reply; 44+ messages in thread From: Xinglu Chen @ 2021-10-29 13:47 UTC (permalink / raw) To: Oleg Pykhalov; +Cc: Ludovic Courtès, 50873, Andrew Tropin [-- Attachment #1: Type: text/plain, Size: 4829 bytes --] On Mon, Oct 11 2021, Oleg Pykhalov wrote: > Hi, > > Xinglu Chen <public@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@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@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@guixsd ~/src/guix [env]$ > oleg@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. [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 861 bytes --] ^ permalink raw reply [flat|nested] 44+ messages in thread
* [bug#50873] [PATCH 0/5] Fixes to ‘guix home import’ 2021-10-29 13:47 ` Xinglu Chen @ 2021-10-30 14:17 ` Ludovic Courtès 0 siblings, 0 replies; 44+ messages in thread From: Ludovic Courtès @ 2021-10-30 14:17 UTC (permalink / raw) To: Xinglu Chen; +Cc: Oleg Pykhalov, 50873, Andrew Tropin Hi, Xinglu Chen <public@yoctocell.xyz> skribis: > On Mon, Oct 11 2021, Oleg Pykhalov wrote: > >> Hi, >> >> Xinglu Chen <public@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’. ^ permalink raw reply [flat|nested] 44+ messages in thread
* [bug#50873] [PATCH v3 0/8] Fixes to ‘guix home import’ 2021-10-10 10:19 ` [bug#50873] [PATCH 0/7] " Xinglu Chen ` (6 preceding siblings ...) 2021-10-10 10:20 ` [bug#50873] [PATCH 7/7] Add tests for ‘guix home import’ Xinglu Chen @ 2021-10-30 10:42 ` Xinglu Chen 2021-10-30 10:42 ` [bug#50873] [PATCH v3 1/8] guix home: import: Make the user to specify a destination directory Xinglu Chen ` (8 more replies) 7 siblings, 9 replies; 44+ messages in thread From: Xinglu Chen @ 2021-10-30 10:42 UTC (permalink / raw) To: 50873, Oleg Pykhalov, Andrew Tropin, Ludovic Courtès [-- Attachment #1: Type: text/plain, Size: 1280 bytes --] 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 [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 861 bytes --] ^ permalink raw reply [flat|nested] 44+ messages in thread
* [bug#50873] [PATCH v3 1/8] guix home: import: Make the user to specify a destination directory. 2021-10-30 10:42 ` [bug#50873] [PATCH v3 0/8] " Xinglu Chen @ 2021-10-30 10:42 ` Xinglu Chen 2021-10-30 14:22 ` Liliana Marie Prikler 2021-10-30 10:42 ` [bug#50873] [PATCH v3 2/8] guix home: import: Allow multiple modules to be imported for each service Xinglu Chen ` (7 subsequent siblings) 8 siblings, 1 reply; 44+ messages in thread From: Xinglu Chen @ 2021-10-30 10:42 UTC (permalink / raw) To: 50873, Oleg Pykhalov, Andrew Tropin, Ludovic Courtès 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 ^ permalink raw reply related [flat|nested] 44+ messages in thread
* [bug#50873] [PATCH v3 1/8] guix home: import: Make the user to specify a destination directory. 2021-10-30 10:42 ` [bug#50873] [PATCH v3 1/8] guix home: import: Make the user to specify a destination directory Xinglu Chen @ 2021-10-30 14:22 ` Liliana Marie Prikler 0 siblings, 0 replies; 44+ messages in thread From: Liliana Marie Prikler @ 2021-10-30 14:22 UTC (permalink / raw) To: Xinglu Chen, 50873, Oleg Pykhalov, Andrew Tropin, Ludovic Courtès 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? ^ permalink raw reply [flat|nested] 44+ messages in thread
* [bug#50873] [PATCH v3 2/8] guix home: import: Allow multiple modules to be imported for each service. 2021-10-30 10:42 ` [bug#50873] [PATCH v3 0/8] " Xinglu Chen 2021-10-30 10:42 ` [bug#50873] [PATCH v3 1/8] guix home: import: Make the user to specify a destination directory Xinglu Chen @ 2021-10-30 10:42 ` Xinglu Chen 2021-10-30 10:42 ` [bug#50873] [PATCH v3 3/8] guix home: import: Fix module name for Bash service Xinglu Chen ` (6 subsequent siblings) 8 siblings, 0 replies; 44+ messages in thread From: Xinglu Chen @ 2021-10-30 10:42 UTC (permalink / raw) To: 50873, Oleg Pykhalov, Andrew Tropin, Ludovic Courtès 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 ^ permalink raw reply related [flat|nested] 44+ messages in thread
* [bug#50873] [PATCH v3 3/8] guix home: import: Fix module name for Bash service. 2021-10-30 10:42 ` [bug#50873] [PATCH v3 0/8] " Xinglu Chen 2021-10-30 10:42 ` [bug#50873] [PATCH v3 1/8] guix home: import: Make the user to specify a destination directory Xinglu Chen 2021-10-30 10:42 ` [bug#50873] [PATCH v3 2/8] guix home: import: Allow multiple modules to be imported for each service Xinglu Chen @ 2021-10-30 10:42 ` Xinglu Chen 2021-10-30 11:50 ` Julien Lepiller 2021-10-30 10:42 ` [bug#50873] [PATCH v3 4/8] guix home: import: Don’t use 'slurp-file-gexp' Xinglu Chen ` (5 subsequent siblings) 8 siblings, 1 reply; 44+ messages in thread From: Xinglu Chen @ 2021-10-30 10:42 UTC (permalink / raw) To: 50873, Oleg Pykhalov, Andrew Tropin, Ludovic Courtès * 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 ^ permalink raw reply related [flat|nested] 44+ messages in thread
* [bug#50873] [PATCH v3 3/8] guix home: import: Fix module name for Bash service. 2021-10-30 10:42 ` [bug#50873] [PATCH v3 3/8] guix home: import: Fix module name for Bash service Xinglu Chen @ 2021-10-30 11:50 ` Julien Lepiller 0 siblings, 0 replies; 44+ messages in thread From: Julien Lepiller @ 2021-10-30 11:50 UTC (permalink / raw) To: Xinglu Chen; +Cc: Oleg Pykhalov, Ludovic Courtès, 50873, Andrew Tropin Le Sat, 30 Oct 2021 12:42:34 +0200, Xinglu Chen <public@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! :) ^ permalink raw reply [flat|nested] 44+ messages in thread
* [bug#50873] [PATCH v3 4/8] guix home: import: Don’t use 'slurp-file-gexp'. 2021-10-30 10:42 ` [bug#50873] [PATCH v3 0/8] " Xinglu Chen ` (2 preceding siblings ...) 2021-10-30 10:42 ` [bug#50873] [PATCH v3 3/8] guix home: import: Fix module name for Bash service Xinglu Chen @ 2021-10-30 10:42 ` Xinglu Chen 2021-10-30 10:42 ` [bug#50873] [PATCH v3 5/8] guix home: import: Delete duplicate modules when importing Xinglu Chen ` (4 subsequent siblings) 8 siblings, 0 replies; 44+ messages in thread From: Xinglu Chen @ 2021-10-30 10:42 UTC (permalink / raw) To: 50873, Oleg Pykhalov, Andrew Tropin, Ludovic Courtès ‘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 ^ permalink raw reply related [flat|nested] 44+ messages in thread
* [bug#50873] [PATCH v3 5/8] guix home: import: Delete duplicate modules when importing. 2021-10-30 10:42 ` [bug#50873] [PATCH v3 0/8] " Xinglu Chen ` (3 preceding siblings ...) 2021-10-30 10:42 ` [bug#50873] [PATCH v3 4/8] guix home: import: Don’t use 'slurp-file-gexp' Xinglu Chen @ 2021-10-30 10:42 ` Xinglu Chen 2021-10-30 10:42 ` [bug#50873] [PATCH v3 6/8] doc: Document the ‘guix home import’ subcommand Xinglu Chen ` (3 subsequent siblings) 8 siblings, 0 replies; 44+ messages in thread From: Xinglu Chen @ 2021-10-30 10:42 UTC (permalink / raw) To: 50873, Oleg Pykhalov, Andrew Tropin, Ludovic Courtès 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 ^ permalink raw reply related [flat|nested] 44+ messages in thread
* [bug#50873] [PATCH v3 6/8] doc: Document the ‘guix home import’ subcommand. 2021-10-30 10:42 ` [bug#50873] [PATCH v3 0/8] " Xinglu Chen ` (4 preceding siblings ...) 2021-10-30 10:42 ` [bug#50873] [PATCH v3 5/8] guix home: import: Delete duplicate modules when importing Xinglu Chen @ 2021-10-30 10:42 ` Xinglu Chen 2021-10-30 10:42 ` [bug#50873] [PATCH v3 7/8] Add tests for ‘guix home import’ Xinglu Chen ` (2 subsequent siblings) 8 siblings, 0 replies; 44+ messages in thread From: Xinglu Chen @ 2021-10-30 10:42 UTC (permalink / raw) To: 50873, Oleg Pykhalov, Andrew Tropin, Ludovic Courtès * 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 ^ permalink raw reply related [flat|nested] 44+ messages in thread
* [bug#50873] [PATCH v3 7/8] Add tests for ‘guix home import’. 2021-10-30 10:42 ` [bug#50873] [PATCH v3 0/8] " Xinglu Chen ` (5 preceding siblings ...) 2021-10-30 10:42 ` [bug#50873] [PATCH v3 6/8] doc: Document the ‘guix home import’ subcommand Xinglu Chen @ 2021-10-30 10:42 ` Xinglu Chen 2021-10-30 10:42 ` [bug#50873] [PATCH v3 8/8] guix home: import: Call ‘local-file’ with ‘name’ Xinglu Chen 2021-10-30 23:01 ` [bug#50873] [PATCH 0/5] Fixes to ‘guix home import’ Ludovic Courtès 8 siblings, 0 replies; 44+ messages in thread From: Xinglu Chen @ 2021-10-30 10:42 UTC (permalink / raw) To: 50873, Oleg Pykhalov, Andrew Tropin, Ludovic Courtès * 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@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@2.0.9" "gcc" "glibc@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 ^ permalink raw reply related [flat|nested] 44+ messages in thread
* [bug#50873] [PATCH v3 8/8] guix home: import: Call ‘local-file’ with ‘name’ 2021-10-30 10:42 ` [bug#50873] [PATCH v3 0/8] " Xinglu Chen ` (6 preceding siblings ...) 2021-10-30 10:42 ` [bug#50873] [PATCH v3 7/8] Add tests for ‘guix home import’ Xinglu Chen @ 2021-10-30 10:42 ` Xinglu Chen 2021-10-30 23:01 ` [bug#50873] [PATCH 0/5] Fixes to ‘guix home import’ Ludovic Courtès 8 siblings, 0 replies; 44+ messages in thread From: Xinglu Chen @ 2021-10-30 10:42 UTC (permalink / raw) To: 50873, Oleg Pykhalov, Andrew Tropin, Ludovic Courtès 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 ^ permalink raw reply related [flat|nested] 44+ messages in thread
* [bug#50873] [PATCH 0/5] Fixes to ‘guix home import’ 2021-10-30 10:42 ` [bug#50873] [PATCH v3 0/8] " Xinglu Chen ` (7 preceding siblings ...) 2021-10-30 10:42 ` [bug#50873] [PATCH v3 8/8] guix home: import: Call ‘local-file’ with ‘name’ Xinglu Chen @ 2021-10-30 23:01 ` Ludovic Courtès 2021-10-31 17:38 ` Xinglu Chen 8 siblings, 1 reply; 44+ messages in thread From: Ludovic Courtès @ 2021-10-30 23:01 UTC (permalink / raw) To: Xinglu Chen; +Cc: Oleg Pykhalov, 50873, Andrew Tropin Hi! Xinglu Chen <public@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’. ^ permalink raw reply [flat|nested] 44+ messages in thread
* [bug#50873] [PATCH 0/5] Fixes to ‘guix home import’ 2021-10-30 23:01 ` [bug#50873] [PATCH 0/5] Fixes to ‘guix home import’ Ludovic Courtès @ 2021-10-31 17:38 ` Xinglu Chen 2021-11-01 6:31 ` Andrew Tropin 0 siblings, 1 reply; 44+ messages in thread From: Xinglu Chen @ 2021-10-31 17:38 UTC (permalink / raw) To: Ludovic Courtès; +Cc: Oleg Pykhalov, 50873, Andrew Tropin [-- Attachment #1: Type: text/plain, Size: 2509 bytes --] Hi, On Sun, Oct 31 2021, Ludovic Courtès wrote: > Hi! > > Xinglu Chen <public@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. :-) [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 861 bytes --] ^ permalink raw reply [flat|nested] 44+ messages in thread
* [bug#50873] [PATCH 0/5] Fixes to ‘guix home import’ 2021-10-31 17:38 ` Xinglu Chen @ 2021-11-01 6:31 ` Andrew Tropin 2021-11-06 17:00 ` Ludovic Courtès 0 siblings, 1 reply; 44+ messages in thread From: Andrew Tropin @ 2021-11-01 6:31 UTC (permalink / raw) To: Xinglu Chen, Ludovic Courtès; +Cc: Oleg Pykhalov, 50873 [-- Attachment #1: Type: text/plain, Size: 2784 bytes --] On 2021-10-31 18:38, Xinglu Chen wrote: > Hi, > > On Sun, Oct 31 2021, Ludovic Courtès wrote: > >> Hi! >> >> Xinglu Chen <public@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 [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 832 bytes --] ^ permalink raw reply [flat|nested] 44+ messages in thread
* [bug#50873] [PATCH 0/5] Fixes to ‘guix home import’ 2021-11-01 6:31 ` Andrew Tropin @ 2021-11-06 17:00 ` Ludovic Courtès 0 siblings, 0 replies; 44+ messages in thread From: Ludovic Courtès @ 2021-11-06 17:00 UTC (permalink / raw) To: Andrew Tropin; +Cc: Oleg Pykhalov, 50873, Xinglu Chen Hi, Andrew Tropin <andrew@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’. ^ permalink raw reply [flat|nested] 44+ messages in thread
end of thread, other threads:[~2021-11-06 17:01 UTC | newest] Thread overview: 44+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2021-09-28 17:33 [bug#50873] [PATCH 0/5] Fixes to ‘guix home import’ Xinglu Chen 2021-09-28 17:35 ` [bug#50873] [PATCH 1/5] guix home: import: Make the user to specify a destination directory Xinglu Chen 2021-09-28 17:35 ` [bug#50873] [PATCH 2/5] guix home: import: Allow multiple modules to be imported for each service Xinglu Chen 2021-09-28 17:35 ` [bug#50873] [PATCH 3/5] guix home: import: Fix module name for Bash service Xinglu Chen 2021-09-28 17:36 ` [bug#50873] [PATCH 4/5] guix home: import: Delete duplicate modules when importing Xinglu Chen 2021-09-28 17:36 ` [bug#50873] [PATCH 5/5] doc: Document the ‘guix home import’ subcommand Xinglu Chen 2021-09-30 7:08 ` Andrew Tropin 2021-10-01 5:08 ` Xinglu Chen 2021-10-02 15:10 ` [bug#50873] [PATCH 0/5] Fixes to ‘guix home import’ Ludovic Courtès 2021-09-28 20:52 ` [bug#50873] [PATCH 0/2] Add pn Antero Mejr via Guix-patches via 2021-09-28 20:52 ` [bug#50873] [PATCH 1/2] gnu: Add libphonenumber Antero Mejr via Guix-patches via 2021-09-28 20:52 ` [bug#50873] [PATCH 2/2] gnu: Add pn Antero Mejr via Guix-patches via 2021-10-02 15:13 ` [bug#50873] [PATCH 0/5] Fixes to ‘guix home import’ Ludovic Courtès 2021-10-02 18:45 ` Xinglu Chen 2021-10-10 10:19 ` [bug#50873] [PATCH 0/7] " Xinglu Chen 2021-10-10 10:20 ` [bug#50873] [PATCH 1/7] guix home: import: Make the user to specify a destination directory Xinglu Chen 2021-10-13 9:24 ` [bug#50873] [PATCH 0/5] Fixes to ‘guix home import’ Ludovic Courtès 2021-10-29 13:37 ` Xinglu Chen 2021-10-10 10:20 ` [bug#50873] [PATCH 2/7] guix home: import: Allow multiple modules to be imported for each service Xinglu Chen 2021-10-10 10:20 ` [bug#50873] [PATCH 3/7] guix home: import: Fix module name for Bash service Xinglu Chen 2021-10-10 10:20 ` [bug#50873] [PATCH 4/7] guix home: import: Don’t use 'slurp-file-gexp' Xinglu Chen 2021-10-10 10:20 ` [bug#50873] [PATCH 5/7] guix home: import: Delete duplicate modules when importing Xinglu Chen 2021-10-10 10:20 ` [bug#50873] [PATCH 6/7] doc: Document the ‘guix home import’ subcommand Xinglu Chen 2021-10-10 10:20 ` [bug#50873] [PATCH 7/7] Add tests for ‘guix home import’ Xinglu Chen 2021-10-11 13:00 ` [bug#50873] [PATCH 0/5] Fixes to " Oleg Pykhalov 2021-10-13 9:25 ` Ludovic Courtès 2021-10-29 7:36 ` Ludovic Courtès 2021-10-29 13:47 ` Xinglu Chen 2021-10-30 14:17 ` Ludovic Courtès 2021-10-30 10:42 ` [bug#50873] [PATCH v3 0/8] " Xinglu Chen 2021-10-30 10:42 ` [bug#50873] [PATCH v3 1/8] guix home: import: Make the user to specify a destination directory Xinglu Chen 2021-10-30 14:22 ` Liliana Marie Prikler 2021-10-30 10:42 ` [bug#50873] [PATCH v3 2/8] guix home: import: Allow multiple modules to be imported for each service Xinglu Chen 2021-10-30 10:42 ` [bug#50873] [PATCH v3 3/8] guix home: import: Fix module name for Bash service Xinglu Chen 2021-10-30 11:50 ` Julien Lepiller 2021-10-30 10:42 ` [bug#50873] [PATCH v3 4/8] guix home: import: Don’t use 'slurp-file-gexp' Xinglu Chen 2021-10-30 10:42 ` [bug#50873] [PATCH v3 5/8] guix home: import: Delete duplicate modules when importing Xinglu Chen 2021-10-30 10:42 ` [bug#50873] [PATCH v3 6/8] doc: Document the ‘guix home import’ subcommand Xinglu Chen 2021-10-30 10:42 ` [bug#50873] [PATCH v3 7/8] Add tests for ‘guix home import’ Xinglu Chen 2021-10-30 10:42 ` [bug#50873] [PATCH v3 8/8] guix home: import: Call ‘local-file’ with ‘name’ Xinglu Chen 2021-10-30 23:01 ` [bug#50873] [PATCH 0/5] Fixes to ‘guix home import’ Ludovic Courtès 2021-10-31 17:38 ` Xinglu Chen 2021-11-01 6:31 ` Andrew Tropin 2021-11-06 17:00 ` Ludovic Courtès
Code repositories for project(s) associated with this public inbox https://git.savannah.gnu.org/cgit/guix.git This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).