[PATCH 0/5] Fixes to ‘guix home import’

DoneSubmitted by Xinglu Chen.
Details
7 participants
  • Andrew Tropin
  • Antero Mejr
  • Oleg Pykhalov
  • Julien Lepiller
  • Liliana Marie Prikler
  • Ludovic Courtès
  • Xinglu Chen
Owner
unassigned
Severity
normal
X
X
Xinglu Chen wrote on 28 Sep 19:33 +0200
[PATCH 0/5] Fixes to ‘guix home imp ort’
(address . guix-patches@gnu.org)
cover.1632849969.git.public@yoctocell.xyz
This series makes some fixes to the ‘guix home import’ subcommand whichbrings it into a usable state.
The last patch documents the subcommand in the manual.
As a sidenote, the ‘manifest->code’ procedure in (guix scripts homeimport), which is based on ‘manifest->code’ from (guix profiles) shouldprobably 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
-----BEGIN PGP SIGNATURE-----
iQJJBAEBCAAzFiEEAVhh4yyK5+SEykIzrPUJmaL7XHkFAmFTUdYVHHB1YmxpY0B5b2N0b2NlbGwueHl6AAoJEKz1CZmi+1x5tMkP/RaFKrwuVlmXoVx4nTb8gV7oQErPKtc+q8zhehNgLX+CTgOXUDp0PJ6XRQ6Z+BfMITogrxPBIzuhvx2VksNIpxIVpKn5HP7hH1u8rbApeONLyTdbuluQRP40Oj4yUvB/g6Art1Qeqg5ZBfagCaVEAYaFGuPc5TyT+b53NfATrLysWX5q4MnEMIHllJR/Ku8QLB59Uu31oCAoDfF1ANs0CNMIwrWXJR0nG6PUX/ic1SMuWZxcy+TcjLdeY5JhXfYK/9S8I2XkWjFTYE32RpF3xjpj3F1z8ewzIpRZKDqlFVDawMyigH8fyOSwQxLi5tTwEnnnJS9h/oBmEa879uOxkBjwn/DmSGUbazquk2q84IwJNi9SpXCfwPjxXtIVhc+ryPa93BSr9a9812PTC1jtlt3P1fWcx+KaE8neCAOe8RXy7AsRg9C6G5+Gv/FaI3kLVZ0Y5vRa27Bc9RnnRhLEVNMTA/bCjXKeuuXMaPg9UWDOcL4vEznrK6xJj39qqmtyF8IgESbK0MKOsXk8YGT355NbCbszwspv+EPo88NhdAO/NhWK7oXYNHW8Mixgqs5NfQ33aUTXxp6nMFkjRDdSZr1nWFAgoEFoHvowz5ymk4WLXWgBwcBmCwGUwQYzWtFjA0+uH6aaik1RNTrtXIqKdxsKloizt2pB2PFHZBj0WnBk=a4L2-----END PGP SIGNATURE-----
X
X
Xinglu Chen wrote on 28 Sep 19:35 +0200
[PATCH 1/5] guix home: import: Make the user to specify a destination directory.
(address . 50873@debbugs.gnu.org)
649c8f3218460dea0ec6cca46064150224374f89.1632849969.git.public@yoctocell.xyz
Copy the appropriate the relevant configuration files to the destinationdirectory, 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, sowhen 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(-)
Toggle diff (149 lines)diff --git a/guix/scripts/home.scm b/guix/scripts/home.scmindex 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) (0diff --git a/guix/scripts/home/import.scm b/guix/scripts/home/import.scmindex 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
X
X
Xinglu Chen wrote on 28 Sep 19:35 +0200
[PATCH 2/5] guix home: import: Allow multiple modules to be imported for each service.
(address . 50873@debbugs.gnu.org)
100bd160a58a65442ec68fb2f83e2dc3291224e0.1632849969.git.public@yoctocell.xyz
Previously, only one module could be imported for each service, e.g., only(gnu home-services shell) could be imported when generating the Bash servicedeclaration. However, for some services, multiple modules might need to beimported 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(-)
Toggle diff (105 lines)diff --git a/guix/scripts/home/import.scm b/guix/scripts/home/import.scmindex 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
X
X
Xinglu Chen wrote on 28 Sep 19:35 +0200
[PATCH 3/5] guix home: import: Fix module name for Bash service.
(address . 50873@debbugs.gnu.org)
4c4666a12f67c76b463cc7701319e68b9b809def.1632849969.git.public@yoctocell.xyz
* 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(-)
Toggle diff (15 lines)diff --git a/guix/scripts/home/import.scm b/guix/scripts/home/import.scmindex 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
X
X
Xinglu Chen wrote on 28 Sep 19:36 +0200
[PATCH 4/5] guix home: import: Delete duplicate modules when importing.
(address . 50873@debbugs.gnu.org)
7063704a274d99c8ea0bdc437a05b74e9fd78a49.1632849969.git.public@yoctocell.xyz
Two different services might require the same module(s), so delete duplicateswhen 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(-)
Toggle diff (26 lines)diff --git a/guix/scripts/home/import.scm b/guix/scripts/home/import.scmindex 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
X
X
Xinglu Chen wrote on 28 Sep 19:36 +0200
[PATCH 5/5] doc: Document the ‘guix hom e import’ subcommand.
(address . 50873@debbugs.gnu.org)
e2be996cf4e3b3140a4c928c53dc37721c783bdc.1632849969.git.public@yoctocell.xyz
* doc/guix.texi (Invoking guix home): Document ‘guix home import’.--- doc/guix.texi | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+)
Toggle diff (46 lines)diff --git a/doc/guix.texi b/doc/guix.texiindex 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
X
X
Xinglu Chen wrote on 28 Sep 20:59 +0200
Re: [bug#50796] [PATCH] gnu: Add pn.
(address . 50873@debbugs.gnu.org)(name . Antero Mejr)(address . antero@mailbox.org)
87lf3g34rb.fsf@yoctocell.xyz
On Fri, Sep 24 2021, Antero Mejr via Guix-patches via wrote:
Toggle quote (2 lines)> * gnu/packages/telephony.scm (pn): New variable.
The ‘libphonenumber’ package is also added; this should be split intopatches, each adding one new package.
Toggle quote (57 lines)> ---> Add pn and its dependencies.> It's a phone number CLI tool used by Linux phone GUIs like SXMO.>> gnu/packages/telephony.scm | 72 ++++++++++++++++++++++++++++++++++++++> 1 file changed, 72 insertions(+)>> diff --git a/gnu/packages/telephony.scm b/gnu/packages/telephony.scm> index 48bbe12920..9015cf536a 100644> --- a/gnu/packages/telephony.scm> +++ b/gnu/packages/telephony.scm> @@ -20,6 +20,7 @@> ;;; Copyright © 2020, 2021 Maxim Cournoyer <maxim.cournoyer@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,72 @@ Initiation Protocol (SIP) and a multimedia framework.")> telephony functionality into custom Telegram clients.")> (home-page "https://github.com/zevlg/libtgvoip")> (license license:unlicense)))> +> +(define-public libphonenumber> + (package> + (name "libphonenumber")> + (version "8.12.33")> + (source> + (origin> + (method git-fetch)> + (uri (git-reference> + (url "https://github.com/google/libphonenumber")> + (commit (string-append "v" version))))> + (file-name (git-file-name name version))> + (sha256> + (base32> + "0r12icyig6jy0v87j9n3w14acfa2yfckzzfbmnjx1hww6qc9ih25"))))> + (build-system cmake-build-system)> + (arguments> + `(#:tests? #f
There should be a comment explaining why tests are disabled.
Toggle quote (5 lines)> + #:phases> + (modify-phases %standard-phases> + (add-after 'unpack 'enter-dir> + (lambda _ (chdir "cpp") #t)))))
Phases don’t have to return #t.
Toggle quote (11 lines)> + (inputs> + `(("boost" ,boost)> + ("googletest" ,googletest)> + ("protobuf" ,protobuf)> + ("icu4c" ,icu4c)))> + (home-page "https://github.com/google/libphonenumber")> + (synopsis "C++ library for phone number parsing")> + (description> + "libphonenumber is Google's common Java, C++ and JavaScript library for> +parsing, formatting, and validating international phone numbers.")
I would use @code{libphonenumber}.
The package doesn’t seem to be reproducible; ‘guix build libphonenumber--rounds=2’ fails with
Toggle snippet (3 lines)guix build: error: derivation `/gnu/store/a0vycg9ic70bziygn098bbvw4hy39zzb-libphonenumber-8.12.33.drv' may not be deterministic: output `/gnu/store/1ifj4ndpf3mv8nwbjp0gzrx5jpjvghgb-libphonenumber-8.12.33' differs
Could you look into this?
Toggle quote (20 lines)> + (license license:asl2.0)))> +> +(define-public pn> + (package> + (name "pn")> + (version "0.9.0")> + (source> + (origin> + (method git-fetch)> + (uri (git-reference> + (url "https://github.com/Orange-OpenSource/pn")> + (commit (string-append "v" version))))> + (file-name (git-file-name name version))> + (sha256> + (base32> + "1lvzb0yixj7wmmqzsri20k9nn3gf06j0yjvmg2mi1zihywq7s4dx"))))> + (build-system cmake-build-system)> + (arguments> + `(#:tests? #f
Why are tests disabled?
Toggle quote (18 lines)> + #:phases> + (modify-phases %standard-phases> + (add-after 'unpack 'sub-bin-path> + (lambda _> + (substitute* "CMakeLists.txt" (("DESTINATION \\$\\{AWKLIBPATH\\}")> + "DESTINATION bin")))))))> + (inputs> + `(("libphonenumber" ,libphonenumber)> + ("icu4c" ,icu4c)> + ("protobuf" ,protobuf)> + ("gawk" ,gawk)))> + (home-page "https://github.com/Orange-OpenSource/pn")> + (synopsis "Command-line validation tool for phone numbers")> + (description> + "pn is a tool that allows command line user/programmers to operate on> +phone numbers (get validity information, reformat them, or extract numbers> +from a text snippet), using libphonenumber.")
I suggest
@code{pn} provides a command line tools that allows on to operate on phone numbers (get validity information, reformat them, or extract numbers from a text snippet), using @code{libphonenumber}.
-----BEGIN PGP SIGNATURE-----
iQJJBAEBCAAzFiEEAVhh4yyK5+SEykIzrPUJmaL7XHkFAmFTZikVHHB1YmxpY0B5b2N0b2NlbGwueHl6AAoJEKz1CZmi+1x5OO0P/1Rxx51OXlTRsGt1+4D5VatanM5tyBNIjzUdPVdJF4q3JYgH9WWwSHEysUlI18taLmVn+XcTUOcMiBiMf8cU8rLEgcol2TYpzU8E4s6qijF5VSF7GN8+6fT3SvgbgneGSriCnGTOM1DaZM2ZRCdtX4rOYK3taKNbTdKjUD5PDlNycoRQY/SSvrOftSuWLcUhcjS0kDjoQFL8QG7ZP2OUalBf4kfEIzoUOPJe5AYGor9b15YPiEGdghgMVRBWdSGlmkEO9PREtZPkSpilg4OicOkDuhrJNadhOuTvAwFKFdMUcaTyg1nqvQdwqWUYcHDIDsYDga5gDM4TrdzgUdhpd44qirRnJW3lEbiDkj7+SO+jd1yYcUTaTMcDimlzuGuGFVyyX0U/rtYI2kNeESpGyab7zdPtM+oO0YkrWfDG1itr1jhGbluJk10PGqUA4M44o76uTTkqsI1F5U+90oZ3ulgZnLxb7iBT4sJvjHOodRW/swUZkmvbgkhGx1A+kpCpz7Cg+yb6Qr4Q47BuPpwg6zKVFmIWTEsFH4GpPR1eVKTkjycXwpxHWyWZnc1eyBi9EO3DqZXxvOVJxzZRGPx+dYJ3JznlI6oGCIt3X4IQ2bHEc2lW1dcFG0+APTM5fxYNOyMnqcMsjJu7+d/BkYZRL5RHTFsvQfwZdt6NmeGYSmUg=1DBg-----END PGP SIGNATURE-----
A
A
Antero Mejr wrote on 28 Sep 22:52 +0200
[PATCH 1/2] gnu: Add libphonenumber.
(address . 50873@debbugs.gnu.org)(name . Antero Mejr)(address . antero@mailbox.org)
20210928205227.25833-2-antero@mailbox.org
* gnu/packages/telephony.scm (libphonenumber): New variable.--- gnu/packages/telephony.scm | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+)
Toggle diff (68 lines)diff --git a/gnu/packages/telephony.scm b/gnu/packages/telephony.scmindex 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
A
A
Antero Mejr wrote on 28 Sep 22:52 +0200
[PATCH 2/2] gnu: Add pn.
(address . 50873@debbugs.gnu.org)(name . Antero Mejr)(address . antero@mailbox.org)
20210928205227.25833-3-antero@mailbox.org
* gnu/packages/telephony.scm (pn): New variable.--- gnu/packages/telephony.scm | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+)
Toggle diff (45 lines)diff --git a/gnu/packages/telephony.scm b/gnu/packages/telephony.scmindex 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
A
A
Antero Mejr wrote on 28 Sep 22:52 +0200
[PATCH 0/2] Add pn.
(address . 50873@debbugs.gnu.org)(name . Antero Mejr)(address . antero@mailbox.org)
20210928205227.25833-1-antero@mailbox.org
Thanks for the suggestions Xinglu, I updated with the changes.
Toggle quote (3 lines)> 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.drvsuccessfully built /gnu/store/dyf2a70slkvfxf4qcims3q69a51ydb0x-libphonenumber-8.12.33.drv
A
A
Andrew Tropin wrote on 30 Sep 09:08 +0200
Re: [bug#50873] [PATCH 5/5] doc: Document the ‘ guix home import’ subcommand.
(name . Ludovic Courtès)(address . ludo@gnu.org)
87h7e2o802.fsf@trop.in
On 2021-09-28 19:36, Xinglu Chen wrote:
Toggle quote (44 lines)> * 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 overalllooks ok.
I'll make a rationale behind this function and the approach I picked inhome services config serializers and will prepare some examples nextweek. Maybe it will convince Ludovic or maybe I'll change my mind andrework configuration records for home services to use file-like objects.
Toggle quote (6 lines)> + (local-file "/home/alice/guix-config/.bashrc")))))))))> +@end example> +> @end table> > @node Documentation
-----BEGIN PGP SIGNATURE-----
iQIzBAEBCgAdFiEEKEGaxlA4dEDH6S/6IgjSCVjB3rAFAmFVYn0ACgkQIgjSCVjB3rAXpw//Xy3kH7/bzCT5yRf1wKEsHX7Bs1eN0S51kkZY5fYQy9oqa9GwmQe0bMX7xu3UMJhRt8ndFjLPtUIArVeSBhHFOi8uPpfBJPZzJQh1lp2XXxNx+ldp1VKHCuzOE/AxP21BJLKYZ3x+C2gO33nD/EhAg2d2NvRmC7sYG81EloDmOrgoVgfnp9REtbP/hsK0S4H+XFNIbHYQ/Llt554Oz43crism4S277KqiDuRlcxAfApGCPO5/2iGLFGQttEYtrDTEcVQtWqvAcA4I1y0wegxgUYkpTXa1Y54taMnQK3xfwm189XBpnQa0nBGJ+GcLIxVtcW6O28fB3Ocp5nqlptaQyEhB4frVJCPG+JQjSiRXvfyLuz7Lj3dXIS/r5RjWBszzNIykzHvpnw2cpLughK0/yk9vnOcDpGnJOmLYdXCRPJ9hylSCXsuJPdzMt7CtI+galfI2N8fP5sNj08sazzVEqRS+l5uQyOiHVLKQY2Ez8yXnWJ9Scpzr275zSPNsN2NOtC6xrClauouRhPFFLNPsNv/WpGMZD8CyYHEjXogTrePGm8RJG50moFKQu1HRIs/TKZ7OAYheJKXLuaUpuA3kBVXGZeARgoQpkDS/sq/V9TaB9Mq/MwXe1Bnpwa1O/87WQw9KPUFgpSPyAdk1aAzZt6cmxtwVzlnWRuFsm8bwdQw==CSlo-----END PGP SIGNATURE-----
X
X
Xinglu Chen wrote on 1 Oct 07:08 +0200
(name . Ludovic Courtès)(address . ludo@gnu.org)
87y27dl4ca.fsf@yoctocell.xyz
On Thu, Sep 30 2021, Andrew Tropin wrote:
Toggle quote (49 lines)> 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.
Toggle quote (6 lines)> 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’ discussionto reach an consensus, then I can send a v2 for this series. :-)
-----BEGIN PGP SIGNATURE-----
iQJJBAEBCAAzFiEEAVhh4yyK5+SEykIzrPUJmaL7XHkFAmFWl8YVHHB1YmxpY0B5b2N0b2NlbGwueHl6AAoJEKz1CZmi+1x5TlkQAKM1l2hFEfwGDQXUHT1E7raJE0pZlLHO/q6OcJ4JlHJL9/Bq8QN9mJwSqVTI7T4d3oyPI9v+//20/vlZi3qoFL835/iOS7BWLUE9Il5HF4IE61dsgpA/e96+xEL9Lm5UkG5kdgT2RZc4hP5ePgbZ7Yve1vYizFXZqSsmvxyrqT+nHy1dOgitHee9l2tYTHHoShLuZQ9bT3xKHFjDEmtR298jbqtsJQ52fPP/BDHekY4kcMj3Y4ynKr5pql6hPlwHkyZDZfkuLoAznt9S21zDexGkAzFuIgq+yM0pdgmfHjEkuZKgDEIBjaqgVN5rJR9V/Y0heoKXM0Au3VW9pzDNv5MkVePZanUz3fJOuyC9sFHslJCjscFDnBR6KfG/jho7rOhPTZlu9+le6QGfR8rId4f3ha5drA8GewJwwXw4cpTaeyJfORhCa8aujjd5YcE+XJTcpfQSCJ6UZWVi4qFD07UYzGr7ANdj1gccYVZk33rWN3K3cW1CcTTMK0gOSXK5Asc659FGtyojxRDD4Fzp2qMXSjShuYLzwwjmP9nLRNVt7KSxPZdT03SeHigYVQY2XvjFtP29B/sTVtVAKOE6mlo7EPCam3Rg1jVXY+caTO81EU1dtbMHYRJET/z9l9NCNvnFiWhbZlL1Yilsl2YYd+E2QTiNr3+13qyXQ5KU4B55=cHO7-----END PGP SIGNATURE-----
L
L
Ludovic Courtès wrote on 2 Oct 17:10 +0200
Re: bug#50873: [PATCH 0/5] Fixes to ‘guix home import’
(name . Xinglu Chen)(address . public@yoctocell.xyz)
87k0ivwjho.fsf_-_@gnu.org
Hi,
Xinglu Chen <public@yoctocell.xyz> skribis:
Toggle quote (2 lines)> On Thu, Sep 30 2021, Andrew Tropin wrote:
[...]
Toggle quote (14 lines)>> 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 thesituation of Guix System services so I see no reason to do thingsdifferently.
Apart from this bit, the documentation part LGTM.
Thank you, Xinglu!
Ludo’.
L
L
Ludovic Courtès wrote on 2 Oct 17:13 +0200
(name . Xinglu Chen)(address . public@yoctocell.xyz)
87czonwjcu.fsf@gnu.org
Xinglu Chen <public@yoctocell.xyz> skribis:
Toggle quote (17 lines)> 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 thinkScheme-level tests like we have for the ‘guix import’ code would befine. It would also help review because it’d give a clearer view of howthis is supposed to work.
Thanks for following up on this!
Ludo’.
X
X
Xinglu Chen wrote on 2 Oct 20:45 +0200
Re: [bug#50873] [PATCH 0/5] Fixes to ‘guix home import’
(name . Ludovic Courtès)(address . ludo@gnu.org)
877devnu3f.fsf@yoctocell.xyz
On Sat, Oct 02 2021, Ludovic Courtès wrote:
Toggle quote (24 lines)> 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!
Toggle quote (2 lines)> Thanks for following up on this!
You are welcome! :-)
-----BEGIN PGP SIGNATURE-----
iQJJBAEBCAAzFiEEAVhh4yyK5+SEykIzrPUJmaL7XHkFAmFYqOQVHHB1YmxpY0B5b2N0b2NlbGwueHl6AAoJEKz1CZmi+1x5p78P/i/mDTCjhgXA7uK9D19DUsnro4lvaUyjeP31y40iyToxOu4zGKasxTk/Lhpj6tJwNpCtiY7pmfOU5KX8e4Q+/x8IhE8U5WGbf7c04W6th2uPbrYh83qJNQPhBobODpqOpQVsAUDB8D4GZkPfcNZ1g9wMPxpYX8idU4+RYyNNV5dhda3Q48JaIulOo5x93eel1yNF6jeNdV1V0XiWVuwRzZTpfEf4+gKPSuiAUu6nykFWApdmAu9Lktz5tc/o/6MqVAbbh+FjBgSI5dMO8rt4+Ra2V8DahdzeNTNLOOzhd8qnrVNX08f+SWE5Tuc+Ey8TPoBEwqVZTEkY2hQGq3ggvHC/aumtpwFbo8P9HozjsG2eOfOQ6t+WcYBaWHjnaWWIYal0zOhXVMlorsOAa6qHKXQ5CnJnzA6+9VkoFou3T9tZXblOS/lrV+q75Mpu5tw/1V0SyTfYuesrD4/+kX46vTYJ/QZYd8j2MS97HUUno9A2PbMwPol477j3B0swEIHAjTEUBMMAatj0f+1jZFzmiRxWyjGyimulEi1xMiAVjJ0WbD1tMtchdbvqikuFlQhsOvyXxXvvcPVSSDAsQrbylRwQRLqARWbNlgSKyivwVtlscLAedmZlH0njsnt/WaGs0uAofelwuk0O3L7wUExoJ17e8iv/MTvF9ugAe+RGwAXK=CSLN-----END PGP SIGNATURE-----
X
X
Xinglu Chen wrote on 10 Oct 12:19 +0200
[PATCH 0/7] Fixes to ‘guix home imp ort’
(address . 50873@debbugs.gnu.org)
cover.1633861021.git.public@yoctocell.xyz
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
-----BEGIN PGP SIGNATURE-----
iQJJBAEBCAAzFiEEAVhh4yyK5+SEykIzrPUJmaL7XHkFAmFivk0VHHB1YmxpY0B5b2N0b2NlbGwueHl6AAoJEKz1CZmi+1x5vSgP/2767jQ3mUl57HqAX7NFWSqSk96Hvzd6BnavuQguchT5q2Fh5LJPlhTUhZlspY+qqv7fbTo7g2llpC7GfzVYVB5a2CT9qN3XcTL+pGRH/YA0vXg6/aOnVXNADxjg9GIQvKtPBLieH6n3JWHeHYJuu+YGVghniF1991tibtEsQnDQvgKJ158OVhpOXVQCyHy51O5qag7lgNQUrCtTcoIqbpHVc8ZrkVLliT2iblbFICUn8GjVLq8QGV4n++Y8TJAsarWhMu0PkpR2mZc9y20K4nxwBKWiZQB81O7ULxxcrnESAM74+JgEhTcmJci4yLxzFePo9RSoeb+FLq7d4oNA002YZMC1eHd9nwP2UvuePQtfmB7vppupinoIMP3aDw7pC9sN9JriODGv8h4fDfuBcux3qTNCjvzIwxYxOjmBaf3/7b2sI4Thmo5aNxfERqMrRupgFaRzquXr4oHbpjaeMNjHNa150jPJ4f+mUE9yEiwZokQFtcG6CYkQea9W1FaTgGZhtOIFvn2j13O2cLRQszr+7kixjdxjMJ61dkd1Gbc6NxrS36aVXmqf1hpihvqdqyoCKJoUNkPiHoBH9xa92zRN8+O4kRnX00o5XKwK4cUUuPni++68Yr6NFOVdNgyr6diV3b3/iAtfjU+hzV7OutWlotYmchsUgfR65Ys38N1a=g6ar-----END PGP SIGNATURE-----
X
X
Xinglu Chen wrote on 10 Oct 12:20 +0200
[PATCH 1/7] guix home: import: Make the user to specify a destination directory.
(address . 50873@debbugs.gnu.org)
9db0424f9494d3d15e534eb75773ae9bd3f33cb3.1633861021.git.public@yoctocell.xyz
Copy the appropriate the relevant configuration files to the destinationdirectory, 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, sowhen 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(-)
Toggle diff (148 lines)diff --git a/guix/scripts/home.scm b/guix/scripts/home.scmindex 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) (0diff --git a/guix/scripts/home/import.scm b/guix/scripts/home/import.scmindex 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
X
X
Xinglu Chen wrote on 10 Oct 12:20 +0200
[PATCH 2/7] guix home: import: Allow multiple modules to be imported for each service.
(address . 50873@debbugs.gnu.org)
ac6637753c1939bddd18c285e4ce0a5937d4cb02.1633861021.git.public@yoctocell.xyz
Previously, only one module could be imported for each service, e.g., only(gnu home-services shell) could be imported when generating the Bash servicedeclaration. However, for some services, multiple modules might need to beimported 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(-)
Toggle diff (105 lines)diff --git a/guix/scripts/home/import.scm b/guix/scripts/home/import.scmindex 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
X
X
Xinglu Chen wrote on 10 Oct 12:20 +0200
[PATCH 3/7] guix home: import: Fix module name for Bash service.
(address . 50873@debbugs.gnu.org)
0ecf026f4196f1f3abb10f917e8a566052f70ed6.1633861021.git.public@yoctocell.xyz
* 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(-)
Toggle diff (15 lines)diff --git a/guix/scripts/home/import.scm b/guix/scripts/home/import.scmindex 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
X
X
Xinglu Chen wrote on 10 Oct 12:20 +0200
[PATCH 4/7] guix home: import: Don’t us e 'slurp-file-gexp'.
(address . 50873@debbugs.gnu.org)
a3b10cf163a3535746a583de1add669e1101ebfe.1633861021.git.public@yoctocell.xyz
‘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(-)
Toggle diff (32 lines)diff --git a/guix/scripts/home/import.scm b/guix/scripts/home/import.scmindex 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
X
X
Xinglu Chen wrote on 10 Oct 12:20 +0200
[PATCH 5/7] guix home: import: Delete duplicate modules when importing.
(address . 50873@debbugs.gnu.org)
2814010aadd95c389a54922958d1f3ffedeec106.1633861021.git.public@yoctocell.xyz
Two different services might require the same module(s), so delete duplicateswhen 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(-)
Toggle diff (26 lines)diff --git a/guix/scripts/home/import.scm b/guix/scripts/home/import.scmindex 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
X
X
Xinglu Chen wrote on 10 Oct 12:20 +0200
[PATCH 6/7] doc: Document the ‘guix hom e import’ subcommand.
(address . 50873@debbugs.gnu.org)
b86d5dab6ff86d4dab6907e68e87b24d9ebef8e1.1633861021.git.public@yoctocell.xyz
* doc/guix.texi (Invoking guix home): Document ‘guix home import’.--- doc/guix.texi | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+)
Toggle diff (45 lines)diff --git a/doc/guix.texi b/doc/guix.texiindex 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
X
X
Xinglu Chen wrote on 10 Oct 12:20 +0200
[PATCH 7/7] Add tests for ‘guix home import’.
(address . 50873@debbugs.gnu.org)
197cab14424f4d28ece9e80981d2a4e142dc4791.1633861021.git.public@yoctocell.xyz
* 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
Toggle diff (210 lines)diff --git a/Makefile.am b/Makefile.amindex 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.scmindex 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.scmnew file mode 100644index 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
O
O
Oleg Pykhalov wrote on 11 Oct 15:00 +0200
Re: bug#50873: [PATCH 0/5] Fixes to ‘guix home import’
(name . Xinglu Chen)(address . public@yoctocell.xyz)
87mtnf1zt0.fsf_-_@gmail.com
Hi,
Xinglu Chen <public@yoctocell.xyz> writes:
[…]
Toggle quote (7 lines)> +;; 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.
Toggle snippet (7 lines)(define-module ... #:use-module ((guix build syscalls) #:select (mkdtemp!)) ...)
(mkdtemp! "/tmp/guix-home-import-test.XXXXXX")
Toggle quote (18 lines)> +> +(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?
[…]
Toggle quote (17 lines)> +(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!'.
Toggle quote (21 lines)> +> +(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 emptydirectory. Then a pasted the generated code to '/tmp/foo/home.scm'file.
Toggle snippet (5 lines)oleg@guixsd ~/src/guix [env]$ ./pre-inst-env guix home build /tmp/foo/home.scm/tmp/foo/home.scm:487:11: error: service: unbound variablehint: Did you forget `(use-modules (gnu services))'?
OK, added missing (use-modules (gnu services)).
Toggle snippet (5 lines)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 variablehint: Did you forget `(use-modules (guix gexp))'?
OK, added missing (use-modules (guix gexp))
Toggle snippet (5 lines)oleg@guixsd ~/src/guix [env]$oleg@guixsd ~/src/guix [env]$ ./pre-inst-env guix home build /tmp/foo/home.scmguix home: error: invalid name: `.bashrc'
Now, I need to rename .bashrc to dot-bashrc and .bash_profile todot-bash_profile. Maybe we should save all dot file with a 'dot-'prefix by default?
Oleg.
-----BEGIN PGP SIGNATURE-----
iQJIBAEBCgAyFiEEcjhxI46s62NFSFhXFn+OpQAa+pwFAmFkNXsUHGdvLndpZ3VzdEBnbWFpbC5jb20ACgkQFn+OpQAa+py98BAAw2qrJNXtEuNXJyUws9obypmDH2aBNtX29V0AjXhmVpoY60rv41I8OVeammAMLAX9974u8Lka1vNfiVKd14JkHqRutKurI6qPbgBjUCI0MSDwl2MrUbq9y/QMw9fmo/PSY+TXE6Zfzg7hN2XLMllwfKVSD5JVrSE67+OybUDPI2Nopx6TEJydwTGdBiRVQBWo4nw7fhqzWYXQtkNoe/BeoAwoybLFwW8+rL9JyISch66f2TSduyVcHXp8F07r9hzCb9S9PqpiQ6EtaVUJC37uJ/jW5b3aQ7r/EVygZMD4bHX5qz5gOe+Cu5HoXUuz/07q2S+E9spjZ+1hVGUltEm6oPU8xLjU/FN9dbMuSLZfzew3UoE6NqNa4bNDjSM5LRO2ZIi3E9N8WCj5ggJVgXziEsns94AaD0obuR9lPATcXzK2XTqdpGK1jdvDKeaNfZQA7gnkIkV1TMbj2p2u2dFVdaM5zjcUtWOLC/6ypLZMlo+g/RygeMWWAW2mba2Yz+05kzaIxucgXxx51fYJWVX8LBuR5+XMpQwwB6W9jEicJu07RFfE357mj4LPuRhfV071ngKi4UTtoz+MxYE9TE6pu9BGPp8zqo3UU9zODk4HZD4NL2dkQEOTesoWXfIdW8MYoxhaKgxYMmEKxg8eLBPopu4EUJE2gmEGq1y7C00Eb/k==mkRy-----END PGP SIGNATURE-----
L
L
Ludovic Courtès wrote on 13 Oct 11:24 +0200
(name . Xinglu Chen)(address . public@yoctocell.xyz)
87v921qnv3.fsf_-_@gnu.org
Hello,
Xinglu Chen <public@yoctocell.xyz> skribis:
Toggle quote (16 lines)> 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!
Toggle quote (7 lines)> * 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.
[...]
Toggle quote (3 lines)> +(define %destination-directory> + (make-parameter (string-append (getenv "HOME") "/src/guix-config")))
Instead of making it a parameter, with a default value that looks fishybut is never actually used :-), can we make it an explicit parameter of‘generate-bash-module+configuration’?
Otherwise LGTM!
Thanks,Ludo’.
L
L
Ludovic Courtès wrote on 13 Oct 11:25 +0200
(name . Oleg Pykhalov)(address . go.wigust@gmail.com)
87r1cpqns1.fsf_-_@gnu.org
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 addressingOleg’s comments?
Thanks,Ludo’.
L
L
Ludovic Courtès wrote on 29 Oct 09:36 +0200
(name . Oleg Pykhalov)(address . go.wigust@gmail.com)
87wnlw2sfy.fsf_-_@gnu.org
Hello!
It’s been a month already. Oleg, perhaps you could make those finalmodifications on behalf on Xinglu so we can move forward? We’re almostthere!
Thanks,Ludo’.
Ludovic Courtès <ludo@gnu.org> skribis:
Toggle quote (9 lines)> 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’.
X
X
Xinglu Chen wrote on 29 Oct 15:37 +0200
(name . Ludovic Courtès)(address . ludo@gnu.org)
87v91g7y0w.fsf@disroot.org
Hi, (sorry for taking so long to get to this!)
On Wed, Oct 13 2021, Ludovic Courtès wrote:
Toggle quote (38 lines)> 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. :-)
-----BEGIN PGP SIGNATURE-----
iQJJBAEBCAAzFiEEAVhh4yyK5+SEykIzrPUJmaL7XHkFAmF7+P8VHHB1YmxpY0B5b2N0b2NlbGwueHl6AAoJEKz1CZmi+1x5bxUP/273Md93z9+YNm4vRYPjbaC/EBQB0IdCRVkmcUrqOkmv25RDOVSoHDMMFfYS2wf0lAIh23rCOdXUIH+QJV/vtYgv0tNHljVUySJxZ/74M0YB+FCikJA+/BVG79eNoLma47aYoK0ZBLKXuUnIladGFpC6SUQrGqmJ4EteGWBdpSrimATvwY2YiCQjSbsCG+moMhV2V6H8u/pXxZtPIQcDEoGN75tJfMBsYDDvCvZCZFY3xw75JZ61K807RwGn7t696LBIstfLHdlkP+28ILDyQyz5t9+ByKQv9bi8KcN2C8NXW5ProdwWs2Kxk/M6aXCj2XFLVXbftaP8ZUTD3JzOnGBJvNn7ZQ+CNqjE78dwcgUwXHVHLXlluZ6FAwiZrqjYeLfUG+kSuUNXXQG00MFNiL5qSGQPJoHX1hwgYsueosgAYn0nXAynf2FbNqoOyHSv9xzlYZU+bN1t8hPQ8a9hikwE4Z6DWZpD0lyGlU6xGYpGtckPNhhWCIjljGxw6DV7Gm7hw9A8/ft4oJrsIwztZA+1pskPQiatFUlpljZuuMHDlWkV8URxmNE8yY19fOe5dPN2t5/AiNxz+lKUAgxaUyQPxLVrQ0eOVNd3d+47mHggkKh9v9Grs0L2/h+y+bgPlSojb85dztzQL03r/rYSRwWkrJEhpuUtbXZFHPMqQP66=TzQO-----END PGP SIGNATURE-----
X
X
Xinglu Chen wrote on 29 Oct 15:47 +0200
(name . Oleg Pykhalov)(address . go.wigust@gmail.com)
87sfwk7xiw.fsf@disroot.org
On Mon, Oct 11 2021, Oleg Pykhalov wrote:
Toggle quote (23 lines)> 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?
Toggle quote (20 lines)>> +>> +(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…
Toggle quote (19 lines)>> +(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 shouldbe ‘%destination-directory’.
Toggle quote (51 lines)>> +>> +(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.
-----BEGIN PGP SIGNATURE-----
iQJJBAEBCAAzFiEEAVhh4yyK5+SEykIzrPUJmaL7XHkFAmF7+4cVHHB1YmxpY0B5b2N0b2NlbGwueHl6AAoJEKz1CZmi+1x5+dAP/R50fg8PIkhxvJUUXNPNtbg7HuM489wVBoz3nfrysKu9VWfhtxXnzmdIE3ckm45DYUKGhADOO4XWVOhBJhdeec76OpNR3c8sgC60u8ViCO1QGFWc8zxFRN801kmxLTCohNdZVPTwysw3aeCb4rfPexG2VUIesiekV4okGGjPEruU2bkAY60O+xvjpCx3PfEvSyY4bv0xobQ5KBeX+wxm/338BINdGmmRZ1m7AI2yrMwxhtO76HDwqW+IRY5NmMiBp+OhkaixL9fOWM/9n7Xwt3qFdAWaZ0WK38o28RtTUSxg92gXYDs1dajhSwRTm6Wj9jc4FrzY8RBiuh2NDnWYvnvQRdrCYlRLRue2fHpO5nPIAmUPASKruzUZG5otzPZ/EborxTKOyyLNpWoLkhY4kce9bjsqiOOT8jGJEuCA3ZC/3OqfnwNiLQCdNnyOWgNnE6qYEgql2Couq2JgpQNgiAlMLWDUY0d+8ZLsU7hpqgoTyk7XVGjl/IzEcA2IMDSR/mrFPr2bV446GObePykTryj2a0lCtEqUsQrfyDyL/37ET4Y9HNarZqqoJE6THLEUC38+PLbpy7uNVdFsq/j7HYL+1PH5REJHsZJ9Dnyz4KBX8n1qMysmlgqHoTr4+5QcjGKekcuqyBoqnT3POjPXUKNdzW2y+gEF50l7Fmi3ScuZ=to73-----END PGP SIGNATURE-----
X
X
Xinglu Chen wrote on 30 Oct 12:42 +0200
[PATCH v3 0/8] Fixes to ‘guix home import’
cover.1635590221.git.public@yoctocell.xyz
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
-----BEGIN PGP SIGNATURE-----
iQJJBAEBCAAzFiEEAVhh4yyK5+SEykIzrPUJmaL7XHkFAmF9IY0VHHB1YmxpY0B5b2N0b2NlbGwueHl6AAoJEKz1CZmi+1x5l/UP/0xijD8WP/DC7nHUsmBymKTK0Isiu3nNopzGQ+bqRPZuB6qO76MG0H3Nor0zxk95Wpmju2PdehRJcq8oK+Vus+APjGcBUagG+jawaHZn+1wreqxb4JQpeF01lAYlmArtAlc8CM8rONd2g5Y2oLd07ajwgCi811X9lycAIvyetar7QLUAyNwv4gyZ2URcBx4enfwgd6OPs2j7Ggmxuz75ESHj7WfNlV4Z/zvSpCMqJAK03I9H6TFUhuVvRS9iEgzWMiXzJwJQfrar8aRtS/uYbmUlBQJo6qg9OKeksc98WaaNlclv0PQbOHXe1hdrD1v8uJ7H4TlqKSTyLKyPC5FABzEP08ufxhR9ZLLzuCAgs7SmetgvTtg92omCEQQpN3kbCeLBitwtrd/wZsOkOkSnRSasx85ImZgOUjr2tBxoCzzcSdnLOXThyUocrggqjrDhNMN69u9WjV6QYDYPANqykFRh2atkhwDzLecVV9mG+3/frq3CReDJlXCISs32gWMJS/vfhiFTgX/kNLUMsLDN1XZ9ivcIwCqDCsLHo0H96xSi8g/cfDds2LSsJtLaueyG2Du91oIanvVqBoQrq2SFdiowSZHRKfbRFezuYZJysmHx1WQw7jM830ut1JwiQvVfaVcB07HKDS22ZUe1NhKgEMXvMxvKL67IpszGLwF0FL5H=LMbt-----END PGP SIGNATURE-----
X
X
Xinglu Chen wrote on 30 Oct 12:42 +0200
[PATCH v3 1/8] guix home: import: Make the user to specify a destination directory.
4b3eb05f3fb1bfbd3e7f16c3ba5862a603372df0.1635590221.git.public@yoctocell.xyz
Copy the appropriate the relevant configuration files to the destinationdirectory, 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, sowhen 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(-)
Toggle diff (180 lines)diff --git a/guix/scripts/home.scm b/guix/scripts/home.scmindex 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) (0diff --git a/guix/scripts/home/import.scm b/guix/scripts/home/import.scmindex 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
X
X
Xinglu Chen wrote on 30 Oct 12:42 +0200
[PATCH v3 2/8] guix home: import: Allow multiple modules to be imported for each service.
1002d5577006cc804193f34237415c9707942e27.1635590221.git.public@yoctocell.xyz
Previously, only one module could be imported for each service, e.g., only(gnu home-services shell) could be imported when generating the Bash servicedeclaration. However, for some services, multiple modules might need to beimported 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(-)
Toggle diff (74 lines)diff --git a/guix/scripts/home/import.scm b/guix/scripts/home/import.scmindex 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
X
X
Xinglu Chen wrote on 30 Oct 12:42 +0200
[PATCH v3 6/8] doc: Document the ‘guix home import’ subcommand.
a97d97a95c1a7b76488866d6e9f7070beccee719.1635590221.git.public@yoctocell.xyz
* doc/guix.texi (Invoking guix home): Document ‘guix home import’.--- doc/guix.texi | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+)
Toggle diff (45 lines)diff --git a/doc/guix.texi b/doc/guix.texiindex 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
X
X
Xinglu Chen wrote on 30 Oct 12:42 +0200
[PATCH v3 3/8] guix home: import: Fix module name for Bash service.
aa7c281e80f0d76780c42a98c53868776ba3a01c.1635590221.git.public@yoctocell.xyz
* 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(-)
Toggle diff (16 lines)diff --git a/guix/scripts/home/import.scm b/guix/scripts/home/import.scmindex 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
X
X
Xinglu Chen wrote on 30 Oct 12:42 +0200
[PATCH v3 4/8] guix home: import: Don’t use 'slurp-file-gexp'.
aa6aa72a97a0497f682266207ceeee70a425d9e4.1635590221.git.public@yoctocell.xyz
‘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(-)
Toggle diff (34 lines)diff --git a/guix/scripts/home/import.scm b/guix/scripts/home/import.scmindex 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
X
X
Xinglu Chen wrote on 30 Oct 12:42 +0200
[PATCH v3 7/8] Add tests for ‘guix home import’.
92b43fa1b99c1f3c65d3985fa99579fb82b43ca8.1635590221.git.public@yoctocell.xyz
* 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
Toggle diff (224 lines)diff --git a/Makefile.am b/Makefile.amindex 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.scmindex 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.scmnew file mode 100644index 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
X
X
Xinglu Chen wrote on 30 Oct 12:42 +0200
[PATCH v3 5/8] guix home: import: Delete duplicate modules when importing.
40ca56d2d949f7a56bce56d1221396fb85e57a4d.1635590221.git.public@yoctocell.xyz
Two different services might require the same module(s), so delete duplicateswhen 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(-)
Toggle diff (26 lines)diff --git a/guix/scripts/home/import.scm b/guix/scripts/home/import.scmindex 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
X
X
Xinglu Chen wrote on 30 Oct 12:42 +0200
[PATCH v3 8/8] guix home: import: Call ‘local-file’ with ‘name’
19dd061d4f7a3aab24ecb660df01e3c6613d4ae7.1635590221.git.public@yoctocell.xyz
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): Adjustaccordingly.--- guix/scripts/home/import.scm | 20 ++++++++++++++++---- tests/home-import.scm | 3 ++- 2 files changed, 18 insertions(+), 5 deletions(-)
Toggle diff (60 lines)diff --git a/guix/scripts/home/import.scm b/guix/scripts/home/import.scmindex 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.scmindex 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
J
J
Julien Lepiller wrote on 30 Oct 13:50 +0200
Re: [bug#50873] [PATCH v3 3/8] guix home: import: Fix module name for Bash service.
(name . Xinglu Chen)(address . public@yoctocell.xyz)
20211030135029.674986c9@tachikoma.lepiller.eu
Le Sat, 30 Oct 2021 12:42:34 +0200,Xinglu Chen <public@yoctocell.xyz> a écrit :
Toggle quote (21 lines)> * 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! :)
L
L
Ludovic Courtès wrote on 30 Oct 16:17 +0200
Re: bug#50873: [PATCH 0/5] Fixes to ‘guix home import’
(name . Xinglu Chen)(address . public@yoctocell.xyz)
87sfwitx5t.fsf@gnu.org
Hi,
Xinglu Chen <public@yoctocell.xyz> skribis:
Toggle quote (28 lines)> 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 olderversion.
Ludo’.
L
L
Liliana Marie Prikler wrote on 30 Oct 16:22 +0200
Re: [PATCH v3 1/8] guix home: import: Make the user to specify a destination directory.
56a9f6fba40556abd5eae450b565b9b32129861c.camel@gmail.com
Hi,
Am Samstag, den 30.10.2021, 12:42 +0200 schrieb Xinglu Chen:
Toggle quote (2 lines)> 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 reasonabledefault like ~/.config/guix/home – alternatively, since all these filesare 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?
L
L
Ludovic Courtès wrote on 31 Oct 01:01 +0200
Re: bug#50873: [PATCH 0/5] Fixes to ‘guix home import’
(name . Xinglu Chen)(address . public@yoctocell.xyz)
8735oirub9.fsf_-_@gnu.org
Hi!
Xinglu Chen <public@yoctocell.xyz> skribis:
Toggle quote (10 lines)> 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 appliedthe 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 likethis.
The last commits improve documentation so users learn about ‘guix homeimport’ when they get started.
It’s really nice to have this tool! I find it perhaps a bit confusingto have to specify a target directory to ‘guix home import’; simplytrying to document it shows that it’s non-obvious.
I wonder if the argument should be optional (in which case the fileswouldn’t be copied). But then people are likely to run into theproblems 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 theconfiguration files of your home environment.” Thoughts?
Ludo’.
L
L
Ludovic Courtès wrote on 31 Oct 01:01 +0200
control message for bug #50873
(address . control@debbugs.gnu.org)
871r42ruaw.fsf@gnu.org
close 50873 quit
X
X
Xinglu Chen wrote on 31 Oct 18:38 +0100
Re: [bug#50873] [PATCH 0/5] Fixes to ‘guix home import’
(name . Ludovic Courtès)(address . ludo@gnu.org)
878ry96qn6.fsf@disroot.org
Hi,
On Sun, Oct 31 2021, Ludovic Courtès wrote:
Toggle quote (32 lines)> 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!
Toggle quote (8 lines)> 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.
Toggle quote (9 lines)> 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 ‘guiximport’ commands do, but it could make sense to just populate a filedirectly. I don’t really have a strong opinion on this, so if nobodyhas any objections, I could send a patch for this. :-)
-----BEGIN PGP SIGNATURE-----
iQJJBAEBCAAzFiEEAVhh4yyK5+SEykIzrPUJmaL7XHkFAmF+1J0VHHB1YmxpY0B5b2N0b2NlbGwueHl6AAoJEKz1CZmi+1x53s8P/087exvVYy0pcgXX0bbUOMHfsEV5TIzKlQ+qraX1HFwvXHImEH1hcxTUlgDE/xPXTQ31yDdxR4HJMOIOzY0Jep57YNwv5Pv9vJn+qOQL6regmlqzyKZNmYTFbQZtS2M7p6RTApKLZZl2HkpZbwV6Lt0oGyVAdnRhBfxPjm1m7rBMEInaReCNefLTrKM+Np4XiZodXZwdydmdKNEnz5rdX+eysKtcCEDm3NVH3GlOqlybpnaWDbPIBUagqSNRTRMf9i1VGsAsGcOSiqFidh+5OtpNdUb3+eIr+CqJp0DbzsrvxOOR27+zCmBrh/fjbsktDd7E3OC4yEZSuM0TPy9u+BxkFZG3kdBEQIwdlPOnKPnTvIzAr7FdggR/oyH1ESEtEMKRi66rgnVGnw/MqCygo9tb2iMA5s4mRQZJF2yuc6cyPbnke05oySk1fb3IWYPivjkqwmBVKFRPXGcLdYXeFVyKgXi3+SeYSC12ZCvoQI8V2lAdXOcm8IM8HguvNft3UCtiNLfj7SAmjkc38r6bvQSaIAXDwKMKmovlDHkscTptQAkEwHGESL1w05s1KAeUzcNWZuu4wwPm/TkPoENuAocSBqlmjq8FvaJ0A8/ly8CCRaZe0OoNxT7u+v0NAU1/FDnwngKv7hUP4ab3HKAGRaNu9I4oCVtX0fXFlw8sxoO1=IqCp-----END PGP SIGNATURE-----
A
A
Andrew Tropin wrote on 1 Nov 07:31 +0100
878ry8tmie.fsf@trop.in
On 2021-10-31 18:38, Xinglu Chen wrote:
Toggle quote (54 lines)> 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 tomake it clearer that it's not a system config.
Toggle quote (9 lines)>>>> 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
-----BEGIN PGP SIGNATURE-----
iQIzBAEBCgAdFiEEKEGaxlA4dEDH6S/6IgjSCVjB3rAFAmF/ickACgkQIgjSCVjB3rDgGg/+JyO6FTPyW8Jsc58J+8062CqNNnua/JzuAWHdC2aAsyicWAVSi6Xg4kH9263KtqG8dehXLMPu7ebo4kc9CEa/CUB+uuGnl6qyMguefYjyBBKIM7aKb4wVe2LNaJgOJuHfEf/CMiSszDUF1r/EIAIZZqmT8OfmsP86VC/YCzu8fnYe1Uox8qBqs1LLLMbsfBGRQqUaPShOvGFOYBHud1rKngVXgtJamIVpXCfFlfOMH4D4qbDvxaBNLUJdqA4Uj/C+yCFOXX6uqnI45rs5Fk7LwQC9im0N9v13cDqvR6ccSxZluN+MOu5QZ6Md9HOysQJakVzE7s3dK2JwcPBOMqfIKe/4GWWwBGGb5w/X1+zbN531FtiYZDiuGg+GK9h+bLRVpUCYkAxCYY+cHVCQarFia3FiDnn0X+GaYHe1YPbBY/lg1rWF+fxv1rjhQ516a8RC99JcmB5LWoXbNlPk45y1BqP2H4i85SxOnwwjsYLHpDum1Ubs7S5qmPbHk9yiFweC6Pq9P3nQkn/vpd9kYbSXa3mYKbqfFpd51uq2c0rXlWV4ANXplrqkBBhtnjTmn4MIBZ7TuALcjv+K7poaq6KdXDyxt3QBtds79aj2MbkAr4Z8Ohi8Roq8SczKfjpSV7meD0HqUr7uUZH9B3LWvbaXk0F2yCh8Ifr/UDaHWHymZUM==4nQ9-----END PGP SIGNATURE-----
L
L
Ludovic Courtès wrote on 6 Nov 18:00 +0100
(name . Andrew Tropin)(address . andrew@trop.in)
87a6ihmd7i.fsf@gnu.org
Hi,
Andrew Tropin <andrew@trop.in> skribis:
Toggle quote (9 lines)>>> 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 theno-abbreviation policy. :-)
If Xinglu or someone else wants to make this change, I’ll happilyreview/apply!
Thanks,Ludo’.
?
Your comment

Commenting via the web interface is currently disabled.

To comment on this conversation send email to 50873@debbugs.gnu.org