[PATCH 0/2] Add 'guix home' command.

  • Done
  • quality assurance status badge
Details
3 participants
  • Andrew Tropin
  • Oleg Pykhalov
  • zimoun
Owner
unassigned
Submitted by
Andrew Tropin
Severity
normal
A
A
Andrew Tropin wrote on 31 Aug 2021 11:28
(address . guix-patches@gnu.org)
874kb6j718.fsf@trop.in
Command and subbcommands allowing to manage home environment with guix.

Andrew Tropin (2):
scripts: Add 'guix home'.
scripts: home: Add import subcommand.

Makefile.am | 3 +
guix/scripts/home.scm | 512 +++++++++++++++++++++++++++++++++++
guix/scripts/home/import.scm | 241 +++++++++++++++++
3 files changed, 756 insertions(+)
create mode 100644 guix/scripts/home.scm
create mode 100644 guix/scripts/home/import.scm

--
2.33.0
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCgAdFiEEKEGaxlA4dEDH6S/6IgjSCVjB3rAFAmEt9qMACgkQIgjSCVjB
3rBELA/+L9JbUUEgOirgg7PaeExiW9NIqkYCU0ER7cW5r6qWnDLaLh18nwrQlBUB
dUk4S71OBM6SODQDrdqbJqHEuTbpdjYtFRjFE+dZ4dqlddG6XFN6KkH3aMMXUIVw
oAgDlgPusxnkPOBWO4AYxEsFKcYxS6oJFwdf3j7TFoSTukzNwW4SEc696OWowJV4
OwPSREmE/SWRyJNrgXZvPVqDwp/Tsluo4NDU8CgUWnoYHBbPriyC3QycTrihf67h
CqauSNf6rtqK7wHE+b+LVONSJQePdG996rnoZO8V6Ih/ZyNM0drMwYVHBN5yE6Y5
ie80caIrtusycX0PBQC7Q2/f7Pt9l0Tg5lB6dkrdR8TOVi+AfxRDk8dn+Q482uuX
toJvdit1fTFNvhOudlFyHMlCWAxozy6IBXNjLdp4YTXs2EsbO38xq/u+8cPSc8St
3rEWtB99ZgJNkkiXlmgzoeaItXqLatq0+JAQJN60EUdVqv+s3x4MAx8OFHgDv5Rs
TzY37HTY2CAzYfH5f1VYmVQ+PQ0Qp/mA9teNTTetowNNthpabYWkkUmf35MOl1z9
MhoSYudOp0tfnj+PAokccFkYYkauNl9WVV1UVz9icvMNsvJqE52MBTv3kt0es+qV
PFfVbyBpfm71hmRAyko2dLPUkjs9wEJv4oVtER3ckYomvenACGk=
=drYg
-----END PGP SIGNATURE-----

A
A
Andrew Tropin wrote on 31 Aug 2021 11:40
[PATCH 1/2] scripts: Add 'guix home'.
(address . 50296@debbugs.gnu.org)
87y28ihs07.fsf@trop.in
* guix/scripts/home.scm: New file.
* Makefile.am (MODULES): Add it.
---
Makefile.am | 2 +
guix/scripts/home.scm | 512 ++++++++++++++++++++++++++++++++++++++++++
2 files changed, 514 insertions(+)
create mode 100644 guix/scripts/home.scm

Toggle diff (538 lines)
diff --git a/Makefile.am b/Makefile.am
index 327d3f9961..d44360c034 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -15,6 +15,7 @@
# Copyright © 2018 Alex Vong <alexvong1995@gmail.com>
# Copyright © 2019 Efraim Flashner <efraim@flashner.co.il>
# Copyright © 2021 Chris Marusich <cmmarusich@gmail.com>
+# Copyright © 2021 Andrew Tropin <andrew@trop.in>
#
# This file is part of GNU Guix.
#
@@ -294,6 +295,7 @@ MODULES = \
guix/scripts/system.scm \
guix/scripts/system/search.scm \
guix/scripts/system/reconfigure.scm \
+ guix/scripts/home.scm \
guix/scripts/lint.scm \
guix/scripts/challenge.scm \
guix/scripts/import/crate.scm \
diff --git a/guix/scripts/home.scm b/guix/scripts/home.scm
new file mode 100644
index 0000000000..9eb5c0c917
--- /dev/null
+++ b/guix/scripts/home.scm
@@ -0,0 +1,512 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2021 Andrew Tropin <andrew@trop.in>
+;;; 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 (guix scripts home)
+ #:use-module (gnu packages admin)
+ #:use-module ((gnu services) #:hide (delete))
+ #:use-module (gnu packages)
+ #:use-module (gnu home)
+ #:use-module (gnu home-services)
+ #:use-module (guix channels)
+ #:use-module (guix derivations)
+ #:use-module (guix ui)
+ #:use-module (guix grafts)
+ #:use-module (guix packages)
+ #:use-module (guix profiles)
+ #:use-module (guix store)
+ #:use-module (guix utils)
+ #:use-module (guix scripts)
+ #:use-module (guix scripts package)
+ #:use-module (guix scripts build)
+ #:use-module (guix scripts system search)
+ #:autoload (guix scripts pull) (channel-commit-hyperlink)
+ ;; #:use-module (guix scripts home import)
+ #:use-module ((guix status) #:select (with-status-verbosity))
+ #:use-module (guix gexp)
+ #:use-module (guix monads)
+ #:use-module (srfi srfi-1)
+ #:use-module (srfi srfi-26)
+ #:use-module (srfi srfi-35)
+ #:use-module (srfi srfi-37)
+ #:use-module (ice-9 match)
+ #:export (guix-home))
+
+
+;;;
+;;; Options.
+;;;
+
+(define %user-module
+ (make-user-module '((gnu home))))
+
+(define %guix-home
+ (string-append %profile-directory "/guix-home"))
+
+(define (show-help)
+ (display (G_ "Usage: guix home [OPTION ...] ACTION [ARG ...] [FILE]
+Build the home environment declared in FILE according to ACTION.
+Some ACTIONS support additional ARGS.\n"))
+ (newline)
+ (display (G_ "The valid values for ACTION are:\n"))
+ (newline)
+ (display (G_ "\
+ search search for existing service types\n"))
+ (display (G_ "\
+ reconfigure switch to a new home environment configuration\n"))
+ (display (G_ "\
+ roll-back switch to the previous home environment configuration\n"))
+ (display (G_ "\
+ describe describe the current home environment\n"))
+ (display (G_ "\
+ list-generations list the home environment generations\n"))
+ (display (G_ "\
+ switch-generation switch to an existing home environment configuration\n"))
+ (display (G_ "\
+ delete-generations delete old home environment generations\n"))
+ (display (G_ "\
+ build build the home environment without installing anything\n"))
+ (display (G_ "\
+ import generates a home environment definition from dotfiles\n"))
+
+ (show-build-options-help)
+ (display (G_ "
+ -v, --verbosity=LEVEL use the given verbosity LEVEL"))
+ (newline)
+ (display (G_ "
+ -h, --help display this help and exit"))
+ (display (G_ "
+ -V, --version display version information and exit"))
+ (newline)
+ (show-bug-report-information))
+
+(define (verbosity-level opts)
+ "Return the verbosity level based on OPTS, the alist of parsed options."
+ (or (assoc-ref opts 'verbosity)
+ (if (eq? (assoc-ref opts 'action) 'build)
+ 2 1)))
+
+(define %options
+ ;; Specification of the command-line options.
+ (cons* (option '(#\h "help") #f #f
+ (lambda args
+ (show-help)
+ (exit 0)))
+ (option '(#\V "version") #f #f
+ (lambda args
+ (show-version-and-exit "guix show")))
+ (option '(#\v "verbosity") #t #f
+ (lambda (opt name arg result)
+ (let ((level (string->number* arg)))
+ (alist-cons 'verbosity level
+ (alist-delete 'verbosity result)))))
+ %standard-build-options))
+
+(define %default-options
+ `((build-mode . ,(build-mode normal))
+ (graft? . #t)
+ (substitutes? . #t)
+ (offload? . #t)
+ (print-build-trace? . #t)
+ (print-extended-build-trace? . #t)
+ (multiplexed-build-output? . #t)
+ (verbosity . 3)
+ (debug . 0)))
+
+
+;;;
+;;; Actions.
+;;;
+
+(define* (perform-action action he
+ #:key
+ dry-run?
+ derivations-only?
+ use-substitutes?)
+ "Perform ACTION for home environment. "
+
+ (define println
+ (cut format #t "~a~%" <>))
+
+ (mlet* %store-monad
+ ((he-drv (home-environment-derivation he))
+ (drvs (mapm/accumulate-builds lower-object (list he-drv)))
+ (% (if derivations-only?
+ (return
+ (for-each (compose println derivation-file-name) drvs))
+ (built-derivations drvs)))
+
+ (he-out-path -> (derivation->output-path he-drv)))
+ (if (or dry-run? derivations-only?)
+ (return #f)
+ (begin
+ (for-each (compose println derivation->output-path) drvs)
+
+ (case action
+ ((reconfigure)
+ (let* ((number (generation-number %guix-home))
+ (generation (generation-file-name
+ %guix-home (+ 1 number))))
+
+ (switch-symlinks generation he-out-path)
+ (switch-symlinks %guix-home generation)
+ (setenv "GUIX_NEW_HOME" he-out-path)
+ (primitive-load (string-append he-out-path "/activate"))
+ (setenv "GUIX_NEW_HOME" #f)
+ (return he-out-path)))
+ (else
+ (newline)
+ (return he-out-path)))))))
+
+(define (process-action action args opts)
+ "Process ACTION, a sub-command, with the arguments are listed in ARGS.
+ACTION must be one of the sub-commands that takes a home environment
+declaration as an argument (a file name.) OPTS is the raw alist of options
+resulting from command-line parsing."
+ (define (ensure-home-environment file-or-exp obj)
+ (unless (home-environment? obj)
+ (leave (G_ "'~a' does not return a home environment ~%")
+ file-or-exp))
+ obj)
+
+ (let* ((file (match args
+ (() #f)
+ ((x . _) x)))
+ (expr (assoc-ref opts 'expression))
+ (system (assoc-ref opts 'system))
+
+ (transform (lambda (obj)
+ (home-environment-with-provenance obj file)))
+
+ (home-environment
+ (transform
+ (ensure-home-environment
+ (or file expr)
+ (cond
+ ((and expr file)
+ (leave
+ (G_ "both file and expression cannot be specified~%")))
+ (expr
+ (read/eval expr))
+ (file
+ (load* file %user-module
+ #:on-error (assoc-ref opts 'on-error)))
+ (else
+ (leave (G_ "no configuration specified~%")))))))
+
+ (dry? (assoc-ref opts 'dry-run?)))
+
+ (with-store store
+ (set-build-options-from-command-line store opts)
+ (with-build-handler (build-notifier #:use-substitutes?
+ (assoc-ref opts 'substitutes?)
+ #:verbosity
+ (verbosity-level opts)
+ #:dry-run?
+ (assoc-ref opts 'dry-run?))
+
+ (run-with-store store
+ (mbegin %store-monad
+ (set-guile-for-build (default-guile))
+
+ (case action
+ (else
+ (perform-action action home-environment
+ #:dry-run? dry?
+ #:derivations-only? (assoc-ref opts 'derivations-only?)
+ #:use-substitutes? (assoc-ref opts 'substitutes?))
+ ))))))
+ (warn-about-disk-space)))
+
+
+(define (process-command command args opts)
+ "Process COMMAND, one of the 'guix home' sub-commands. ARGS is its
+argument list and OPTS is the option alist."
+ (define-syntax-rule (with-store* store exp ...)
+ (with-store store
+ (set-build-options-from-command-line store opts)
+ exp ...))
+ (case command
+ ;; The following commands do not need to use the store, and they do not need
+ ;; an home environment file.
+ ((search)
+ (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))))
+ ((describe)
+ (match (generation-number %guix-home)
+ (0
+ (error (G_ "no home environment generation, nothing to describe~%")))
+ (generation
+ (display-home-environment-generation generation))))
+ ((list-generations)
+ (let ((pattern (match args
+ (() #f)
+ ((pattern) pattern)
+ (x (leave (G_ "wrong number of arguments~%"))))))
+ (list-generations pattern)))
+ ((switch-generation)
+ (let ((pattern (match args
+ ((pattern) pattern)
+ (x (leave (G_ "wrong number of arguments~%"))))))
+ (with-store* store
+ (switch-to-home-environment-generation store pattern))))
+ ((roll-back)
+ (let ((pattern (match args
+ (() "")
+ (x (leave (G_ "wrong number of arguments~%"))))))
+ (with-store* store
+ (roll-back-home-environment store))))
+ ((delete-generations)
+ (let ((pattern (match args
+ (() #f)
+ ((pattern) pattern)
+ (x (leave (G_ "wrong number of arguments~%"))))))
+ (with-store*
+ store
+ (delete-matching-generations store %guix-home pattern))))
+ (else (process-action command args opts))))
+
+(define-command (guix-home . args)
+ (synopsis "build and deploy home environments")
+
+ (define (parse-sub-command arg result)
+ ;; Parse sub-command ARG and augment RESULT accordingly.
+ (if (assoc-ref result 'action)
+ (alist-cons 'argument arg result)
+ (let ((action (string->symbol arg)))
+ (case action
+ ((build
+ reconfigure
+ extension-graph shepherd-graph
+ list-generations describe
+ delete-generations roll-back
+ switch-generation search
+ import)
+ (alist-cons 'action action result))
+ (else (leave (G_ "~a: unknown action~%") action))))))
+
+ (define (match-pair car)
+ ;; Return a procedure that matches a pair with CAR.
+ (match-lambda
+ ((head . tail)
+ (and (eq? car head) tail))
+ (_ #f)))
+
+ (define (option-arguments opts)
+ ;; Extract the plain arguments from OPTS.
+ (let* ((args (reverse (filter-map (match-pair 'argument) opts)))
+ (count (length args))
+ (action (assoc-ref opts 'action))
+ (expr (assoc-ref opts 'expression)))
+ (define (fail)
+ (leave (G_ "wrong number of arguments for action '~a'~%")
+ action))
+
+ (unless action
+ (format (current-error-port)
+ (G_ "guix home: missing command name~%"))
+ (format (current-error-port)
+ (G_ "Try 'guix home --help' for more information.~%"))
+ (exit 1))
+
+ (case action
+ ((build reconfigure)
+ (unless (or (= count 1)
+ (and expr (= count 0)))
+ (fail)))
+ ((init)
+ (unless (= count 2)
+ (fail))))
+ args))
+
+ (with-error-handling
+ (let* ((opts (parse-command-line args %options
+ (list %default-options)
+ #:argument-handler
+ parse-sub-command))
+ (args (option-arguments opts))
+ (command (assoc-ref opts 'action)))
+ (parameterize ((%graft? (assoc-ref opts 'graft?)))
+ (with-status-verbosity (verbosity-level opts)
+ (process-command command args opts))))))
+
+
+;;;
+;;; Searching.
+;;;
+
+(define service-type-name*
+ (compose symbol->string service-type-name))
+
+(define (service-type-description-string type)
+ "Return the rendered and localised description of TYPE, a service type."
+ (and=> (service-type-description type)
+ (compose texi->plain-text P_)))
+
+(define %service-type-metrics
+ ;; Metrics used to estimate the relevance of a search result.
+ `((,service-type-name* . 3)
+ (,service-type-description-string . 2)
+ (,(lambda (type)
+ (match (and=> (service-type-location type) location-file)
+ ((? string? file)
+ (basename file ".scm"))
+ (#f
+ "")))
+ . 1)))
+
+(define (find-service-types regexps)
+ "Return a list of service type/score pairs: service types whose name or
+description matches REGEXPS sorted by relevance, and their score."
+ (let ((matches (fold-home-service-types
+ (lambda (type result)
+ (match (relevance type regexps
+ %service-type-metrics)
+ ((? zero?)
+ result)
+ (score
+ (cons (cons type score) result))))
+ '())))
+ (sort matches
+ (lambda (m1 m2)
+ (match m1
+ ((type1 . score1)
+ (match m2
+ ((type2 . score2)
+ (if (= score1 score2)
+ (string>? (service-type-name* type1)
+ (service-type-name* type2))
+ (> score1 score2))))))))))
+
+(define (search . args)
+ (with-error-handling
+ (let* ((regexps (map (cut make-regexp* <> regexp/icase) args))
+ (matches (find-service-types regexps)))
+ (leave-on-EPIPE
+ (display-search-results matches (current-output-port)
+ #:print service-type->recutils
+ #:command "guix home search")))))
+
+
+;;;
+;;; Generations.
+;;;
+
+(define* (display-home-environment-generation
+ number
+ #:optional (profile %guix-home))
+ "Display a summary of home-environment generation NUMBER in a
+human-readable format."
+ (define (display-channel channel)
+ (format #t " ~a:~%" (channel-name channel))
+ (format #t (G_ " repository URL: ~a~%") (channel-url channel))
+ (when (channel-branch channel)
+ (format #t (G_ " branch: ~a~%") (channel-branch channel)))
+ (format #t (G_ " commit: ~a~%")
+ (if (supports-hyperlinks?)
+ (channel-commit-hyperlink channel)
+ (channel-commit channel))))
+
+ (unless (zero? number)
+ (let* ((generation (generation-file-name profile number)))
+ (define-values (channels config-file)
+ ;; The function will work for home environments too, we just
+ ;; need to keep provenance file.
+ (system-provenance generation))
+
+ (display-generation profile number)
+ (format #t (G_ " file name: ~a~%") generation)
+ (format #t (G_ " canonical file name: ~a~%") (readlink* generation))
+ ;; TRANSLATORS: Please preserve the two-space indentation.
+
+ (unless (null? channels)
+ ;; TRANSLATORS: Here "channel" is the same terminology as used in
+ ;; "guix describe" and "guix pull --channels".
+ (format #t (G_ " channels:~%"))
+ (for-each display-channel channels))
+ (when config-file
+ (format #t (G_ " configuration file: ~a~%")
+ (if (supports-hyperlinks?)
+ (file-hyperlink config-file)
+ config-file))))))
+
+(define* (list-generations pattern #:optional (profile %guix-home))
+ "Display in a human-readable format all the home environment
+generations matching PATTERN, a string. When PATTERN is #f, display
+all the home environment generations."
+ (cond ((not (file-exists? profile)) ; XXX: race condition
+ (raise (condition (&profile-not-found-error
+ (profile profile)))))
+ ((not pattern)
+ (for-each display-home-environment-generation (profile-generations profile)))
+ ((matching-generations pattern profile)
+ =>
+ (lambda (numbers)
+ (if (null-list? numbers)
+ (exit 1)
+ (leave-on-EPIPE
+ (for-each display-home-environment-generation numbers)))))))
+
+
+;;;
+;;; Switch generations.
+;;;
+
+;; TODO: Make it public in (guix scripts system)
+(define-syntax-rule (unless-file-not-found exp)
+ (catch 'system-error
+ (lambda ()
+ exp)
+ (lambda args
+ (if (= ENOENT (system-error-errno args))
+ #f
+ (apply throw args)))))
+
+(define (switch-to-home-environment-generation store spec)
+ "Switch the home-environment profile to the generation specified by
+SPEC. STORE is an open connection to the store."
+ (let* ((number (relative-generation-spec->number %guix-home spec))
+ (generation (generation-file-name %guix-home number))
+ (activate (string-append generation "/activate")))
+ (if number
+ (begin
+ (setenv "GUIX_NEW_HOME" (readlink generation))
+ (switch-to-generation* %guix-home number)
+ (unless-file-not-found (primitive-load activate))
+ (setenv "GUIX_NEW_HOME" #f))
+ (leave (G_ "cannot switch to home environment generation '~a'~%") spec))))
+
+
+;;;
+;;; Roll-back.
+;;;
+
+(define (roll-back-home-environment store)
+ "Roll back the home-environment profile to its previous generation.
+STORE is an open connection to the store."
+ (switch-to-home-environment-gen
This message was truncated. Download the full message here.
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCgAdFiEEKEGaxlA4dEDH6S/6IgjSCVjB3rAFAmEt+PgACgkQIgjSCVjB
3rAkUw/+LZ1Cq3n46PxPfj6V9zXKZxyzU4k4MHTq5o75G2PPgLDjwi9tst/Nz7T5
Reo3ETe/FfsVWWTl8Fi4lzUk+uIorREnwcKwLqwJP2H0vxXC6LcfLswb6TpVKGq5
fBAyfPHbeBFZiKlfpKdPaHKsXcqM50zsoi7UcGpYcJDnUaVBfxAqfjT71Ru/N8K4
hcmepyths+s23+iqXMM97u+aKWIxTtPnksmZVHeDLVSDjaBmjFa6DP5CsfP+kinJ
rPH1sPaVUuRbLAYMhcQVOTjGrKeTAEOG2ZG9jgZJrUbsYZdndrH3WqjleTvAM6Ln
3O/IlFeIKZ8UHxeDL78ZVldqMNJt4yY69jR/rTYu13DFdvRCnPIgu765ddDZ5+TB
+5AlHSWUaRMWHi6KKjOoAKWGDthu3KHiioIX9Y/FpvGSBzqFkdrKCEMUVG9m6yyK
4PkKGd255/w8WwFxIUyUPGrOr7CekCDO+uBdyFtMvgThBLk/plgRi6JhfkJLha3Z
Pd8h5Hl8u170mRJHTedOr8tfVIwaXJpEVD6NMxobiD7HyXEsV/elI3UIrHnholK5
589dYqIFDr3EU5/1hxViWlXyQzUHO+EI84nntQLdVjuJAaMZCS3exNLqfOrWr+2G
Wr7MguyydHYZiY5eU2sd8JV7KeIiTiqLCgjnJZ8ATSKWyip3ce0=
=WPvF
-----END PGP SIGNATURE-----

A
A
Andrew Tropin wrote on 31 Aug 2021 11:40
[PATCH 2/2] scripts: home: Add import subcommand.
(address . 50296@debbugs.gnu.org)
87v93mhryt.fsf@trop.in
* guix/scripts/home/import.scm: New file.
* Makefile.am (MODULES): Add it.
---
Makefile.am | 1 +
guix/scripts/home.scm | 2 +-
guix/scripts/home/import.scm | 241 +++++++++++++++++++++++++++++++++++
3 files changed, 243 insertions(+), 1 deletion(-)
create mode 100644 guix/scripts/home/import.scm

Toggle diff (274 lines)
diff --git a/Makefile.am b/Makefile.am
index d44360c034..c27dcf9a38 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -296,6 +296,7 @@ MODULES = \
guix/scripts/system/search.scm \
guix/scripts/system/reconfigure.scm \
guix/scripts/home.scm \
+ guix/scripts/home/import.scm \
guix/scripts/lint.scm \
guix/scripts/challenge.scm \
guix/scripts/import/crate.scm \
diff --git a/guix/scripts/home.scm b/guix/scripts/home.scm
index 9eb5c0c917..75df6d707d 100644
--- a/guix/scripts/home.scm
+++ b/guix/scripts/home.scm
@@ -36,7 +36,7 @@
#:use-module (guix scripts build)
#:use-module (guix scripts system search)
#:autoload (guix scripts pull) (channel-commit-hyperlink)
- ;; #:use-module (guix scripts home import)
+ #:use-module (guix scripts home import)
#:use-module ((guix status) #:select (with-status-verbosity))
#:use-module (guix gexp)
#:use-module (guix monads)
diff --git a/guix/scripts/home/import.scm b/guix/scripts/home/import.scm
new file mode 100644
index 0000000000..39f45dbeac
--- /dev/null
+++ b/guix/scripts/home/import.scm
@@ -0,0 +1,241 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2021 Xinglu Chen <public@yoctocell.xyz>
+;;; Copyright © 2021 Andrew Tropin <andrew@trop.in>
+;;;
+;;; 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 (guix scripts home import)
+ #:use-module (guix profiles)
+ #:use-module (guix ui)
+ #:use-module (ice-9 match)
+ #:use-module (ice-9 pretty-print)
+ #:use-module (srfi srfi-1)
+ #:export (import-manifest))
+
+;;; Commentary:
+;;;
+;;; This module provides utilities for generating home service
+;;; configurations from existing "dotfiles".
+;;;
+;;; Code:
+
+
+(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 (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)))
+
+;; Based on `manifest->code' from (guix profiles)
+;; MAYBE: Upstream it?
+(define* (manifest->code manifest
+ #:key
+ (entry-package-version (const ""))
+ (home-environment? #f))
+ "Return an sexp representing code to build an approximate version of
+MANIFEST; the code is wrapped in a top-level 'begin' form. If
+HOME-ENVIRONMENT? is #t, return an <home-environment> definition.
+Call ENTRY-PACKAGE-VERSION to determine the version number to use in
+the spec for a given entry; it can be set to 'manifest-entry-version'
+for fully-specified version numbers, or to some other procedure to
+disambiguate versions for packages for which several versions are
+available."
+ (define (entry-transformations entry)
+ ;; Return the transformations that apply to ENTRY.
+ (assoc-ref (manifest-entry-properties entry) 'transformations))
+
+ (define transformation-procedures
+ ;; List of transformation options/procedure name pairs.
+ (let loop ((entries (manifest-entries manifest))
+ (counter 1)
+ (result '()))
+ (match entries
+ (() result)
+ ((entry . tail)
+ (match (entry-transformations entry)
+ (#f
+ (loop tail counter result))
+ (options
+ (if (assoc-ref result options)
+ (loop tail counter result)
+ (loop tail (+ 1 counter)
+ (alist-cons options
+ (string->symbol
+ (format #f "transform~a" counter))
+ result)))))))))
+
+ (define (qualified-name entry)
+ ;; Return the name of ENTRY possibly with "@" followed by a version.
+ (match (entry-package-version entry)
+ ("" (manifest-entry-name entry))
+ (version (string-append (manifest-entry-name entry)
+ "@" version))))
+
+ (if (null? transformation-procedures)
+ (let ((specs (map (lambda (entry)
+ (match (manifest-entry-output entry)
+ ("out" (qualified-name entry))
+ (output (string-append (qualified-name entry)
+ ":" output))))
+ (manifest-entries manifest))))
+ (if home-environment?
+ (let ((modules+configurations (modules+configurations)))
+ `(begin
+ (use-modules (gnu home)
+ (gnu packages)
+ ,@(map first modules+configurations))
+ ,(home-environment-template
+ #:specs specs
+ #:services (map second modules+configurations))))
+ `(begin
+ (use-modules (gnu packages))
+
+ (specifications->manifest
+ (list ,@specs)))))
+ (let* ((transform (lambda (options exp)
+ (if (not options)
+ exp
+ (let ((proc (assoc-ref transformation-procedures
+ options)))
+ `(,proc ,exp)))))
+ (packages (map (lambda (entry)
+ (define options
+ (entry-transformations entry))
+
+ (define name
+ (qualified-name entry))
+
+ (match (manifest-entry-output entry)
+ ("out"
+ (transform options
+ `(specification->package ,name)))
+ (output
+ `(list ,(transform
+ options
+ `(specification->package ,name))
+ ,output))))
+ (manifest-entries manifest)))
+ (transformations (map (match-lambda
+ ((options . name)
+ `(define ,name
+ (options->transformation ',options))))
+ transformation-procedures)))
+ (if home-environment?
+ (let ((modules+configurations (modules+configurations)))
+ `(begin
+ (use-modules (guix transformations)
+ (gnu home)
+ (gnu packages)
+ ,@(map first modules+configurations))
+
+ ,@transformations
+
+ ,(home-environment-template
+ #:packages packages
+ #:services (map second modules+configurations))))
+ `(begin
+ (use-modules (guix transformations)
+ (gnu packages))
+
+ ,@transformations
+
+ (packages->manifest
+ (list ,@packages)))))))
+
+(define* (home-environment-template #:key (packages #f) (specs #f) services)
+ "Return an S-exp containing a <home-environment> declaration
+containing PACKAGES, or SPECS (package specifications), and SERVICES."
+ `(home-environment
+ (packages
+ ,@(if packages
+ `((list ,@packages))
+ `((map specification->package
+ (list ,@specs)))))
+ (services (list ,@services))))
+
+(define* (import-manifest
+ manifest
+ #:optional (port (current-output-port)))
+ "Write to PORT a <home-environment> corresponding to MANIFEST."
+ (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)))))))
+
+ (match (manifest->code manifest
+ #:entry-package-version version-spec
+ #:home-environment? #t)
+ (('begin exp ...)
+ (format port (G_ "\
+;; 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.\n"))
+ (for-each (lambda (exp)
+ (newline port)
+ (pretty-print exp port))
+ exp))))
--
2.33.0
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCgAdFiEEKEGaxlA4dEDH6S/6IgjSCVjB3rAFAmEt+SoACgkQIgjSCVjB
3rD7hw/7By/FO3SarrQZ0kmMNWV83UIi2ztywbNAayzHmSsT1cLIi/xKaKOT+05W
3SVDdg8VZRR6C3Wc7RIujPnCqO5iWGtVHOTbmgNEfS8JPSlxqA3yHkkmxuvltbI/
DNwUPgiYx2rqb2EaTNLAgu+Dsyb9K4RN6j+GAXuDRAmcy3ttk7h7kx2wxcwT16Jo
CEi2SNlIxCfUfEfvNMa7mzQ46LlC+cdsq78SnFcfioL3keWhHFsoSjPHp4K+ZEN0
9fLzi4NLq0nTkyuXCG/wW0TUNBBr1zw5ZOpGfKejGzoH2JGn7ufuc4IDeULkgDiS
8pJhBKtKSBKyVLo2Nk6xhcnOiu/88O8XebHcmqS10Jijpt6zaJof4ONhY9nYBhV7
w5iqUxEaANbQ1GG3mtcB5AZJloPpIIG5UEgAdjE4bBVoEot2HIrZ9P0r4DQk9hqm
7L9iZDU6WW6C0gPhvnWx7YXqZG8gBofbEo76GMLMgGARJT/6SPaEz4q6dFobgRRd
4F2utWajCAFAHjdv9UHTFS6F2PwjQ05uLH8E7uOywvOCu0kmyBCyt6n1bNmes7h4
NXP6y5NR931XGpJselSOeQABHYUaR1H2ODTcxQbJvERFLltJ15CgxhCt6Zjh3z72
n34GI19YJsgAyFNnm2aRsYGe4Uw+LB4eTAAxvyDSSX1INrwqEHw=
=JFMU
-----END PGP SIGNATURE-----

O
O
Oleg Pykhalov wrote on 31 Aug 2021 13:13
Re: [bug#50296] [PATCH 0/2] Add 'guix home' command.
(name . Andrew Tropin)(address . andrew@trop.in)(address . 50296-done@debbugs.gnu.org)
87tuj598an.fsf@gmail.com
Hi Andrew,

Andrew Tropin <andrew@trop.in> writes:

Toggle quote (13 lines)
> Command and subbcommands allowing to manage home environment with guix.
>
> Andrew Tropin (2):
> scripts: Add 'guix home'.
> scripts: home: Add import subcommand.
>
> Makefile.am | 3 +
> guix/scripts/home.scm | 512 +++++++++++++++++++++++++++++++++++
> guix/scripts/home/import.scm | 241 +++++++++++++++++
> 3 files changed, 756 insertions(+)
> create mode 100644 guix/scripts/home.scm
> create mode 100644 guix/scripts/home/import.scm

I applied your patches and also fixed a typo in
gnu/home-services/xdg.scm file, which I noticed during Geiser entering
(guix scripts home) module about missing ‘home-services-utils’, which
should be ‘home-services utils’.

Pushed to wip-guix-home.

Also, I tried to use guix home for the first time as documented at site
[1], and got an error:
Toggle snippet (4 lines)
(string-append #f "/" "profile/share/fonts")
In procedure string-append: Wrong type (expecting string): #f



The following text in the message is only about the error.

oleg@guixsd ~/src/guix-wip-guix-home$ mkdir /tmp/guix

oleg@guixsd ~/src/guix-wip-guix-home$ guix pull --url=file:///home/oleg/src/guix-wip-guix-home --branch=wip-guix-home -p /tmp/guix/guix

~/.local/share/chezmoi/dotfiles/guixsd/home.scm:
Toggle snippet (51 lines)
(use-modules (gnu home)
(gnu home-services)
;; (gnu home-services ssh)
(gnu home-services shells)
;; (gnu home-services files)
(gnu services)
(gnu packages admin)
(guix gexp)

(ice-9 rdelim))

(define %home
(and=> (getenv "HOME")
(lambda (home)
home)))

(define .bash_profile
(string-append %home "/.local/share/chezmoi/dot_bash_profile"))

(home-environment

;; (packages (list htop))

(services
(list

(service home-bash-service-type
(home-bash-configuration
(guix-defaults? #t)
(bash-profile
(list
(with-input-from-file .bash_profile read-string)))))

;; XXX: missing home-files-service-type
;; (simple-service 'test-config
;; home-files-service-type
;; (list `("config/test.conf"
;; ,(plain-file "tmp-file.txt"
;; "the content of ~/.config/test.conf"))))
;; XXX: missing home-ssh-configuration
;; (service home-ssh-service-type
;; (home-ssh-configuration
;; (extra-config
;; (list
;; (ssh-host "savannah"
;; '((compression . #f)))))))

)))

My first guix home reconfigure launch:
Toggle snippet (55 lines)
oleg@guixsd ~/src/guix-wip-guix-home$ /tmp/guix/guix/bin/guix home reconfigure ~/.local/share/chezmoi/dotfiles/guixsd/home.scm
/gnu/store/xl4igqm0jjy7gfbganz9061ivdgzfpdk-home
New symlinks to home-environment will be created soon.
All conflicting files will go to /home/oleg/1630407324-guix-home-legacy-configs-backup.

Skipping /home/oleg/.config (directory already exists)... done
Creating /home/oleg/.config/fontconfig... done
Symlinking /home/oleg/.config/fontconfig/fonts.conf -> /gnu/store/phj2z2iiqdhryfy7mqral0b9qz3hlva6-fonts.conf... done
Backing up /home/oleg/.bashrc... done
Symlinking /home/oleg/.bashrc -> /gnu/store/513j2xkszmcmv7fiawh59mr0i1fmin55-bashrc... done
Symlinking /home/oleg/.profile -> /gnu/store/fxbppk3pqzdi3zzy0xl5vg1ir6c5jzq5-shell-profile... done
Backing up /home/oleg/.bash_profile... done
Symlinking /home/oleg/.bash_profile -> /gnu/store/2c3yva8vj5ikb0gspmjvzw0r9g9i1cxc-bash_profile... done
done
Finished updating symlinks.

Backtrace:
In guix/ui.scm:
2185:7 19 (run-guix . _)
2148:10 18 (run-guix-command _ . _)
In ice-9/boot-9.scm:
1752:10 17 (with-exception-handler _ _ #:unwind? _ # _)
In guix/status.scm:
820:3 16 (_)
800:4 15 (call-with-status-report _ _)
In guix/scripts/home.scm:
214:4 14 (_)
In ice-9/boot-9.scm:
1752:10 13 (with-exception-handler _ _ #:unwind? _ # _)
In guix/store.scm:
658:37 12 (thunk)
1320:8 11 (call-with-build-handler _ _)
1320:8 10 (call-with-build-handler #<procedure 7f5d757319c0 at g…> …)
2108:24 9 (run-with-store #<store-connection 256.99 7f5d77fb3550> …)
In guix/scripts/home.scm:
169:15 8 (_ _)
In unknown file:
7 (primitive-load "/gnu/store/xl4igqm0jjy7gfbganz9061ivdg…")
In ice-9/eval.scm:
619:8 6 (_ #(#(#(#(#(#(#(#(#(#(#<…> …) …) …) …) …) …) …) …) …) …))
626:19 5 (_ #(#(#(#(#(#(#(#(#(#(#<…> …) …) …) …) …) …) …) …) …) …))
In srfi/srfi-1.scm:
586:17 4 (map1 (("profile/share/fonts" (system* "/gnu/stor…" …))))
In ice-9/eval.scm:
293:34 3 (_ #(#(#<directory (guile-user) 7f5d87ca3c80> #<va…>) #))
In unknown file:
2 (string-append #f "/" "profile/share/fonts")
In ice-9/boot-9.scm:
1685:16 1 (raise-exception _ #:continuable? _)
1685:16 0 (raise-exception _ #:continuable? _)

ice-9/boot-9.scm:1685:16: In procedure raise-exception:
In procedure string-append: Wrong type (expecting string): #f

I skipped the error and tried to configure Bash more:
Toggle snippet (12 lines)
(define .bashrc
(string-append %home "/.local/share/chezmoi/dot_bashrc"))

;; ...

(home-bash-configuration
;; ...
(bashrc
(list
(with-input-from-file .bashrc read-string))))

Another launch, no errors this time:
Toggle snippet (46 lines)
oleg@guixsd ~/src/guix-wip-guix-home$ /tmp/guix/guix/bin/guix home reconfigure ~/.local/share/chezmoi/dotfiles/guixsd/home.scm
substitute: updating substitutes from 'https://ci.guix.gnu.org'... 100.0%
substitute: updating substitutes from 'https://bordeaux.guix.gnu.org'... 100.0%
The following derivations will be built:
/gnu/store/fn1hzpyic1k32pamyf45vwa0x3lw046g-home.drv
/gnu/store/akdwz30lx0widqvyqmnkya45cb78f74d-files.drv
/gnu/store/xcvi7n1l0fvsm099x2vyg6xci0qkayzp-bashrc.drv
/gnu/store/pm1gw2xakkqj0zxsbbq0jnwgv3v95ajj-provenance.drv
building /gnu/store/pm1gw2xakkqj0zxsbbq0jnwgv3v95ajj-provenance.drv...
successfully built /gnu/store/pm1gw2xakkqj0zxsbbq0jnwgv3v95ajj-provenance.drv
building /gnu/store/xcvi7n1l0fvsm099x2vyg6xci0qkayzp-bashrc.drv...
successfully built /gnu/store/xcvi7n1l0fvsm099x2vyg6xci0qkayzp-bashrc.drv
building /gnu/store/akdwz30lx0widqvyqmnkya45cb78f74d-files.drv...
successfully built /gnu/store/akdwz30lx0widqvyqmnkya45cb78f74d-files.drv
building /gnu/store/fn1hzpyic1k32pamyf45vwa0x3lw046g-home.drv...
successfully built /gnu/store/fn1hzpyic1k32pamyf45vwa0x3lw046g-home.drv
/gnu/store/1y84hzz1m1c3jw03n2g8hn9wwyxngab3-home
Cleaning up symlinks from previous home-environment.

Removing /home/oleg/.config/fontconfig/fonts.conf... done
Removing /home/oleg/.config/fontconfig... done
Skipping /home/oleg/.config (not an empty directory)... done
Removing /home/oleg/.bashrc... done
Removing /home/oleg/.profile... done
Removing /home/oleg/.bash_profile... done
Cleanup finished.

New symlinks to home-environment will be created soon.
All conflicting files will go to /home/oleg/1630407412-guix-home-legacy-configs-backup.

Skipping /home/oleg/.config (directory already exists)... done
Creating /home/oleg/.config/fontconfig... done
Symlinking /home/oleg/.config/fontconfig/fonts.conf -> /gnu/store/phj2z2iiqdhryfy7mqral0b9qz3hlva6-fonts.conf... done
Symlinking /home/oleg/.bashrc -> /gnu/store/lf51wflmvx91m2jx8hx3j34qs9x1k153-bashrc... done
Symlinking /home/oleg/.profile -> /gnu/store/fxbppk3pqzdi3zzy0xl5vg1ir6c5jzq5-shell-profile... done
Symlinking /home/oleg/.bash_profile -> /gnu/store/2c3yva8vj5ikb0gspmjvzw0r9g9i1cxc-bash_profile... done
done
Finished updating symlinks.

Comparing /gnu/store/xl4igqm0jjy7gfbganz9061ivdgzfpdk-home/profile/share/fonts and
/gnu/store/1y84hzz1m1c3jw03n2g8hn9wwyxngab3-home/profile/share/fonts... done (same)
Evaling on-change gexps.

On-change gexps evaluation finished.

Oleg.
-----BEGIN PGP SIGNATURE-----

iQJIBAEBCgAyFiEEcjhxI46s62NFSFhXFn+OpQAa+pwFAmEuDsAUHGdvLndpZ3Vz
dEBnbWFpbC5jb20ACgkQFn+OpQAa+px5zhAAwPWVUW9s1WDXP1j5wDHJ355YJRoi
JhGScL7rWDibGhaPGSN5pPBPBWeIt5I59uojrMgH9SOqB6pCxcinz38Op5neM/KX
S86Axe1iCCyRjGT5RMxPrO0tMwIV0/gW5zrCIir9BFtSEU0LJZBOfr9U2sQb0Lr6
pa+OiWx2CU+X5brtXBLBQyLAmdxSf1+Ps5wa2ZekzfrltFch3x855Je1dZ/cWtke
z+0r+ypvRhbZzwBR23bAC9saIWJPqF5AI8dlujo7sOD/oLgQd5VGvqaUmeiiYKOK
dNMEUM86qPfuk7CTmBkS4RUHwvKS7tPWGCsiKJ4mgFMwmCHg35l4xT9teOxk9isn
xVKRiSdg6/mIGbk8Pn2XUy/hYzmDvlMRkdCWVp8XNU7bI1Hc8LmFesW5RBMVNQwP
UM/QTr2+fmOYjO3qCTy1E71MBO25tZk+zSni4R8kdiMl/D6qgdQNRFXE29k3GZst
yiQZ744TiE36uNvpfzJiTANSS+GNZZ8ka1s3H3gUWdM9qpFG8p50D33a3Hdg9b7w
TzsovR5JWr28kEqALiAH1wSJMFIByChv7Ce9dL9FBE58b3w3bZbGWKIzdP5YM/6r
yc33IBATW8RDC/Z/BL8eSzNuK9W9x1heQgpj2i8z2sOYAk94Eiydrc3doF5JW/mL
S64IskPyDGvzjkM=
=78cW
-----END PGP SIGNATURE-----

Closed
Z
Z
zimoun wrote on 31 Aug 2021 12:46
86tuj5opr0.fsf@gmail.com
Hi Andrew,

On Tue, 31 Aug 2021 at 12:28, Andrew Tropin <andrew@trop.in> wrote:
Toggle quote (6 lines)
> Command and subbcommands allowing to manage home environment with guix.
>
> Andrew Tropin (2):
> scripts: Add 'guix home'.
> scripts: home: Add import subcommand.

Raghav recently asked [1] an interesting question about consistency of
command line commands, i.e., compare for instance:

guix system roll-back
guix pull --roll-back
guix package --roll-back

I do not have an opinion but is it a conscientious or discussed choice
for subcommands?


All the best,
simon


Z
Z
zimoun wrote on 31 Aug 2021 12:53
Re: [bug#50296] [PATCH 1/2] scripts: Add 'guix home'.
86pmttopfk.fsf@gmail.com
Hi,

On Tue, 31 Aug 2021 at 12:40, Andrew Tropin <andrew@trop.in> wrote:

Toggle quote (19 lines)
> +(define-command (guix-home . args)
> + (synopsis "build and deploy home environments")
> +
> + (define (parse-sub-command arg result)
> + ;; Parse sub-command ARG and augment RESULT accordingly.
> + (if (assoc-ref result 'action)
> + (alist-cons 'argument arg result)
> + (let ((action (string->symbol arg)))
> + (case action
> + ((build
> + reconfigure
> + extension-graph shepherd-graph
> + list-generations describe
> + delete-generations roll-back
> + switch-generation search
> + import)
> + (alist-cons 'action action result))
> + (else (leave (G_ "~a: unknown action~%") action))))))

For parsing the actions, I would define elsewhere the list. Then if the
action is unknown, you could use ’string-closest’ and so return an hint
if there is a typo.

Other said, this

guix home recnfigure

would return

guix home: error: recnfigure: unknown action
hint: Did you mean `reconfigure'?

WDYT?

Cheers,
simon
A
A
Andrew Tropin wrote on 31 Aug 2021 13:46
Re: [bug#50296] [PATCH 0/2] Add 'guix home' command.
(name . Oleg Pykhalov)(address . go.wigust@gmail.com)(address . 50296-done@debbugs.gnu.org)
87sfypj0qk.fsf@trop.in
On 2021-08-31 14:13, Oleg Pykhalov wrote:

Toggle quote (23 lines)
> Hi Andrew,
>
> Andrew Tropin <andrew@trop.in> writes:
>
>> Command and subbcommands allowing to manage home environment with guix.
>>
>> Andrew Tropin (2):
>> scripts: Add 'guix home'.
>> scripts: home: Add import subcommand.
>>
>> Makefile.am | 3 +
>> guix/scripts/home.scm | 512 +++++++++++++++++++++++++++++++++++
>> guix/scripts/home/import.scm | 241 +++++++++++++++++
>> 3 files changed, 756 insertions(+)
>> create mode 100644 guix/scripts/home.scm
>> create mode 100644 guix/scripts/home/import.scm
>
> I applied your patches and also fixed a typo in
> gnu/home-services/xdg.scm file, which I noticed during Geiser entering
> (guix scripts home) module about missing ‘home-services-utils’, which
> should be ‘home-services utils’.
>

In rde we have home-services-utils, during recent refactoring I took
parts of it and split into home-services utils and home-services
configure modules. For some reason I missed that xdg still uses it and
I didn't get rid of this import, I'll update xdg module and send patches
for it, thank you for noticing the issue.

Toggle quote (128 lines)
>
> Pushed to wip-guix-home.
>
> Also, I tried to use guix home for the first time as documented at site
> [1], and got an error:
> --8<---------------cut here---------------start------------->8---
> (string-append #f "/" "profile/share/fonts")
> In procedure string-append: Wrong type (expecting string): #f
> --8<---------------cut here---------------end--------------->8---
>
> [1] https://guix-home.trop.in/Declaring-the-Home-Environment.html
>
>
> The following text in the message is only about the error.
>
> oleg@guixsd ~/src/guix-wip-guix-home$ mkdir /tmp/guix
>
> oleg@guixsd ~/src/guix-wip-guix-home$ guix pull --url=file:///home/oleg/src/guix-wip-guix-home --branch=wip-guix-home -p /tmp/guix/guix
>
> ~/.local/share/chezmoi/dotfiles/guixsd/home.scm:
> --8<---------------cut here---------------start------------->8---
> (use-modules (gnu home)
> (gnu home-services)
> ;; (gnu home-services ssh)
> (gnu home-services shells)
> ;; (gnu home-services files)
> (gnu services)
> (gnu packages admin)
> (guix gexp)
>
> (ice-9 rdelim))
>
> (define %home
> (and=> (getenv "HOME")
> (lambda (home)
> home)))
>
> (define .bash_profile
> (string-append %home "/.local/share/chezmoi/dot_bash_profile"))
>
> (home-environment
>
> ;; (packages (list htop))
>
> (services
> (list
>
> (service home-bash-service-type
> (home-bash-configuration
> (guix-defaults? #t)
> (bash-profile
> (list
> (with-input-from-file .bash_profile read-string)))))
>
> ;; XXX: missing home-files-service-type
> ;; (simple-service 'test-config
> ;; home-files-service-type
> ;; (list `("config/test.conf"
> ;; ,(plain-file "tmp-file.txt"
> ;; "the content of ~/.config/test.conf"))))
>
> ;; XXX: missing home-ssh-configuration
> ;; (service home-ssh-service-type
> ;; (home-ssh-configuration
> ;; (extra-config
> ;; (list
> ;; (ssh-host "savannah"
> ;; '((compression . #f)))))))
>
> )))
> --8<---------------cut here---------------end--------------->8---
>
> My first guix home reconfigure launch:
> --8<---------------cut here---------------start------------->8---
> oleg@guixsd ~/src/guix-wip-guix-home$ /tmp/guix/guix/bin/guix home reconfigure ~/.local/share/chezmoi/dotfiles/guixsd/home.scm
> /gnu/store/xl4igqm0jjy7gfbganz9061ivdgzfpdk-home
> New symlinks to home-environment will be created soon.
> All conflicting files will go to /home/oleg/1630407324-guix-home-legacy-configs-backup.
>
> Skipping /home/oleg/.config (directory already exists)... done
> Creating /home/oleg/.config/fontconfig... done
> Symlinking /home/oleg/.config/fontconfig/fonts.conf -> /gnu/store/phj2z2iiqdhryfy7mqral0b9qz3hlva6-fonts.conf... done
> Backing up /home/oleg/.bashrc... done
> Symlinking /home/oleg/.bashrc -> /gnu/store/513j2xkszmcmv7fiawh59mr0i1fmin55-bashrc... done
> Symlinking /home/oleg/.profile -> /gnu/store/fxbppk3pqzdi3zzy0xl5vg1ir6c5jzq5-shell-profile... done
> Backing up /home/oleg/.bash_profile... done
> Symlinking /home/oleg/.bash_profile -> /gnu/store/2c3yva8vj5ikb0gspmjvzw0r9g9i1cxc-bash_profile... done
> done
> Finished updating symlinks.
>
> Backtrace:
> In guix/ui.scm:
> 2185:7 19 (run-guix . _)
> 2148:10 18 (run-guix-command _ . _)
> In ice-9/boot-9.scm:
> 1752:10 17 (with-exception-handler _ _ #:unwind? _ # _)
> In guix/status.scm:
> 820:3 16 (_)
> 800:4 15 (call-with-status-report _ _)
> In guix/scripts/home.scm:
> 214:4 14 (_)
> In ice-9/boot-9.scm:
> 1752:10 13 (with-exception-handler _ _ #:unwind? _ # _)
> In guix/store.scm:
> 658:37 12 (thunk)
> 1320:8 11 (call-with-build-handler _ _)
> 1320:8 10 (call-with-build-handler #<procedure 7f5d757319c0 at g…> …)
> 2108:24 9 (run-with-store #<store-connection 256.99 7f5d77fb3550> …)
> In guix/scripts/home.scm:
> 169:15 8 (_ _)
> In unknown file:
> 7 (primitive-load "/gnu/store/xl4igqm0jjy7gfbganz9061ivdg…")
> In ice-9/eval.scm:
> 619:8 6 (_ #(#(#(#(#(#(#(#(#(#(#<…> …) …) …) …) …) …) …) …) …) …))
> 626:19 5 (_ #(#(#(#(#(#(#(#(#(#(#<…> …) …) …) …) …) …) …) …) …) …))
> In srfi/srfi-1.scm:
> 586:17 4 (map1 (("profile/share/fonts" (system* "/gnu/stor…" …))))
> In ice-9/eval.scm:
> 293:34 3 (_ #(#(#<directory (guile-user) 7f5d87ca3c80> #<va…>) #))
> In unknown file:
> 2 (string-append #f "/" "profile/share/fonts")
> In ice-9/boot-9.scm:
> 1685:16 1 (raise-exception _ #:continuable? _)
> 1685:16 0 (raise-exception _ #:continuable? _)
>
> ice-9/boot-9.scm:1685:16: In procedure raise-exception:
> In procedure string-append: Wrong type (expecting string): #f

run-on-change service doesn't handle the case, where the previous
generation doesn't exists. Fix should be pretty simple, will send a
patch once it done. Thank you for catching this)

Toggle quote (65 lines)
> --8<---------------cut here---------------end--------------->8---
>
> I skipped the error and tried to configure Bash more:
> --8<---------------cut here---------------start------------->8---
> (define .bashrc
> (string-append %home "/.local/share/chezmoi/dot_bashrc"))
>
> ;; ...
>
> (home-bash-configuration
> ;; ...
> (bashrc
> (list
> (with-input-from-file .bashrc read-string))))
> --8<---------------cut here---------------end--------------->8---
>
> Another launch, no errors this time:
> --8<---------------cut here---------------start------------->8---
> oleg@guixsd ~/src/guix-wip-guix-home$ /tmp/guix/guix/bin/guix home reconfigure ~/.local/share/chezmoi/dotfiles/guixsd/home.scm
> substitute: updating substitutes from 'https://ci.guix.gnu.org'... 100.0%
> substitute: updating substitutes from 'https://bordeaux.guix.gnu.org'... 100.0%
> The following derivations will be built:
> /gnu/store/fn1hzpyic1k32pamyf45vwa0x3lw046g-home.drv
> /gnu/store/akdwz30lx0widqvyqmnkya45cb78f74d-files.drv
> /gnu/store/xcvi7n1l0fvsm099x2vyg6xci0qkayzp-bashrc.drv
> /gnu/store/pm1gw2xakkqj0zxsbbq0jnwgv3v95ajj-provenance.drv
> building /gnu/store/pm1gw2xakkqj0zxsbbq0jnwgv3v95ajj-provenance.drv...
> successfully built /gnu/store/pm1gw2xakkqj0zxsbbq0jnwgv3v95ajj-provenance.drv
> building /gnu/store/xcvi7n1l0fvsm099x2vyg6xci0qkayzp-bashrc.drv...
> successfully built /gnu/store/xcvi7n1l0fvsm099x2vyg6xci0qkayzp-bashrc.drv
> building /gnu/store/akdwz30lx0widqvyqmnkya45cb78f74d-files.drv...
> successfully built /gnu/store/akdwz30lx0widqvyqmnkya45cb78f74d-files.drv
> building /gnu/store/fn1hzpyic1k32pamyf45vwa0x3lw046g-home.drv...
> successfully built /gnu/store/fn1hzpyic1k32pamyf45vwa0x3lw046g-home.drv
> /gnu/store/1y84hzz1m1c3jw03n2g8hn9wwyxngab3-home
> Cleaning up symlinks from previous home-environment.
>
> Removing /home/oleg/.config/fontconfig/fonts.conf... done
> Removing /home/oleg/.config/fontconfig... done
> Skipping /home/oleg/.config (not an empty directory)... done
> Removing /home/oleg/.bashrc... done
> Removing /home/oleg/.profile... done
> Removing /home/oleg/.bash_profile... done
> Cleanup finished.
>
> New symlinks to home-environment will be created soon.
> All conflicting files will go to /home/oleg/1630407412-guix-home-legacy-configs-backup.
>
> Skipping /home/oleg/.config (directory already exists)... done
> Creating /home/oleg/.config/fontconfig... done
> Symlinking /home/oleg/.config/fontconfig/fonts.conf -> /gnu/store/phj2z2iiqdhryfy7mqral0b9qz3hlva6-fonts.conf... done
> Symlinking /home/oleg/.bashrc -> /gnu/store/lf51wflmvx91m2jx8hx3j34qs9x1k153-bashrc... done
> Symlinking /home/oleg/.profile -> /gnu/store/fxbppk3pqzdi3zzy0xl5vg1ir6c5jzq5-shell-profile... done
> Symlinking /home/oleg/.bash_profile -> /gnu/store/2c3yva8vj5ikb0gspmjvzw0r9g9i1cxc-bash_profile... done
> done
> Finished updating symlinks.
>
> Comparing /gnu/store/xl4igqm0jjy7gfbganz9061ivdgzfpdk-home/profile/share/fonts and
> /gnu/store/1y84hzz1m1c3jw03n2g8hn9wwyxngab3-home/profile/share/fonts... done (same)
> Evaling on-change gexps.
>
> On-change gexps evaluation finished.
> --8<---------------cut here---------------end--------------->8---
>
> Oleg.
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCgAdFiEEKEGaxlA4dEDH6S/6IgjSCVjB3rAFAmEuFoMACgkQIgjSCVjB
3rBeTQ//R/adsPvLRB0+bkYq8O8PGYWCLpKLdu9XPuqMuN+FjceajxaqA4hZrTug
RP4RSGjQjuy9pVvHBfZ5sYU0h2D/YSrK6piwlyzpa6vmaZvcANCARyi6NjRL1f9W
Qf0LN+JGLc4WJTjmx/5WPpTuwXJ3/mlLDNRhLr7KpKb56z4Z5c/y618593fTdUP7
FzNQVfUiQbetjmhgYmw1OS9qTMDA+DcJOnHA4qIgtwtX/HMelLwUEVKMXJWHHtsD
QQzbXg9Hi3iuOgB5zVy/yEfVDYmQwIEKOedutIr3dcdz3ZApGcgd9pVNPHnJSVx7
f3fgCOOeE+4dX+QqNGQbN35MCQZ8QldM+VA+VAKOkVXFaNGX6k+rHOUQZoZC7tqb
RMRJszxGUUL/z39DAZJgwxiNyDz5bsDv1QAtPZFzy8gNrGBBpFQ7kvxTlr4C/WQq
hDC/1U/xF9hQoRbt7soMep4Pj0p1rU9SeiIY6I1ZQIAQdWRlHKOaLsKRLWk9wdLi
0pD6/SPoqWV2E/Ardsc3NXF2X/8PLCdocUiyelg5F3leGdYNlyx+/kxk687cJBUv
Sh9uqndCOw++5R2DvKBdhxSWhkS100dxYMKoCHUKOL//eP3Vu6f1dGcNSN2/mGZN
TePxYA/W09ZWC8u4GJGpVIumI/soYFLuiHKtpvVP9suALgL5mWA=
=HP6T
-----END PGP SIGNATURE-----

Closed
A
A
Andrew Tropin wrote on 31 Aug 2021 14:03
87lf4hizxt.fsf@trop.in
On 2021-08-31 12:46, zimoun wrote:

Toggle quote (20 lines)
> Hi Andrew,
>
> On Tue, 31 Aug 2021 at 12:28, Andrew Tropin <andrew@trop.in> wrote:
>> Command and subbcommands allowing to manage home environment with guix.
>>
>> Andrew Tropin (2):
>> scripts: Add 'guix home'.
>> scripts: home: Add import subcommand.
>
> Raghav recently asked [1] an interesting question about consistency of
> command line commands, i.e., compare for instance:
>
> guix system roll-back
> guix pull --roll-back
> guix package --roll-back
>
> I do not have an opinion but is it a conscientious or discussed choice
> for subcommands?
>

Yeah, I also mentioned this inconsistency, but I decided to stick to the
'guix system' approach and use subcommands. I'm not sure, which one is
better, I would like to have pull, package and system to work the same
way, but it seems that such refactoring will berak people setups.
Anyway, I will be keeping the "compatibility" with 'guix system', so if
we decide to change its interface, 'guix home's interface will be
changed too.

Toggle quote (7 lines)
>
>
> All the best,
> simon
>
>
> 1: <https://yhetil.org/guix/fdb27bc6-875e-d0e7-8d8e-4c21331b06c4@raghavgururajan.name>
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCgAdFiEEKEGaxlA4dEDH6S/6IgjSCVjB3rAFAmEuGo4ACgkQIgjSCVjB
3rBcug/8D7NUpsXz0O3UXBs8FhvVLWdw0oIavftR+rNZnJdAzR4NXK2wShkBX2Zl
jokwldbZvChvDpWE++96VFasBQJ56arvDOjZz4ZbAsaS+XUraZrJaM4f2MbSqU+q
rgVvyf6XjAF0GBh39U2uFkb0vbZ2oSbmg0AhPgLNOXMkncIvvFCO1OXgrWOaLeyI
aZrQlZa6P+C3ACBT+NzJzuMOxaI7TuZwJeEZdLRMchWPxV2I/jRTzY+BkWssRF1r
EkA8LhbZ+6o1+d6CXq8c5wmIwCoxpTUsvlNaFe+fbkR8uGdMMo8v4TBA3gMsIugb
dou3pNXJgc4g0U65XBdJ7r9o5k4IyNAD80eEGkF9MmHA2Bks2hm+6h5zJPa91NQj
ljWY6k2BWjCnTwBuZ2zUgSQ6MMm+NFz1G4w7Df5dBInCv7zVV/m7aSplAEx8QZj/
jBBURvZQLVIO/ItGse0xqYI918oVJNQbU194DlvlezAyHLlR5ZJc0zRgaVghqB0i
Kl5qi7h9d64lepC61pG8GzO3k0BHCquwm1n2M1IopuE+PmYBwhnrp3FtX3OQ3ERX
XUylDf8dUjWC1DDcSVAvBnAz9biXd2Ri+8DwC/hb7l8drQ804hK821dAWDL3hjkU
8WzNPwC/KZxikAJ6iCR0ShjCS+Rd/80s6LzOfCp0Ufx6YItdCOA=
=bKOs
-----END PGP SIGNATURE-----

A
A
Andrew Tropin wrote on 31 Aug 2021 14:12
Re: [bug#50296] [PATCH 1/2] scripts: Add 'guix home'.
87ilzlizit.fsf@trop.in
On 2021-08-31 12:53, zimoun wrote:

Toggle quote (39 lines)
> Hi,
>
> On Tue, 31 Aug 2021 at 12:40, Andrew Tropin <andrew@trop.in> wrote:
>
>> +(define-command (guix-home . args)
>> + (synopsis "build and deploy home environments")
>> +
>> + (define (parse-sub-command arg result)
>> + ;; Parse sub-command ARG and augment RESULT accordingly.
>> + (if (assoc-ref result 'action)
>> + (alist-cons 'argument arg result)
>> + (let ((action (string->symbol arg)))
>> + (case action
>> + ((build
>> + reconfigure
>> + extension-graph shepherd-graph
>> + list-generations describe
>> + delete-generations roll-back
>> + switch-generation search
>> + import)
>> + (alist-cons 'action action result))
>> + (else (leave (G_ "~a: unknown action~%") action))))))
>
> For parsing the actions, I would define elsewhere the list. Then if the
> action is unknown, you could use ’string-closest’ and so return an hint
> if there is a typo.
>
> Other said, this
>
> guix home recnfigure
>
> would return
>
> guix home: error: recnfigure: unknown action
> hint: Did you mean `reconfigure'?
>
> WDYT?
>

Sounds good, the same "issue" exists for guix system subcommands, it
would be cool to have such functionality, but I would like to have those
changes to both guix system and guix home after wip-guix-home merged,
because backporting changes to rde is a little tedious.

Also, it seems related to subcommands/--arguments discussion and maybe
better to talk about it in a separate thread.

Toggle quote (2 lines)
>
> Cheers, simon
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCgAdFiEEKEGaxlA4dEDH6S/6IgjSCVjB3rAFAmEuHKoACgkQIgjSCVjB
3rDNKg/+Odxm/7m8GkuO2mvU4LMKdRFENKho6MDtSsML+x7zaWcuD/p9Aibwqbu9
G5p19LUiHEe+zvoUIO8OjMnvBhkynCa/TlyuMnkuEbCshRmisGIeaxQ20aP/UVUX
XuWT7VxmqNAN5FZ18JckFSQwnEGsrUL/0r7bMcL08Koez3SnR1Hczpw8tw0b2zvF
hs6VcrPDV6kyGk1rF4nyRiygENisGp+JUOCqTM3wU1kR8Ikqap471tPRI0DhfcOX
QwfsbmItFAVZj67BnYgebyIazuttqtoPTsHVylQgPRdtaUstpIcZCHAb/x0h4Sr9
IKm0DgN+BgXycrNPYwUdpFBfmoVWzY/0vT0i1cXXyxoGQbcOM/mM/SIMCcm7/M6h
Wh+MvmjEmg31KkTO0fIUsiS1cZWj6ejZMFmkL+jwyczbRVrSPJ8YgXT/8epmJBpS
RiEm9blscWOhnv4IBkqEHxUjpKi2uXVVWJX5AoAsdvS4deniCILRB+dSugsmViU7
1eec8NQg5GI6/6TS6vTdqiIuG9pE6+BsinST5CoGxvu7DoaWEcQ9qAQh9RMeisC9
YCH1e+rleF6030AGJFUdHL9NgJrP3v2tg5DaQfTYuUXqJM3li60WZUgpnwkfc+At
3nP9Fkf5MueiKMw0RRxAtFo0nU0P1PQwInhbrjDh7b4f1YyjcbI=
=FnWQ
-----END PGP SIGNATURE-----

A
A
Andrew Tropin wrote on 31 Aug 2021 14:47
Re: [bug#50296] [PATCH 0/2] Add 'guix home' command.
(name . Oleg Pykhalov)(address . go.wigust@gmail.com)(address . 50296-done@debbugs.gnu.org)
87eea9ixx4.fsf@trop.in
On 2021-08-31 14:46, Andrew Tropin wrote:

Toggle quote (32 lines)
> On 2021-08-31 14:13, Oleg Pykhalov wrote:
>
>> Hi Andrew,
>>
>> Andrew Tropin <andrew@trop.in> writes:
>>
>>> Command and subbcommands allowing to manage home environment with guix.
>>>
>>> Andrew Tropin (2):
>>> scripts: Add 'guix home'.
>>> scripts: home: Add import subcommand.
>>>
>>> Makefile.am | 3 +
>>> guix/scripts/home.scm | 512 +++++++++++++++++++++++++++++++++++
>>> guix/scripts/home/import.scm | 241 +++++++++++++++++
>>> 3 files changed, 756 insertions(+)
>>> create mode 100644 guix/scripts/home.scm
>>> create mode 100644 guix/scripts/home/import.scm
>>
>> I applied your patches and also fixed a typo in
>> gnu/home-services/xdg.scm file, which I noticed during Geiser entering
>> (guix scripts home) module about missing ‘home-services-utils’, which
>> should be ‘home-services utils’.
>>
>
> In rde we have home-services-utils, during recent refactoring I took
> parts of it and split into home-services utils and home-services
> configure modules. For some reason I missed that xdg still uses it and
> I didn't get rid of this import, I'll update xdg module and send patches
> for it, thank you for noticing the issue.
>

The functions from home-services-utils used by xdg now in home-services
utils:
From efd3ea79905c12e2c1c594fa6b54cf62d741f92f Mon Sep 17 00:00:00 2001
From: Andrew Tropin <andrew@trop.in>
Date: Tue, 31 Aug 2021 15:40:07 +0300
Subject: [PATCH 2/2] home-services: configuration: Add
generic-serialize-alist.

* gnu/home-services/configuration.scm (generic-serialize-alist)
(generic-serialize-alist-entry): New variables.
---
gnu/home-services/configuration.scm | 28 +++++++++++++++++++++++++++-
1 file changed, 27 insertions(+), 1 deletion(-)

Toggle diff (58 lines)
diff --git a/gnu/home-services/configuration.scm b/gnu/home-services/configuration.scm
index 039877b5c1..3698006c37 100644
--- a/gnu/home-services/configuration.scm
+++ b/gnu/home-services/configuration.scm
@@ -1,5 +1,6 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2021 Andrew Tropin <andrew@trop.in>
+;;; Copyright © 2021 Xinglu Chen <public@yoctocell.xyz>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -20,6 +21,8 @@
#:use-module (gnu services configuration)
#:use-module (guix gexp)
#:use-module (srfi srfi-1)
+ #:use-module (ice-9 curried-definitions)
+ #:use-module (ice-9 match)
#:export (filter-configuration-fields
@@ -31,7 +34,9 @@
string-or-gexp?
serialize-string-or-gexp
text-config?
- serialize-text-config))
+ serialize-text-config
+ generic-serialize-alist-entry
+ generic-serialize-alist))
(define* (filter-configuration-fields configuration-fields fields
#:optional negate?)
@@ -79,3 +84,24 @@ the list result in @code{#t} when applying PRED? on them."
(and (list? config) (every string-or-gexp? config)))
(define (serialize-text-config field-name val)
#~(string-append #$@(interpose val "\n" 'suffix)))
+
+(define ((generic-serialize-alist-entry serialize-field) entry)
+ "Apply the SERIALIZE-FIELD procedure on the field and value of ENTRY."
+ (match entry
+ ((field . val) (serialize-field field val))))
+
+(define (generic-serialize-alist combine serialize-field fields)
+ "Generate a configuration from an association list FIELDS.
+
+SERIALIZE-FIELD is a procedure that takes two arguments, it will be
+applied on the fields and values of FIELDS using the
+@code{generic-serialize-alist-entry} procedure.
+
+COMBINE is a procedure that takes one or more arguments and combines
+all the alist entries into one value, @code{string-append} or
+@code{append} are usually good candidates for this.
+
+See the @code{serialize-alist} procedure in `@code{(gnu home-services
+version-control}' for an example usage.)}"
+ (apply combine
+ (map (generic-serialize-alist-entry serialize-field) fields)))
--
2.33.0
Toggle quote (134 lines)
>
>>
>> Pushed to wip-guix-home.
>>
>> Also, I tried to use guix home for the first time as documented at site
>> [1], and got an error:
>> --8<---------------cut here---------------start------------->8---
>> (string-append #f "/" "profile/share/fonts")
>> In procedure string-append: Wrong type (expecting string): #f
>> --8<---------------cut here---------------end--------------->8---
>>
>> [1] https://guix-home.trop.in/Declaring-the-Home-Environment.html
>>
>>
>> The following text in the message is only about the error.
>>
>> oleg@guixsd ~/src/guix-wip-guix-home$ mkdir /tmp/guix
>>
>> oleg@guixsd ~/src/guix-wip-guix-home$ guix pull --url=file:///home/oleg/src/guix-wip-guix-home --branch=wip-guix-home -p /tmp/guix/guix
>>
>> ~/.local/share/chezmoi/dotfiles/guixsd/home.scm:
>> --8<---------------cut here---------------start------------->8---
>> (use-modules (gnu home)
>> (gnu home-services)
>> ;; (gnu home-services ssh)
>> (gnu home-services shells)
>> ;; (gnu home-services files)
>> (gnu services)
>> (gnu packages admin)
>> (guix gexp)
>>
>> (ice-9 rdelim))
>>
>> (define %home
>> (and=> (getenv "HOME")
>> (lambda (home)
>> home)))
>>
>> (define .bash_profile
>> (string-append %home "/.local/share/chezmoi/dot_bash_profile"))
>>
>> (home-environment
>>
>> ;; (packages (list htop))
>>
>> (services
>> (list
>>
>> (service home-bash-service-type
>> (home-bash-configuration
>> (guix-defaults? #t)
>> (bash-profile
>> (list
>> (with-input-from-file .bash_profile read-string)))))
>>
>> ;; XXX: missing home-files-service-type
>> ;; (simple-service 'test-config
>> ;; home-files-service-type
>> ;; (list `("config/test.conf"
>> ;; ,(plain-file "tmp-file.txt"
>> ;; "the content of ~/.config/test.conf"))))
>>
>> ;; XXX: missing home-ssh-configuration
>> ;; (service home-ssh-service-type
>> ;; (home-ssh-configuration
>> ;; (extra-config
>> ;; (list
>> ;; (ssh-host "savannah"
>> ;; '((compression . #f)))))))
>>
>> )))
>> --8<---------------cut here---------------end--------------->8---
>>
>> My first guix home reconfigure launch:
>> --8<---------------cut here---------------start------------->8---
>> oleg@guixsd ~/src/guix-wip-guix-home$ /tmp/guix/guix/bin/guix home reconfigure ~/.local/share/chezmoi/dotfiles/guixsd/home.scm
>> /gnu/store/xl4igqm0jjy7gfbganz9061ivdgzfpdk-home
>> New symlinks to home-environment will be created soon.
>> All conflicting files will go to /home/oleg/1630407324-guix-home-legacy-configs-backup.
>>
>> Skipping /home/oleg/.config (directory already exists)... done
>> Creating /home/oleg/.config/fontconfig... done
>> Symlinking /home/oleg/.config/fontconfig/fonts.conf -> /gnu/store/phj2z2iiqdhryfy7mqral0b9qz3hlva6-fonts.conf... done
>> Backing up /home/oleg/.bashrc... done
>> Symlinking /home/oleg/.bashrc -> /gnu/store/513j2xkszmcmv7fiawh59mr0i1fmin55-bashrc... done
>> Symlinking /home/oleg/.profile -> /gnu/store/fxbppk3pqzdi3zzy0xl5vg1ir6c5jzq5-shell-profile... done
>> Backing up /home/oleg/.bash_profile... done
>> Symlinking /home/oleg/.bash_profile -> /gnu/store/2c3yva8vj5ikb0gspmjvzw0r9g9i1cxc-bash_profile... done
>> done
>> Finished updating symlinks.
>>
>> Backtrace:
>> In guix/ui.scm:
>> 2185:7 19 (run-guix . _)
>> 2148:10 18 (run-guix-command _ . _)
>> In ice-9/boot-9.scm:
>> 1752:10 17 (with-exception-handler _ _ #:unwind? _ # _)
>> In guix/status.scm:
>> 820:3 16 (_)
>> 800:4 15 (call-with-status-report _ _)
>> In guix/scripts/home.scm:
>> 214:4 14 (_)
>> In ice-9/boot-9.scm:
>> 1752:10 13 (with-exception-handler _ _ #:unwind? _ # _)
>> In guix/store.scm:
>> 658:37 12 (thunk)
>> 1320:8 11 (call-with-build-handler _ _)
>> 1320:8 10 (call-with-build-handler #<procedure 7f5d757319c0 at g…> …)
>> 2108:24 9 (run-with-store #<store-connection 256.99 7f5d77fb3550> …)
>> In guix/scripts/home.scm:
>> 169:15 8 (_ _)
>> In unknown file:
>> 7 (primitive-load "/gnu/store/xl4igqm0jjy7gfbganz9061ivdg…")
>> In ice-9/eval.scm:
>> 619:8 6 (_ #(#(#(#(#(#(#(#(#(#(#<…> …) …) …) …) …) …) …) …) …) …))
>> 626:19 5 (_ #(#(#(#(#(#(#(#(#(#(#<…> …) …) …) …) …) …) …) …) …) …))
>> In srfi/srfi-1.scm:
>> 586:17 4 (map1 (("profile/share/fonts" (system* "/gnu/stor…" …))))
>> In ice-9/eval.scm:
>> 293:34 3 (_ #(#(#<directory (guile-user) 7f5d87ca3c80> #<va…>) #))
>> In unknown file:
>> 2 (string-append #f "/" "profile/share/fonts")
>> In ice-9/boot-9.scm:
>> 1685:16 1 (raise-exception _ #:continuable? _)
>> 1685:16 0 (raise-exception _ #:continuable? _)
>>
>> ice-9/boot-9.scm:1685:16: In procedure raise-exception:
>> In procedure string-append: Wrong type (expecting string): #f
>
> run-on-change service doesn't handle the case, where the previous
> generation doesn't exists. Fix should be pretty simple, will send a
> patch once it done. Thank you for catching this)
>

The fix:
From a07541380d412b33c504e5811776062af4e38582 Mon Sep 17 00:00:00 2001
From: Andrew Tropin <andrew@trop.in>
Date: Tue, 31 Aug 2021 15:24:25 +0300
Subject: [PATCH 1/2] home-services: run-on-change: Handle first generation
case.

---
gnu/home-services.scm | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)

Toggle diff (23 lines)
diff --git a/gnu/home-services.scm b/gnu/home-services.scm
index 2a773496f0..5608c65175 100644
--- a/gnu/home-services.scm
+++ b/gnu/home-services.scm
@@ -448,13 +448,14 @@ with one gexp, but many times, and all gexps must be idempotent.")))
(if any-changes? (cadr x) "")))
'#$pattern-gexp-tuples))
- (if #$eval-gexps?
+ (if (and #$eval-gexps? (getenv "GUIX_OLD_HOME"))
(begin
(display "Evaling on-change gexps.\n\n")
(for-each primitive-eval expressions-to-eval)
(display "On-change gexps evaluation finished.\n\n"))
(display "\
-On-change gexps won't evaluated, disabled by service configuration.\n"))))
+On-change gexps won't evaluated, disabled by service configuration or
+there are no previos generations.\n"))))
(define home-run-on-change-service-type
(service-type (name 'home-run-on-change)
--
2.33.0
Toggle quote (66 lines)
>
>> --8<---------------cut here---------------end--------------->8---
>>
>> I skipped the error and tried to configure Bash more:
>> --8<---------------cut here---------------start------------->8---
>> (define .bashrc
>> (string-append %home "/.local/share/chezmoi/dot_bashrc"))
>>
>> ;; ...
>>
>> (home-bash-configuration
>> ;; ...
>> (bashrc
>> (list
>> (with-input-from-file .bashrc read-string))))
>> --8<---------------cut here---------------end--------------->8---
>>
>> Another launch, no errors this time:
>> --8<---------------cut here---------------start------------->8---
>> oleg@guixsd ~/src/guix-wip-guix-home$ /tmp/guix/guix/bin/guix home reconfigure ~/.local/share/chezmoi/dotfiles/guixsd/home.scm
>> substitute: updating substitutes from 'https://ci.guix.gnu.org'... 100.0%
>> substitute: updating substitutes from 'https://bordeaux.guix.gnu.org'... 100.0%
>> The following derivations will be built:
>> /gnu/store/fn1hzpyic1k32pamyf45vwa0x3lw046g-home.drv
>> /gnu/store/akdwz30lx0widqvyqmnkya45cb78f74d-files.drv
>> /gnu/store/xcvi7n1l0fvsm099x2vyg6xci0qkayzp-bashrc.drv
>> /gnu/store/pm1gw2xakkqj0zxsbbq0jnwgv3v95ajj-provenance.drv
>> building /gnu/store/pm1gw2xakkqj0zxsbbq0jnwgv3v95ajj-provenance.drv...
>> successfully built /gnu/store/pm1gw2xakkqj0zxsbbq0jnwgv3v95ajj-provenance.drv
>> building /gnu/store/xcvi7n1l0fvsm099x2vyg6xci0qkayzp-bashrc.drv...
>> successfully built /gnu/store/xcvi7n1l0fvsm099x2vyg6xci0qkayzp-bashrc.drv
>> building /gnu/store/akdwz30lx0widqvyqmnkya45cb78f74d-files.drv...
>> successfully built /gnu/store/akdwz30lx0widqvyqmnkya45cb78f74d-files.drv
>> building /gnu/store/fn1hzpyic1k32pamyf45vwa0x3lw046g-home.drv...
>> successfully built /gnu/store/fn1hzpyic1k32pamyf45vwa0x3lw046g-home.drv
>> /gnu/store/1y84hzz1m1c3jw03n2g8hn9wwyxngab3-home
>> Cleaning up symlinks from previous home-environment.
>>
>> Removing /home/oleg/.config/fontconfig/fonts.conf... done
>> Removing /home/oleg/.config/fontconfig... done
>> Skipping /home/oleg/.config (not an empty directory)... done
>> Removing /home/oleg/.bashrc... done
>> Removing /home/oleg/.profile... done
>> Removing /home/oleg/.bash_profile... done
>> Cleanup finished.
>>
>> New symlinks to home-environment will be created soon.
>> All conflicting files will go to /home/oleg/1630407412-guix-home-legacy-configs-backup.
>>
>> Skipping /home/oleg/.config (directory already exists)... done
>> Creating /home/oleg/.config/fontconfig... done
>> Symlinking /home/oleg/.config/fontconfig/fonts.conf -> /gnu/store/phj2z2iiqdhryfy7mqral0b9qz3hlva6-fonts.conf... done
>> Symlinking /home/oleg/.bashrc -> /gnu/store/lf51wflmvx91m2jx8hx3j34qs9x1k153-bashrc... done
>> Symlinking /home/oleg/.profile -> /gnu/store/fxbppk3pqzdi3zzy0xl5vg1ir6c5jzq5-shell-profile... done
>> Symlinking /home/oleg/.bash_profile -> /gnu/store/2c3yva8vj5ikb0gspmjvzw0r9g9i1cxc-bash_profile... done
>> done
>> Finished updating symlinks.
>>
>> Comparing /gnu/store/xl4igqm0jjy7gfbganz9061ivdgzfpdk-home/profile/share/fonts and
>> /gnu/store/1y84hzz1m1c3jw03n2g8hn9wwyxngab3-home/profile/share/fonts... done (same)
>> Evaling on-change gexps.
>>
>> On-change gexps evaluation finished.
>> --8<---------------cut here---------------end--------------->8---
>>
>> Oleg.
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCgAdFiEEKEGaxlA4dEDH6S/6IgjSCVjB3rAFAmEuJMcACgkQIgjSCVjB
3rDUmw//a1IxwssRamJwRhFACw8IZ8vpTcp/GdWxaXZKY1oq1kVlp6PM6BzmQ9T9
NL5JcrKrR8uganqrIx7s+x+ONrIdMgGLRLsNb/pLnOtPd4kWuxDhw5KNTDL2KZku
LqXZX3YnIJ+Ry9kxzk+p6q9/qVF50xGOERawBv3Z+DHl6kPK6DRPpr1gNh3eR3LP
HBBk25bi1Xrd/lWMLTQkNqo9LHiJK7C1R8y62vsfbYKDBdc6lzkcP3kNIoZ9bZyw
KkqQgNsibYGj+bC+F+uQpvj8zSy7HBapIkGq/gFnTlhTDvK36B3ZVm81BSLjOOlG
FNfnUYb4HdHGdCrOU/vSlpJqN4vmcK7xS2NMVchMWo5+V4jCsINQkWIMHJqwL/WO
5k6tPLddHH5nwXkGdkIUschwt8qdzSz4RIKtF9uDnVkdYYtEZwKzMYDFZvs9tob1
uEDuzt0f9dbX/b2gJA8QYjmz5Bs/Jrc0A9MAHS9/cFdGu0DsDYAc1M9uATA9gfj4
7bDkuCcA0f4YutGMH+IvAl1AgFGauKSA6HKSTg8Zh7pL8plbvQKIDnL8ey2vY8fJ
ndJlZjjX40wGSnGZnU7ErwKWk2JH30Q/sgJEL6+7kt15xUZt7b9jS6C9Mqd7GzXI
lMENLia8TfZSLjxqc7bMH2X6zlwYX+/HxmipPZpcQKzc+hiWM/0=
=z6Xh
-----END PGP SIGNATURE-----

Closed
Z
Z
zimoun wrote on 31 Aug 2021 15:09
Re: [bug#50296] [PATCH 1/2] scripts: Add 'guix home'.
(name . Andrew Tropin)(address . andrew@trop.in)(address . 50296@debbugs.gnu.org)
CAJ3okZ2X5QAJBRZDgtqOFaBbMWJDRpn-oHBeKMTwwL1LdkahQw@mail.gmail.com
Hi,

On Tue, 31 Aug 2021 at 14:12, Andrew Tropin <andrew@trop.in> wrote:
Toggle quote (26 lines)
> On 2021-08-31 12:53, zimoun wrote:
> > On Tue, 31 Aug 2021 at 12:40, Andrew Tropin <andrew@trop.in> wrote:
> >
> >> +(define-command (guix-home . args)
> >> + (synopsis "build and deploy home environments")
> >> +
> >> + (define (parse-sub-command arg result)
> >> + ;; Parse sub-command ARG and augment RESULT accordingly.
> >> + (if (assoc-ref result 'action)
> >> + (alist-cons 'argument arg result)
> >> + (let ((action (string->symbol arg)))
> >> + (case action
> >> + ((build
> >> + reconfigure
> >> + extension-graph shepherd-graph
> >> + list-generations describe
> >> + delete-generations roll-back
> >> + switch-generation search
> >> + import)
> >> + (alist-cons 'action action result))
> >> + (else (leave (G_ "~a: unknown action~%") action))))))
> >
> > For parsing the actions, I would define elsewhere the list. Then if the
> > action is unknown, you could use ’string-closest’ and so return an hint
> > if there is a typo.

[...]

Toggle quote (5 lines)
> Sounds good, the same "issue" exists for guix system subcommands, it
> would be cool to have such functionality, but I would like to have those
> changes to both guix system and guix home after wip-guix-home merged,
> because backporting changes to rde is a little tedious.

Your point is to hint both "guix system" and "guix home" in the same
time because they share the same pattern. Right?

Toggle quote (3 lines)
> Also, it seems related to subcommands/--arguments discussion and maybe
> better to talk about it in a separate thread.

Yes, and from my understanding, your answer is keep consistency with
"guix system". :-)

Cheers,
simon
O
O
Oleg Pykhalov wrote on 31 Aug 2021 16:23
Re: [bug#50296] [PATCH 0/2] Add 'guix home' command.
(name . Andrew Tropin)(address . andrew@trop.in)(address . 50296-done@debbugs.gnu.org)
87pmtt8zh0.fsf@gmail.com
Andrew Tropin <andrew@trop.in> writes:

[…]

Toggle quote (12 lines)
> The functions from home-services-utils used by xdg now in home-services
> utils:
>
> From efd3ea79905c12e2c1c594fa6b54cf62d741f92f Mon Sep 17 00:00:00 2001
> From: Andrew Tropin <andrew@trop.in>
> Date: Tue, 31 Aug 2021 15:40:07 +0300
> Subject: [PATCH 2/2] home-services: configuration: Add
> generic-serialize-alist.
>
> * gnu/home-services/configuration.scm (generic-serialize-alist)
> (generic-serialize-alist-entry): New variables.

As you said, no variables, but functions ;-)

Also, we could join those functions in Git commit message with comma.

Applied with changes above.

[…]

Toggle quote (17 lines)
>> run-on-change service doesn't handle the case, where the previous
>> generation doesn't exists. Fix should be pretty simple, will send a
>> patch once it done. Thank you for catching this)
>>
>
> The fix:
>
> From a07541380d412b33c504e5811776062af4e38582 Mon Sep 17 00:00:00 2001
> From: Andrew Tropin <andrew@trop.in>
> Date: Tue, 31 Aug 2021 15:24:25 +0300
> Subject: [PATCH 1/2] home-services: run-on-change: Handle first generation
> case.
>
> ---
> gnu/home-services.scm | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)

[…]

Added Git changelog-like line.

Applied.

Pushed to wip-guix-home as 0c7bb26435513a61814d98af1c790e43a74afb6e.

Oleg.
-----BEGIN PGP SIGNATURE-----

iQJIBAEBCgAyFiEEcjhxI46s62NFSFhXFn+OpQAa+pwFAmEuO2sUHGdvLndpZ3Vz
dEBnbWFpbC5jb20ACgkQFn+OpQAa+pzgKhAAx1ie4fYYIz8iCcVhiloGnVN4N4pE
iLNeGAvWG64wrI9GMyWlKrm2QSIrlwlqW1mKtUA6M2OLF5FaeSbZWOGbQ+qVcVJR
xwKdLNS8qn+eNO3DeJyYBxb7PoOgPYMmHTwRgN4IpDtyqj3w+Zn+vKB4f6hpAqDt
4NoYDa0/32mntwvoQDkggvRNVaRxHd9T1T8yuHv2E2MZN7oqPvKmPUdo/GR5Czrx
Aa3lSiyPPqKDZSR5b0LK2wEVDAhZDrlH27lQ8RvbJ8sDO4kACZGhj2DXcLidoS2x
6qO5wRpFSxJ0CfO9qLl0gaxBlG5mPx3QrFHhcBEnZltmQK9dwTv8Jwrf1Zzq4QdA
EUvdt8XcgSddlNVzFaA3AZGpeCtLw3uSEmLrUvITHKzfJvcckTHLEj3L6SpDADLk
w88SjZM5mgEL4YYO67MGSwj/hUQMch7jDbTQTdkzHdHi81l34Ebc64QmoR0a2XH7
eYeKWDT8PvDTc9UOIUAxIrlAbR3LgUN+T2tOnirjbHvDe4w5zOVh6+6m4QVW6BcX
+svmbfjGBieeUmaxaqGiAAP1lg0Dzawkm5T6OX4F1+UIhbfxYNUxrn0FWzqKLNnt
imCWrxUl4h3ddqn/VrV83J84UH+/4cd7Ez5OfhKH3rOVSPzWdtcWUhnr9lQV3Khe
iu4/cf3OKBFPBys=
=uX5l
-----END PGP SIGNATURE-----

Closed
A
A
Andrew Tropin wrote on 1 Sep 2021 07:20
Re: [bug#50296] [PATCH 1/2] scripts: Add 'guix home'.
(name . zimoun)(address . zimon.toutoune@gmail.com)(address . 50296@debbugs.gnu.org)
87lf4gzxbi.fsf@trop.in
On 2021-08-31 15:09, zimoun wrote:

Toggle quote (48 lines)
> Hi,
>
> On Tue, 31 Aug 2021 at 14:12, Andrew Tropin <andrew@trop.in> wrote:
>> On 2021-08-31 12:53, zimoun wrote:
>> > On Tue, 31 Aug 2021 at 12:40, Andrew Tropin <andrew@trop.in> wrote:
>> >
>> >> +(define-command (guix-home . args)
>> >> + (synopsis "build and deploy home environments")
>> >> +
>> >> + (define (parse-sub-command arg result)
>> >> + ;; Parse sub-command ARG and augment RESULT accordingly.
>> >> + (if (assoc-ref result 'action)
>> >> + (alist-cons 'argument arg result)
>> >> + (let ((action (string->symbol arg)))
>> >> + (case action
>> >> + ((build
>> >> + reconfigure
>> >> + extension-graph shepherd-graph
>> >> + list-generations describe
>> >> + delete-generations roll-back
>> >> + switch-generation search
>> >> + import)
>> >> + (alist-cons 'action action result))
>> >> + (else (leave (G_ "~a: unknown action~%") action))))))
>> >
>> > For parsing the actions, I would define elsewhere the list. Then if the
>> > action is unknown, you could use ’string-closest’ and so return an hint
>> > if there is a typo.
>
> [...]
>
>> Sounds good, the same "issue" exists for guix system subcommands, it
>> would be cool to have such functionality, but I would like to have those
>> changes to both guix system and guix home after wip-guix-home merged,
>> because backporting changes to rde is a little tedious.
>
> Your point is to hint both "guix system" and "guix home" in the same
> time because they share the same pattern. Right?
>
>> Also, it seems related to subcommands/--arguments discussion and maybe
>> better to talk about it in a separate thread.
>
> Yes, and from my understanding, your answer is keep consistency with
> "guix system". :-)
>
> Cheers,
> simon

Yep, corret (:
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCgAdFiEEKEGaxlA4dEDH6S/6IgjSCVjB3rAFAmEvDZEACgkQIgjSCVjB
3rCBuhAAkFjmNkkx8CCD0n4ez7mhICxLwET6gZqHkCG5GYYIKNjk9wflPHFpvwD6
E4xBLhi13lhQvSVD38ZbYnFPWIvmG5ykZB9jHPjFATqU17TSI4FF/Sn1sXz5084n
rD3qpAZJ1q6gSJMLCX/YJzzqUYqhaV/zGgX53qiN1hX4t0BBPxKuS9rGtS1CkIsT
100HROpQUJvT+XHyYhbOEYqYBVIYUI7G2nWwu/yyTNJWzBdAXbbybe27cUCdI/n/
8aV75MtVr1XzA8hLieyvarpbU2PyqTmPYmTrVA4oFX8FitkQG5l3VMlPkTfsCm0l
mqnVaXg2WKHPJVpBXjkuSnHPdcPhA02p09b98bSsPDXNqSDUzLSBIX9LGPZJpzWL
77GQ5i7J4gxakON7bW3yesygFO/fas2CG+kWYr2smV4l5SSFmdQzAjat8zh2dtTs
/MSmJqIi0Zi251Eaek4lhLaRLbztQmJxmGvGngjsAW7qsORLNVjDImQx7coavD0U
qXZAQ8+9w3kQuL4JlU9e0MOIwAziL0fKBu7ZIjTKbqPywwXCKmTOijekUXbVih0T
Xikvt1ArSVyMpOCer5qoFfbj84UWTxsr9957YrAplZlj9p2JvtDcgl5IBCeW9r0h
Pes5a+pAKRh9MhseD1XkZdi6ngeVE3nAPZ1f9CrCiJVy8Kz8seA=
=s3J9
-----END PGP SIGNATURE-----

A
A
Andrew Tropin wrote on 1 Sep 2021 07:36
Re: [bug#50296] [PATCH 0/2] Add 'guix home' command.
(name . Oleg Pykhalov)(address . go.wigust@gmail.com)(address . 50296-done@debbugs.gnu.org)
87ilzkzwkq.fsf@trop.in
On 2021-08-31 17:23, Oleg Pykhalov wrote:

Toggle quote (52 lines)
> Andrew Tropin <andrew@trop.in> writes:
>
> […]
>
>> The functions from home-services-utils used by xdg now in home-services
>> utils:
>>
>> From efd3ea79905c12e2c1c594fa6b54cf62d741f92f Mon Sep 17 00:00:00 2001
>> From: Andrew Tropin <andrew@trop.in>
>> Date: Tue, 31 Aug 2021 15:40:07 +0300
>> Subject: [PATCH 2/2] home-services: configuration: Add
>> generic-serialize-alist.
>>
>> * gnu/home-services/configuration.scm (generic-serialize-alist)
>> (generic-serialize-alist-entry): New variables.
>
> As you said, no variables, but functions ;-)
>
> Also, we could join those functions in Git commit message with comma.
>
> Applied with changes above.
>
> […]
>
>>> run-on-change service doesn't handle the case, where the previous
>>> generation doesn't exists. Fix should be pretty simple, will send a
>>> patch once it done. Thank you for catching this)
>>>
>>
>> The fix:
>>
>> From a07541380d412b33c504e5811776062af4e38582 Mon Sep 17 00:00:00 2001
>> From: Andrew Tropin <andrew@trop.in>
>> Date: Tue, 31 Aug 2021 15:24:25 +0300
>> Subject: [PATCH 1/2] home-services: run-on-change: Handle first generation
>> case.
>>
>> ---
>> gnu/home-services.scm | 5 +++--
>> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> […]
>
> Added Git changelog-like line.
>
> Applied.
>
> Pushed to wip-guix-home as 0c7bb26435513a61814d98af1c790e43a74afb6e.
>
> Oleg.


Cool, seems now we have a working copy of guix home in wip-guix-home,
I'll start cleaning up the documentation and prepare it for merging.

Thank you for your help with all that stuff)
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCgAdFiEEKEGaxlA4dEDH6S/6IgjSCVjB3rAFAmEvEVUACgkQIgjSCVjB
3rBnuQ//R+npgyFXQpWT4/bkahpRoRO4vn0l5owgNiRF82NoHQNckeGRtCYAmdB4
rFn7y/3VVK7B9eDyhCyWRQF+mfCpiyvdfSeKcJTBl8R3N33vRw8ggCRc2rz9OABK
oi4wuHO4Yqp7rr0fS8lUnEAw5Jr65PeMvugGatIwMdOy4c1JePU5imKS5AA8SFMU
vG1zYDLPKsJOfEQ4UuSPyL+UBTlL/ECvIEGe7p/Y+5InNKHh2Oah3np+v39TNmHA
tBbgE1LnZNjtK4WdkAIT5zSFWRlFscqr2s88VYfxSILklL3OkBtavDlHZiMMot6F
0ZBQZLglqrTmY6HsSLMP0QfCO5wyfbUQdrPZEyZZMP6N0Ut7beCn78oAXWfLeySL
wWjlS6u0wB0nmxkTVSaXG/Wk9d2pnOs0vB5/PVHs/MqrxLon4J1znbbk3LmOovNO
wfPDQzGA2r/x6bfU/14zTg2fqtNwqV6s2KUkXbsbta3LLFtEICMtpUYQlWqKbke0
PzNwUqCrjVHbYaNTNoriV/Gesxmx451QwSgmRGBoMA0JEeb3vvtJhWjXQ+D98tig
4OduOftN9OSJUyPlo/J+ciDy/tQRvuqk+pd3OTbs6giDRCHI5ZipbELKMRo2IvK0
an9tJYXb9edrco6yut6CI2hpVri+VP9dbcldmv8zBBPmsyabHfU=
=Vxn8
-----END PGP SIGNATURE-----

Closed
A
A
Andrew Tropin wrote on 9 Sep 2021 08:10
(name . Oleg Pykhalov)(address . go.wigust@gmail.com)(address . 50296-done@debbugs.gnu.org)
87ee9yuvnb.fsf@trop.in
On 2021-08-31 17:23, Oleg Pykhalov wrote:

Toggle quote (51 lines)
> Andrew Tropin <andrew@trop.in> writes:
>
> […]
>
>> The functions from home-services-utils used by xdg now in home-services
>> utils:
>>
>> From efd3ea79905c12e2c1c594fa6b54cf62d741f92f Mon Sep 17 00:00:00 2001
>> From: Andrew Tropin <andrew@trop.in>
>> Date: Tue, 31 Aug 2021 15:40:07 +0300
>> Subject: [PATCH 2/2] home-services: configuration: Add
>> generic-serialize-alist.
>>
>> * gnu/home-services/configuration.scm (generic-serialize-alist)
>> (generic-serialize-alist-entry): New variables.
>
> As you said, no variables, but functions ;-)
>
> Also, we could join those functions in Git commit message with comma.
>
> Applied with changes above.
>
> […]
>
>>> run-on-change service doesn't handle the case, where the previous
>>> generation doesn't exists. Fix should be pretty simple, will send a
>>> patch once it done. Thank you for catching this)
>>>
>>
>> The fix:
>>
>> From a07541380d412b33c504e5811776062af4e38582 Mon Sep 17 00:00:00 2001
>> From: Andrew Tropin <andrew@trop.in>
>> Date: Tue, 31 Aug 2021 15:24:25 +0300
>> Subject: [PATCH 1/2] home-services: run-on-change: Handle first generation
>> case.
>>
>> ---
>> gnu/home-services.scm | 5 +++--
>> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> […]
>
> Added Git changelog-like line.
>
> Applied.
>
> Pushed to wip-guix-home as 0c7bb26435513a61814d98af1c790e43a74afb6e.
>
> Oleg.

I did a little better solution for the first generation case for
on-change service. Added it as fixup commit, so it's necessary to
rebase with --autosquash to get it melded in the right place. Can you
also rebase the whole branch on the latest master and recreate it,
please? I'll test it and will be preparing for merge. Probably will
send a few more patches, but they should be minor.
From 6f3ec7f6bb4a6f495c4b7f38fce7cb31d179097b Mon Sep 17 00:00:00 2001
From: Andrew Tropin <andrew@trop.in>
Date: Wed, 8 Sep 2021 08:15:35 +0300
Subject: [PATCH] fixup! home-services: run-on-change: Handle first generation
case.

---
gnu/home-services.scm | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)

Toggle diff (36 lines)
diff --git a/gnu/home-services.scm b/gnu/home-services.scm
index 5608c65175..9f1e986616 100644
--- a/gnu/home-services.scm
+++ b/gnu/home-services.scm
@@ -439,7 +439,10 @@ with one gexp, but many times, and all gexps must be idempotent.")))
(define expressions-to-eval
(map
(lambda (x)
- (let* ((file1 (string-append (getenv "GUIX_OLD_HOME") "/" (car x)))
+ (let* ((file1 (string-append
+ (or (getenv "GUIX_OLD_HOME")
+ "/gnu/store/non-existing-generation")
+ "/" (car x)))
(file2 (string-append (getenv "GUIX_NEW_HOME") "/" (car x)))
(_ (format #t "Comparing ~a and\n~10t~a..." file1 file2))
(any-changes? (something-changed? file1 file2))
@@ -448,14 +451,14 @@ with one gexp, but many times, and all gexps must be idempotent.")))
(if any-changes? (cadr x) "")))
'#$pattern-gexp-tuples))
- (if (and #$eval-gexps? (getenv "GUIX_OLD_HOME"))
+ (if #$eval-gexps?
(begin
(display "Evaling on-change gexps.\n\n")
(for-each primitive-eval expressions-to-eval)
(display "On-change gexps evaluation finished.\n\n"))
(display "\
-On-change gexps won't evaluated, disabled by service configuration or
-there are no previos generations.\n"))))
+On-change gexps won't be evaluated, disabled by service
+configuration.\n"))))
(define home-run-on-change-service-type
(service-type (name 'home-run-on-change)
--
2.33.0
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCgAdFiEEKEGaxlA4dEDH6S/6IgjSCVjB3rAFAmE5pUgACgkQIgjSCVjB
3rBXVA/6Ajk69Fqoq3JAwlQ6MmwEZ0u7DUDFWnP+tOA3Jp23yvN4cShWrHBMCDJU
MVTgms7BMGKGb1uO0Z91J3WVKDQxYwOHa8QFic/+DWtkhYkLHX1Twu2veLrCgnuu
hzbSJGBr8glsSQFyScnYvA+bEXKVJvQh3vQ4RtU8ofAJUcDGrF9afFoGIbrLFF9w
hzb+fv2Rk8gpaPzJH/BCNI50nyJxS2ZOevQTsb8EPQWnCsh5/GO0LD4Dj64qA73O
GHm1eMaa+BkRDmNlwczmpxdfh60gL5Xykh5GQNIBMndEQlqr4j/KNLYoluS5En0O
HzPbaJtlikeuzXQw9MQOw8lPKXG/oQs/2BJ3WYIGf1H5gtVarNt2MJb4wKfuHCI4
07ZtsH9SuF99L4raZIbU/g5ULqRFzR6BRM22zfu3Jp8eolOaYLdNl120ZlXNev5e
jjZTTBuek5zJF3go7PtXtWvFg/7hCwis/uo+KkxWHFqnobENoMVM1+xAtiopTQBv
Ik7s/C79s+8dz0pGi2FKfjifKJfvx82T4v4amnMbzIr3xhOelW0Lpo5RXceX7Zod
6aTDUhdjw+QCUBEeV7PPiq1XF/u4wPQPnUF0+EF142CBrhRLOW1nMChZPcSxIGhH
bBNp/XSUJRvnB/vK/mffPQkCICUaaVAvWfag+aFie1JkFBqcgH0=
=jLqQ
-----END PGP SIGNATURE-----

Closed
O
O
Oleg Pykhalov wrote on 9 Sep 2021 19:45
(name . Andrew Tropin)(address . andrew@trop.in)(address . 50296-done@debbugs.gnu.org)
875yv9lk18.fsf@gmail.com
Andrew Tropin <andrew@trop.in> writes:

[…]

Toggle quote (17 lines)
> I did a little better solution for the first generation case for
> on-change service. Added it as fixup commit, so it's necessary to
> rebase with --autosquash to get it melded in the right place. Can you
> also rebase the whole branch on the latest master and recreate it,
> please? I'll test it and will be preparing for merge. Probably will
> send a few more patches, but they should be minor.
>
> From 6f3ec7f6bb4a6f495c4b7f38fce7cb31d179097b Mon Sep 17 00:00:00 2001
> From: Andrew Tropin <andrew@trop.in>
> Date: Wed, 8 Sep 2021 08:15:35 +0300
> Subject: [PATCH] fixup! home-services: run-on-change: Handle first generation
> case.
>
> ---
> gnu/home-services.scm | 11 +++++++----
> 1 file changed, 7 insertions(+), 4 deletions(-)

I did what you asked, but please, don't depend on recreating the branch
next time. Otherwise we will wait for other contributers decision about
this approach. Every branch recreation guix-commits mailing list
receives a batch of messages, which could annoy subscribers.

Thanks,
Oleg.
-----BEGIN PGP SIGNATURE-----

iQJIBAEBCgAyFiEEcjhxI46s62NFSFhXFn+OpQAa+pwFAmE6SFMUHGdvLndpZ3Vz
dEBnbWFpbC5jb20ACgkQFn+OpQAa+px4rQ/+MCP5YSZ9Wt/rSNDBN74qwf6WBHL5
jeKAXSZ4pKsEvMaQu9HE8M55hzx1lwanP698EkfJ+9V5iR2Ggt1/TlPFFroTB8NN
V343fbN5AKdYHEqn7abLvPL5mFL2lKxtcO+ExHKneQA6qzOC/7WXxouDqC5JDQ3r
trWyFg742g/Pg4rwjbxnYf9+BIDjGIvZW/JzWshE5PiH2sjaddHecZI74fYqTE4E
Co9jm7u/crRrWoCvqnrvLgXplEUbTxfE+zBL4PkfsF5uEOdTU8HUjkM1065ODox/
UqzeCnMeAK71HYdPZB7EwwM4qo567SfStrlype+6UNQGeiSh/VM30r3+wE9CQYyj
ZSbPm5Wuqy191hYbtP0WjEidgP5H1fwmcZTnLHm/uahaVbuGFRjh11FFBipG3ib2
6smQWjpusWtwXxhQjOMVMcbe3Z+5gyx6yJPyRAEvB3G0XiBlMV5u9cjLyAa/gSGS
BNPT9sEJhbPY5nDqQUsYA8ow+VAQbR3N6b8uhLqBDWZnWV0GJ+4faJtt1DNHGcgb
whkb61LtLzJFtcqDt/LZ+Ki/JG2OX3fF80LPiv1DG/V+Xiejpq6KNXUMG8eifcVa
yUj4s8YMIrf5v1L+zeGSgML5de3fzvbEeGouxrrrrEmFFCBNGpWRlHmrQyJ3ATlT
/Sll5a7RTPjxJ+8=
=qkRr
-----END PGP SIGNATURE-----

Closed
A
A
Andrew Tropin wrote on 10 Sep 2021 07:31
(name . Oleg Pykhalov)(address . go.wigust@gmail.com)(address . 50296-done@debbugs.gnu.org)
87h7etyp1i.fsf@trop.in
On 2021-09-09 20:45, Oleg Pykhalov wrote:

Toggle quote (29 lines)
> Andrew Tropin <andrew@trop.in> writes:
>
> […]
>
>> I did a little better solution for the first generation case for
>> on-change service. Added it as fixup commit, so it's necessary to
>> rebase with --autosquash to get it melded in the right place. Can you
>> also rebase the whole branch on the latest master and recreate it,
>> please? I'll test it and will be preparing for merge. Probably will
>> send a few more patches, but they should be minor.
>>
>> From 6f3ec7f6bb4a6f495c4b7f38fce7cb31d179097b Mon Sep 17 00:00:00 2001
>> From: Andrew Tropin <andrew@trop.in>
>> Date: Wed, 8 Sep 2021 08:15:35 +0300
>> Subject: [PATCH] fixup! home-services: run-on-change: Handle first generation
>> case.
>>
>> ---
>> gnu/home-services.scm | 11 +++++++----
>> 1 file changed, 7 insertions(+), 4 deletions(-)
>
> I did what you asked, but please, don't depend on recreating the branch
> next time. Otherwise we will wait for other contributers decision about
> this approach. Every branch recreation guix-commits mailing list
> receives a batch of messages, which could annoy subscribers.
>
> Thanks,
> Oleg.

Thank you!

Didn't think about guix-commits ML, ok, will try to avoid this next
time)
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCgAdFiEEKEGaxlA4dEDH6S/6IgjSCVjB3rAFAmE67bkACgkQIgjSCVjB
3rB3ew//cR3vEAagmvS2jMOm2zIpqHyhm4FuWIK9vd87XE66OKpnZCJrh8ShbVQB
730qkRTqD49C1ddRun25PzGEeGpS3AToSIQ436vZ7Ps0/0MjiCsii5gTyUD9QsbI
Om57DQqzX4yiT+AKJdXoIMDRrN6Im+dx6VUCwj1SI2iy9QVCPpv3YUfdBQHCgMhi
xwcS2HGpNcaE2tK2o/5pVwMhrWwO1UTVMY1hr8gQIlTFB95nnihE/dHi89f/rS3d
PF26xwFvqDRzBE83WerS7pcxYsr+Vn/aPCIqh6vaQjRlVii3KeGuaQ/IQteSeuC+
JScfij4F3JR6vAmW7mnpc44aoA0/Ot2WRCamAamLd4h3FRlrLaoTiMwphVWhaelD
UhNSt+dGD3J0oO/h7NO3okHyAcjo7R9rbHu4Vwas3yHIqisXvxmaRhPwRXAGpcUZ
EjTJBZHaV7mYoypgvrh5LJIQy2YWJaDEU5p2Kvl+0ifgz78tJNoJKAxQusd7huvL
VEDLUabYxjllczchVAbmOsRbkwuAcsL74ivo08l+vULO8wiEP4A3WBPL/ICU56H4
dtEBcHKvzE+QBL9nRXlYkpcbk/Ocn9YjcaIJqA7meTRfXNZFkD4zhA6WaBlsZOpR
obpTLH0HHaCmI9nexq3aw15ulyT3BRbKlANocSkUNB2CqUkLW3w=
=e5rh
-----END PGP SIGNATURE-----

Closed
?