[PATCH 0/4] Essential home services

  • Done
  • quality assurance status badge
Details
4 participants
  • Andrew Tropin
  • Oleg Pykhalov
  • Ludovic Courtès
  • Maxime Devos
Owner
unassigned
Submitted by
Andrew Tropin
Severity
normal
Merged with
A
A
Andrew Tropin wrote on 5 Jul 2021 17:35
(address . guix-patches@gnu.org)
87y2akhiz1.fsf@trop.in
This patch series contains most crucial home services and few helper functions
required for Guix Home.

Andrew Tropin (4):
home-services: Add most essential home services
home-services: Add home-run-on-change-service-type
home-services: Add home-provenance-service-type
home-services: Add fold-home-service-types function

gnu/home-services.scm | 472 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 472 insertions(+)
create mode 100644 gnu/home-services.scm

--
2.32.0
-----BEGIN PGP SIGNATURE-----

iQJDBAEBCgAtFiEEKEGaxlA4dEDH6S/6IgjSCVjB3rAFAmDjJrIPHGFuZHJld0B0
cm9wLmluAAoJECII0glYwd6wHSgP/iGWNsxcvgbodO7ee4UwF8pTKG24ulIlYHC/
AJ2ifrYwaX+EcrBS9nZ2/PkQZR6a+/+YEUXmS5Ys1akuDNbyQLRL+F6YXyyjsIH1
2Ko4mg0QpppSwpTOtwFzQSv0HYH7PURh8cjDeD63qKvzKhhrH59nyrBf/ePeWW14
KSap8Ant7ULNUM1kp86bFBbXGeEh7wf7NH9ftsBnpp947xUKc4RnhOeQyC/wg7Xl
zHSOY2ACJ/0hbt+i0nzM/yNqnINaSYkAxQga0M4g2sRYbIskcvdwVgonGDkaaCjV
qHp9a3Ugru5oKVGNlf52E4PkdVMIIctAmHGL7Eh1yyl11FZNUvtjoShYQCAcYOBd
bjpwq2O4UX+0CU+SnBw++2KWNj+j3ENdWW27fpPYo7/KUrFUIRTSVa6vodOXw1q3
nvMHv+Cqz6fcZeWHwHLoPIcwcjk76kPNplIvAlImva/BpY4cwdU5/ptzuSGH2dsn
AwIpue1PE5gWDVLfv2Lu7QUqOTQvcfaI+yOtEWwuvjt788XwsOcB6C3oWJIb+nsV
qr/A9SKdgT5/VVKMy1kaJCKVyuFxpqP6XzzBVsfSjVp8qlM7399EUr6IKVXxldTJ
qAmvUYBHajBP0YyGs8dX/yWSfJMnQurtUlpnQ/kMKpMtetjE0luFL2VVB8KnEqth
H6tLhYZx
=T9SZ
-----END PGP SIGNATURE-----

A
A
Andrew Tropin wrote on 5 Jul 2021 17:37
[PATCH 1/4] home-services: Add most essential home services
(address . 49419@debbugs.gnu.org)
87wnq4hivq.fsf@trop.in
home-service-type is a root of home services DAG.

home-profile-service-type is almost the same as profile-service-type, at least
for now.

home-environment-variables-service-type generates a @file{setup-environment}
shell script, which is expected to be sourced by login shell or other program,
which starts early and spawns all other processes. Home services for shells
automatically add code for sourcing this file, if person do not use those home
services they have to source this script manually in their's shell *profile
file (details described in the manual).

home-files-service-type is similar to etc-service-type, but doesn't extend
home-activation, because deploy mechanism for config files is pluggable and
can be different for different home environments: The default one is called
symlink-manager (will be introudced in a separate patch series), which creates
links for various dotfiles (like $XDG_CONFIG_HOME/$APP/...) to store, but is
possible to implement alternative approaches like read-only home from Julien's
guix-home-manager.

home-run-on-first-login-service-type provides an @file{on-first-login} guile
script, which runs provided gexps once, when user makes first login. It can
be used to start user's Shepherd and maybe some other process. It relies on
assumption that /run/user/$UID will be created on login by some login
manager (elogind for example).

home-activation-service-type provides an @file{activate} guile script, which
do three main things:

- Sets environment variables to the values declared in
@file{setup-environment} shell script. It's necessary, because user can set
for example XDG_CONFIG_HOME and it should be respected by activation gexp of
symlink-manager.

- Sets GUIX_NEW_HOME and possibly GUIX_OLD_HOME vars to paths in the store.
Later those variables can be used by activation gexps, for example by
symlink-manager or run-on-change services.

- Run all activation gexps provided by other home services.
---
gnu/home-services.scm | 328 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 328 insertions(+)
create mode 100644 gnu/home-services.scm

Toggle diff (336 lines)
diff --git a/gnu/home-services.scm b/gnu/home-services.scm
new file mode 100644
index 0000000000..44a7e68934
--- /dev/null
+++ b/gnu/home-services.scm
@@ -0,0 +1,328 @@
+;;; 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 (gnu home-services)
+ #:use-module (gnu services)
+ #:use-module (guix channels)
+ #:use-module (guix monads)
+ #:use-module (guix store)
+ #:use-module (guix gexp)
+ #:use-module (guix profiles)
+ #:use-module (guix sets)
+ #:use-module (guix ui)
+ #:use-module (guix discovery)
+ #:use-module (guix diagnostics)
+
+ #:use-module (srfi srfi-1)
+ #:use-module (ice-9 match)
+
+ #:export (home-service-type
+ home-profile-service-type
+ home-environment-variables-service-type
+ home-files-service-type
+ home-run-on-first-login-service-type
+ home-activation-service-type)
+
+ #:re-export (service
+ service-type
+ service-extension))
+
+;;; Comment:
+;;;
+;;; This module is similar to (gnu system services) module, but
+;;; provides Home Services, which are supposed to be used for building
+;;; home-environment.
+;;;
+;;; Home Services use the same extension as System Services. Consult
+;;; (gnu system services) module or manual for more information.
+;;;
+;;; Code:
+
+
+(define (home-derivation entries mextensions)
+ "Return as a monadic value the derivation of the 'home'
+directory containing the given entries."
+ (mlet %store-monad ((extensions (mapm/accumulate-builds identity
+ mextensions)))
+ (lower-object
+ (file-union "home" (append entries (concatenate extensions))))))
+
+(define home-service-type
+ ;; This is the ultimate service type, the root of the home service
+ ;; DAG. The service of this type is extended by monadic name/item
+ ;; pairs. These items end up in the "home-environment directory" as
+ ;; returned by 'home-environment-derivation'.
+ (service-type (name 'home)
+ (extensions '())
+ (compose identity)
+ (extend home-derivation)
+ (default-value '())
+ (description
+ "Build the home environment top-level directory,
+which in turn refers to everything the home environment needs: its
+packages, configuration files, activation script, and so on.")))
+
+(define (packages->profile-entry packages)
+ "Return a system entry for the profile containing PACKAGES."
+ ;; XXX: 'mlet' is needed here for one reason: to get the proper
+ ;; '%current-target' and '%current-target-system' bindings when
+ ;; 'packages->manifest' is called, and thus when the 'package-inputs'
+ ;; etc. procedures are called on PACKAGES. That way, conditionals in those
+ ;; inputs see the "correct" value of these two parameters. See
+ ;; <https://issues.guix.gnu.org/44952>.
+ (mlet %store-monad ((_ (current-target-system)))
+ (return `(("profile" ,(profile
+ (content (packages->manifest
+ (map identity
+ ;;(options->transformation transformations)
+ (delete-duplicates packages eq?))))))))))
+
+;; MAYBE: Add a list of transformations for packages. It's better to
+;; place it in home-profile-service-type to affect all profile
+;; packages and prevent conflicts, when other packages relies on
+;; non-transformed version of package.
+(define home-profile-service-type
+ (service-type (name 'home-profile)
+ (extensions
+ (list (service-extension home-service-type
+ packages->profile-entry)))
+ (compose concatenate)
+ (extend append)
+ (description
+ "This is the @dfn{home profile} and can be found in
+@file{~/.guix-home/profile}. It contains packages and
+configuration files that the user has declared in their
+@code{home-environment} record.")))
+
+(define (environment-variables->setup-environment-script vars)
+ "Return a file that can be sourced by a POSIX compliant shell which
+initializes the environment. The file will source the home
+environment profile, set some default environment variables, and set
+environment variables provided in @code{vars}. @code{vars} is a list
+of pairs (@code{(key . value)}), @code{key} is a string and
+@code{value} is a string or gexp.
+
+If value is @code{#f} variable will be omitted.
+If value is @code{#t} variable will be just exported.
+For any other, value variable will be set to the @code{value} and
+exported."
+ (define (warn-about-duplicate-defenitions)
+ (fold
+ (lambda (x acc)
+ (when (equal? (car x) (car acc))
+ (warning
+ (G_ "duplicate definition for `~a' environment variable ~%") (car x)))
+ x)
+ (cons "" "")
+ (sort vars (lambda (a b)
+ (string<? (car a) (car b))))))
+
+ (warn-about-duplicate-defenitions)
+ (with-monad
+ %store-monad
+ (return
+ `(("setup-environment"
+ ;; TODO: It's necessary to source ~/.guix-profile too
+ ;; on foreign distros
+ ,(apply mixed-text-file "setup-environment"
+ "\
+HOME_ENVIRONMENT=$HOME/.guix-home
+GUIX_PROFILE=\"$HOME_ENVIRONMENT/profile\"
+PROFILE_FILE=\"$HOME_ENVIRONMENT/profile/etc/profile\"
+[ -f $PROFILE_FILE ] && . $PROFILE_FILE
+
+case $XDG_DATA_DIRS in
+ *$HOME_ENVIRONMENT/profile/share*) ;;
+ *) export XDG_DATA_DIRS=$HOME_ENVIRONMENT/profile/share:$XDG_DATA_DIRS ;;
+esac
+case $MANPATH in
+ *$HOME_ENVIRONMENT/profile/share/man*) ;;
+ *) export MANPATH=$HOME_ENVIRONMENT/profile/share/man:$MANPATH
+esac
+case $INFOPATH in
+ *$HOME_ENVIRONMENT/profile/share/info*) ;;
+ *) export INFOPATH=$HOME_ENVIRONMENT/profile/share/info:$INFOPATH ;;
+esac
+case $XDG_CONFIG_DIRS in
+ *$HOME_ENVIRONMENT/profile/etc/xdg*) ;;
+ *) export XDG_CONFIG_DIRS=$HOME_ENVIRONMENT/profile/etc/xdg:$XDG_CONFIG_DIRS ;;
+esac
+case $XCURSOR_PATH in
+ *$HOME_ENVIRONMENT/profile/share/icons*) ;;
+ *) export XCURSOR_PATH=$HOME_ENVIRONMENT/profile/share/icons:$XCURSOR_PATH ;;
+esac
+
+"
+
+ (append-map
+ (match-lambda
+ ((key . #f)
+ '())
+ ((key . #t)
+ (list "export " key "\n"))
+ ((key . value)
+ (list "export " key "=" value "\n")))
+ vars)))))))
+
+(define home-environment-variables-service-type
+ (service-type (name 'home-environment-variables)
+ (extensions
+ (list (service-extension
+ home-service-type
+ environment-variables->setup-environment-script)))
+ (compose concatenate)
+ (extend append)
+ (default-value '())
+ (description "Set the environment variables.")))
+
+(define (files->files-directory files)
+ "Return a @code{files} directory that contains FILES."
+ (define (assert-no-duplicates files)
+ (let loop ((files files)
+ (seen (set)))
+ (match files
+ (() #t)
+ (((file _) rest ...)
+ (when (set-contains? seen file)
+ (raise (formatted-message (G_ "duplicate '~a' entry for files/")
+ file)))
+ (loop rest (set-insert file seen))))))
+
+ ;; Detect duplicates early instead of letting them through, eventually
+ ;; leading to a build failure of "files.drv".
+ (assert-no-duplicates files)
+
+ (file-union "files" files))
+
+(define (files-entry files)
+ "Return an entry for the @file{~/.guix-home/files}
+directory containing FILES."
+ (with-monad %store-monad
+ (return `(("files" ,(files->files-directory files))))))
+
+(define home-files-service-type
+ (service-type (name 'home-files)
+ (extensions
+ (list (service-extension home-service-type
+ files-entry)))
+ (compose concatenate)
+ (extend append)
+ (default-value '())
+ (description "Configuration files for programs that
+will be put in @file{~/.guix-home/files}.")))
+
+(define (compute-on-first-login-script _ gexps)
+ (gexp->script
+ "on-first-login"
+ #~(let* ((xdg-runtime-dir (or (getenv "XDG_RUNTIME_DIR")
+ (format #f "/run/user/~a" (getuid))))
+ (flag-file-path (string-append
+ xdg-runtime-dir "/on-first-login-executed"))
+ (touch (lambda (file-name)
+ (call-with-output-file file-name (const #t)))))
+ ;; XDG_RUNTIME_DIR dissapears on logout, that means such trick
+ ;; allows to launch on-first-login script on first login only
+ ;; after complete logout/reboot.
+ (when (not (file-exists? flag-file-path))
+ (begin #$@gexps (touch flag-file-path))))))
+
+(define (on-first-login-script-entry m-on-first-login)
+ "Return, as a monadic value, an entry for the on-first-login script
+in the home environment directory."
+ (mlet %store-monad ((on-first-login m-on-first-login))
+ (return `(("on-first-login" ,on-first-login)))))
+
+(define home-run-on-first-login-service-type
+ (service-type (name 'home-run-on-first-login)
+ (extensions
+ (list (service-extension
+ home-service-type
+ on-first-login-script-entry)))
+ (compose identity)
+ (extend compute-on-first-login-script)
+ (default-value #f)
+ (description "Run gexps on first user login. Can be
+extended with one gexp.")))
+
+
+(define (compute-activation-script init-gexp gexps)
+ (gexp->script
+ "activate"
+ #~(let* ((he-init-file (lambda (he) (string-append he "/setup-environment")))
+ (he-path (string-append (getenv "HOME") "/.guix-home"))
+ (new-home-env (getenv "GUIX_NEW_HOME"))
+ (new-home (or new-home-env
+ ;; Path of the activation file if called interactively
+ (dirname (car (command-line)))))
+ (old-home-env (getenv "GUIX_OLD_HOME"))
+ (old-home (or old-home-env
+ (if (file-exists? (he-init-file he-path))
+ (readlink he-path)
+ #f))))
+ (if (file-exists? (he-init-file new-home))
+ (let* ((port ((@@ (ice-9 popen) open-input-pipe)
+ (format #f "source ~a && env"
+ (he-init-file new-home))))
+ (result ((@@ (ice-9 rdelim) read-delimited) "" port))
+ (vars (map (lambda (x)
+ (let ((si (string-index x #\=)))
+ (cons (string-take x si)
+ (string-drop x (1+ si)))))
+ ((@@ (srfi srfi-1) remove)
+ string-null?
+ (string-split result #\newline)))))
+ (close-port port)
+ (map (lambda (x) (setenv (car x) (cdr x))) vars)
+
+ (setenv "GUIX_NEW_HOME" new-home)
+ (setenv "GUIX_OLD_HOME" old-home)
+
+ #$@gexps
+
+ ;; Do not unset env variable if it was set outside.
+ (unless new-home-env (setenv "GUIX_NEW_HOME" #f))
+ (unless old-home-env (setenv "GUIX_OLD_HOME" #f)))
+ (format #t "\
+Activation script was either called or loaded by file from this direcotry:
+~a
+It doesn't seem that home environment is somewhere around.
+Make sure that you call ./activate by symlink from -home store item.\n"
+ new-home)))))
+
+(define (activation-script-entry m-activation)
+ "Return, as a monadic value, an entry for the activation script
+in the home environment directory."
+ (mlet %store-monad ((activation m-activation))
+ (return `(("activate" ,activation)))))
+
+(define home-activation-service-type
+ (service-type (name 'home-activation)
+ (extensions
+ (list (service-extension
+ home-service-type
+ activation-script-entry)))
+ (compose identity)
+ (extend compute-activation-script)
+ (default-value #f)
+ (description "Run gexps to activate the current
+generation of home environment and update the state of the home
+directory. @command{activate} script automatically called during
+reconfiguration or generation switching. This service can be extended
+with one gexp, but many times, and all gexps must be idempotent.")))
+
--
2.32.0
-----BEGIN PGP SIGNATURE-----

iQJDBAEBCgAtFiEEKEGaxlA4dEDH6S/6IgjSCVjB3rAFAmDjJykPHGFuZHJld0B0
cm9wLmluAAoJECII0glYwd6wEhQP/jgDYw5Erlq3nGRdfwKsKGBLkdYphrx1CE+5
qqdZ3u4IGd66O9gKskHtz9BR1Hr8rY/DPc8ZpUYob7TrmwCPgDRv8GWqnzYAaIBh
cr0ga65Do5mBWNUqGbvV/m95qdXcxMhgx0A6sMjNmvI9y5/TMP1HSN+IXZh4AfUe
db//TBBOhK1hGOkHhepPzekJkOYlz0JYMgsTwYJ6kFMx7tKMI3nawMcEjZBBQ48R
24gvmgKfaGrtnmdpR8EcUqC/odRzo9TEabIDhH9rQefW8JAbq8+G8WltLqfckeZQ
/u3MFov2fulXHvEwc5GhKCiRfqrJEc2rVvVJJKJjW1NYkHeJ8ad/6Kd58j7N1tzF
iyMoVZq2e4B207064pIoj3vA4ZepJ3BG5c81HBvBNFjuKJtKRaAACdtNIhJvwFtX
YR/M243/lvBbkk+Ms2it73k1xBfvr0YEpC2A13E6AEd8XgP9+kDauydy4x4396lW
OqbI5nTW39vb+jCfkCxoUWTaTeBqFxq6RkUps1lsKw0K2aXaQKbwldvB5c2BGuhm
1pqCn7ty2tjUu/g8e+t0MLOP6OFAG/9otrREouFs2Q2YC86vEtdrvYqZoFTpBsC5
7PKkNmopJZP/w2dNXI7pKml3T7Z5NfsVah1uM9ewGUYBjc3bLDE4HVja2kesXngB
Kf+rUERt
=bWHO
-----END PGP SIGNATURE-----

A
A
Andrew Tropin wrote on 5 Jul 2021 17:39
[PATCH 2/4] home-services: Add home-run-on-change-service-type
(address . 49419@debbugs.gnu.org)
87v95ohirj.fsf@trop.in
Service allows to trigger actions during activation if file or directory
specified by pattern is changed.
---
gnu/home-services.scm | 95 ++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 94 insertions(+), 1 deletion(-)

Toggle diff (112 lines)
diff --git a/gnu/home-services.scm b/gnu/home-services.scm
index 44a7e68934..002a003d65 100644
--- a/gnu/home-services.scm
+++ b/gnu/home-services.scm
@@ -37,7 +37,8 @@
home-environment-variables-service-type
home-files-service-type
home-run-on-first-login-service-type
- home-activation-service-type)
+ home-activation-service-type
+ home-run-on-change-service-type)
#:re-export (service
service-type
@@ -326,3 +327,95 @@ directory. @command{activate} script automatically called during
reconfiguration or generation switching. This service can be extended
with one gexp, but many times, and all gexps must be idempotent.")))
+
+;;;
+;;; On-change.
+;;;
+
+(define (compute-on-change-gexp eval-gexps? pattern-gexp-tuples)
+ #~(begin
+ (define (equal-regulars? file1 file2)
+ "Check if FILE1 and FILE2 are bit for bit identical."
+ (let* ((cmp-binary #$(file-append
+ (@@ (gnu packages base) diffutils) "/bin/cmp"))
+ (status (system* cmp-binary file1 file2)))
+ (= status 0)))
+
+ (define (equal-symlinks? symlink1 symlink2)
+ "Check if SYMLINK1 and SYMLINK2 are pointing to the same target."
+ (string=? (readlink symlink1) (readlink symlink2)))
+
+ (define (equal-directories? dir1 dir2)
+ "Check if DIR1 and DIR2 have the same content."
+ (define (ordinary-file file)
+ (not (or (string=? file ".")
+ (string=? file ".."))))
+ (let* ((files1 (scandir dir1 ordinary-file))
+ (files2 (scandir dir2 ordinary-file)))
+ (if (equal? files1 files2)
+ (map (lambda (file)
+ (equal-files?
+ (string-append dir1 "/" file)
+ (string-append dir2 "/" file)))
+ files1)
+ #f)))
+
+ (define (equal-files? file1 file2)
+ "Compares files, symlinks or directories of the same type."
+ (case (file-type file1)
+ ((directory) (equal-directories? file1 file2))
+ ((symlink) (equal-symlinks? file1 file2))
+ ((regular) (equal-regulars? file1 file2))
+ (else
+ (display "The file type is unsupported by on-change service.\n")
+ #f)))
+
+ (define (file-type file)
+ (stat:type (lstat file)))
+
+ (define (something-changed? file1 file2)
+ (cond
+ ((and (not (file-exists? file1))
+ (not (file-exists? file2))) #f)
+ ((or (not (file-exists? file1))
+ (not (file-exists? file2))) #t)
+
+ ((not (eq? (file-type file1) (file-type file2))) #t)
+
+ (else
+ (not (equal-files? file1 file2)))))
+
+ (define expressions-to-eval
+ (map
+ (lambda (x)
+ (let* ((file1 (string-append (getenv "GUIX_OLD_HOME") "/" (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))
+ (_ (format #t " done (~a)\n"
+ (if any-changes? "changed" "same"))))
+ (if any-changes? (cadr x) "")))
+ '#$pattern-gexp-tuples))
+
+ (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.\n"))))
+
+(define home-run-on-change-service-type
+ (service-type (name 'home-run-on-change)
+ (extensions
+ (list (service-extension
+ home-activation-service-type
+ identity)))
+ (compose concatenate)
+ (extend compute-on-change-gexp)
+ (default-value #t)
+ (description "\
+G-expressions to run if the specified files have changed since the
+last generation. The extension should be a list of lists where the
+first element is the pattern for file or directory that expected to be
+changed, and the second element is the G-expression to be evaluated.")))
--
2.32.0
-----BEGIN PGP SIGNATURE-----

iQJDBAEBCgAtFiEEKEGaxlA4dEDH6S/6IgjSCVjB3rAFAmDjJ8APHGFuZHJld0B0
cm9wLmluAAoJECII0glYwd6waMIP/iftqlC/BHYKJZUXuGla6gqEyIZy495xHJGq
ZPHSZaIcqnGjTx2A7J5+w6xTsDgnRzTAzXtJ+7Wx31sS3mk1noVSBDVxA7HGsFu4
KUP/gjjRxm9qsegRtWWrvHjDrRpmTfG460/HOvS5b80gVlr0o8A1UL/O7fElPqk9
rr0vbx18f/FB+m0EwiApk2g26ORrHEDL4YhIT+fvW3JxgGTCTVUF+T6DyiRa2wKa
cIH6pVi2DFzNEIECfbi6adWkNNLgX/PY+shrQJZTVopDPRu0oND04wL/TZWvryfK
BW9Gigi6Ma2iSj47qn1+RicUKNZi6NJgnv+jUBngSxhFDWfQBLJgMJKgGB6agNFW
gLcwFTe6KHdgrOu2oiH9Cc4uhUQw+g3ddCR8mfkSvST/RafMWgOrptFWspHrLfMH
F3uTMGlUJ76m+9sjdFkgI4vdvzWSX96M94ddkWFJFSG0KhRtqQ9kCf01MM7bRDFL
QRtQ7zhgUOoAQlz5xSs5aTh+2FkGf0Xdd5itUP8IGXzYhtQLvm2/HhaRF035YoDu
c4qWmvS5454VG152u1Bz/QsM95uxZSEPChqEIyquSFcyX5WUQHDVa2e6RoO1DmFY
EBYy4XwnzCKaLpWvarC3z9E7SCYJIBkSqb4oV3OLtklHiADFSu8LD7UdYmK8vKFU
JytNaSV7
=Zq/L
-----END PGP SIGNATURE-----

A
A
Andrew Tropin wrote on 5 Jul 2021 17:41
[PATCH 3/4] home-services: Add home-provenance-service-type
(address . 49419@debbugs.gnu.org)
87sg0ship8.fsf@trop.in
* gnu/home-services.scm (home-provenance-service-type, sexp->home-provenance,
home-provenance): New variables.
---
gnu/home-services.scm | 27 ++++++++++++++++++++++++++-
1 file changed, 26 insertions(+), 1 deletion(-)

Toggle diff (44 lines)
diff --git a/gnu/home-services.scm b/gnu/home-services.scm
index 002a003d65..20a9537650 100644
--- a/gnu/home-services.scm
+++ b/gnu/home-services.scm
@@ -38,7 +38,10 @@
home-files-service-type
home-run-on-first-login-service-type
home-activation-service-type
- home-run-on-change-service-type)
+ home-run-on-change-service-type
+ home-provenance-service-type
+
+ fold-home-service-types)
#:re-export (service
service-type
@@ -419,3 +422,25 @@ G-expressions to run if the specified files have changed since the
last generation. The extension should be a list of lists where the
first element is the pattern for file or directory that expected to be
changed, and the second element is the G-expression to be evaluated.")))
+
+
+;;;
+;;; Provenance tracking.
+;;;
+
+(define home-provenance-service-type
+ (service-type
+ (name 'home-provenance)
+ (extensions
+ (list (service-extension
+ home-service-type
+ (service-extension-compute
+ (first (service-type-extensions provenance-service-type))))))
+ (default-value #f) ;the HE config file
+ (description "\
+Store provenance information about the home environment in the home
+environment itself: the channels used when building the home
+environment, and its configuration file, when available.")))
+
+(define sexp->home-provenance sexp->system-provenance)
+(define home-provenance system-provenance)
--
2.32.0
-----BEGIN PGP SIGNATURE-----

iQJDBAEBCgAtFiEEKEGaxlA4dEDH6S/6IgjSCVjB3rAFAmDjKBMPHGFuZHJld0B0
cm9wLmluAAoJECII0glYwd6wFgQP/25DCZPMwKYLNPaIz+QqKQODiND/L+UK+UMS
arAdMlZIEQoDaUXU+5e7ekzxhIwOXcF1MIXAjeGX/VogNDRFmk8btSUndXlcBr4f
bjpPn1DOof8QwZIZJ1/TKcC+pz7uNA4s0q6/MjZLn4XxJHz4eaqMip+CnKUBTIIQ
FTO0Z9KMFUhwDNIprBCM1t/JpGlDLdCRAIxeV6LCoYCOWskEVLAa76JrrJ7kI9p3
U4uezVeLlVCET6RKgy8IkZM6w9e+Gk8VFz4nAwJ2FpdLxYir8J5wC0pCkImhrOR5
g2ksdmLLS7u88jKdIfHVCrGqRQ7kA4MLVhHzCXRnu9ZlZ/wm8gz4NYWVPeT173VK
lFYcXTi83B4MCxuzj3JXijNcWDQK1Q814k6PwhqHoxLziRDCyvPgwwwRSpPTtZRQ
ChC8FB8C4bc/vA4KEJA9wwJjydUMpkZ3q3dvzZBqKFpzbIJKygrTUToUk7dAjo96
fYBzqVwqfECvVNERnelc3Vrak4Ad55cZLWiQ/62U7pp2ZprlUJg4hjeycihmvK3Q
ciQZ8G5gWGx8fhR8k/BUcZSAgp34wy4sRaXPU19irPgpuAWZPGub5DM2t5CIVJh3
hsF5RKJM5COmAB2XDnsppkSpdC6H/67jCT1aNUyqUBQ0wBMexMG26R+2nOdiSLGB
KeqwmUsw
=EObI
-----END PGP SIGNATURE-----

A
A
Andrew Tropin wrote on 5 Jul 2021 17:41
[PATCH 4/4] home-services: Add fold-home-service-types function
(address . 49419@debbugs.gnu.org)
87pmvwhio6.fsf@trop.in
* gnu/home-services.scm (parent-directory, %guix-home-root-directory,
%service-type-path, all-home-service-modules, fold-home-service-types): New
variables.
---
gnu/home-services.scm | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)

Toggle diff (36 lines)
diff --git a/gnu/home-services.scm b/gnu/home-services.scm
index 20a9537650..a06cd72459 100644
--- a/gnu/home-services.scm
+++ b/gnu/home-services.scm
@@ -444,3 +444,29 @@ environment, and its configuration file, when available.")))
(define sexp->home-provenance sexp->system-provenance)
(define home-provenance system-provenance)
+
+
+;;;
+;;; Searching
+;;;
+
+(define (parent-directory directory)
+ "Get the parent directory of DIRECTORY"
+ (string-join (drop-right (string-split directory #\/) 1) "/"))
+
+(define %guix-home-root-directory
+ ;; Absolute file name of the module hierarchy.
+ (parent-directory (dirname (search-path %load-path "gnu/home-services.scm"))))
+
+(define %service-type-path
+ ;; Search path for service types.
+ (make-parameter `((,%guix-home-root-directory . "gnu/home-services"))))
+
+(define (all-home-service-modules)
+ "Return the default set of home-service modules."
+ (cons (resolve-interface '(gnu home-services))
+ (all-modules (%service-type-path)
+ #:warn warn-about-load-error)))
+
+(define* (fold-home-service-types proc seed)
+ (fold-service-types proc seed (all-home-service-modules)))
--
2.32.0
-----BEGIN PGP SIGNATURE-----

iQJDBAEBCgAtFiEEKEGaxlA4dEDH6S/6IgjSCVjB3rAFAmDjKDkPHGFuZHJld0B0
cm9wLmluAAoJECII0glYwd6wnIgP/isEncoPbwrs77ZNLilDgzqLXZzFPMsZembM
kHKhSufjTTuDdvutWFZJGXPDjoGchJCp2/jIlQmQ2qRrZ2CfhLvUVnAnHQbt1oSI
wh8XecyKY2ML4QjV1J9jkXH4XcLKkrAlqkbVeXNXcrtJFTZdPlbcUdsaR0PKJ5xC
O2cb2+qcMGf6wof3tJjxkKzqS3wVEwOKRWHad5dik/F3FdYM6UcsRxNr9Qhcb8yM
oqS3ccjAznkH+NZehl4JqeIUqVewlhQYb8gn8zTEA1paFLBfZxYFALjDxKhdB5MR
kekSlIPRkDJavuQKNogL9Rui9N2dOiwuxWXCiPLdql8/mYTEazTFMm4Cm/1Kw6zt
4BouLKAVfRJpO5/bK6Z/eaKxRgf/fTsXQu+UM7G242ahR8oflAve9Txuno/TtDDJ
tU0ZzHoY2jPfV8MCV8D8xGKudbjHSzunHlMfvUoLTiF4WLzhuEuX7eKgo0yP3IuZ
T64LgwHzaKkDStMgYyomxVEJhSL4WWYZxYyFaftVGMj8RFhzvKlUySXZFF5tkLgw
pxB2xgT50qaP+PMXePOorSyIgS6+IQveV+auRjbfCpaCjEriWnJk+4hYRHLyRPQr
zTY9BrY5JV86PCn6YbAKqZaiFImM5CGZJFAx/7AQaheo5laeiv+Lt/n4dwv/lV9f
ogLILU0w
=L4cH
-----END PGP SIGNATURE-----

M
M
Maxime Devos wrote on 5 Jul 2021 17:47
Re: [bug#49419] [PATCH 1/4] home-services: Add most essential home services
9ee31c62aef0a42b15b48ece2c1d0fe765fdcc83.camel@telenet.be
Hi,

Andrew Tropin schreef op ma 05-07-2021 om 18:37 [+0300]:
Toggle quote (13 lines)
> + (if (file-exists? (he-init-file new-home))
> + (let* ((port ((@@ (ice-9 popen) open-input-pipe)
> + (format #f "source ~a && env"
> + (he-init-file new-home))))
> + (result ((@@ (ice-9 rdelim) read-delimited) "" port))
> + (vars (map (lambda (x)
> + (let ((si (string-index x #\=)))
> + (cons (string-take x si)
> + (string-drop x (1+ si)))))
> + ((@@ (srfi srfi-1) remove)
> + string-null?
> + (string-split result #\newline)))))

Why are you using @@ here? 'open-input-pipe', 'read-delimited' and 'remove'
are exported variables, so you can just use @ instead of the magic evil @@
operator.

From the guile manual:

-- syntax: @ module-name binding-name
Refer to the binding named BINDING-NAME in module MODULE-NAME. The
binding must have been exported by the module.

-- syntax: @@ module-name binding-name
Refer to the binding named BINDING-NAME in module MODULE-NAME. The
binding must not have been exported by the module. This syntax is
only intended for debugging purposes or as a last resort. *Note
Declarative Modules::, for some limitations on the use of ‘@@’.

Greetings,
Maxime.
-----BEGIN PGP SIGNATURE-----

iI0EABYKADUWIQTB8z7iDFKP233XAR9J4+4iGRcl7gUCYOMpjRccbWF4aW1lZGV2
b3NAdGVsZW5ldC5iZQAKCRBJ4+4iGRcl7gQOAPsFGFgW0cLP4W/e7uwZbt03DBOA
fxqtbIow4lZzBZnzuwEAudd2ldnndceENw+2HPKFVb7MVWUMg97zzFX4fXgADAc=
=CSiP
-----END PGP SIGNATURE-----


A
A
Andrew Tropin wrote on 5 Jul 2021 18:19
87mtr0hgx0.fsf@trop.in
Maxime Devos <maximedevos@telenet.be> writes:

Toggle quote (20 lines)
> Hi,
>
> Andrew Tropin schreef op ma 05-07-2021 om 18:37 [+0300]:
>> + (if (file-exists? (he-init-file new-home))
>> + (let* ((port ((@@ (ice-9 popen) open-input-pipe)
>> + (format #f "source ~a && env"
>> + (he-init-file new-home))))
>> + (result ((@@ (ice-9 rdelim) read-delimited) "" port))
>> + (vars (map (lambda (x)
>> + (let ((si (string-index x #\=)))
>> + (cons (string-take x si)
>> + (string-drop x (1+ si)))))
>> + ((@@ (srfi srfi-1) remove)
>> + string-null?
>> + (string-split result #\newline)))))
>
> Why are you using @@ here? 'open-input-pipe', 'read-delimited' and 'remove'
> are exported variables, so you can just use @ instead of the magic evil @@
> operator.

Because of a bad habbit, I needed it once and after that started to use
it uncoditionally. It should be @, thanks for pointing!

BTW, how to add changes to the patches? Do I need to resend a
particular patch with required updates or have to wait other reviews and
send a v2 patch series?
-----BEGIN PGP SIGNATURE-----

iQJDBAEBCgAtFiEEKEGaxlA4dEDH6S/6IgjSCVjB3rAFAmDjMRsPHGFuZHJld0B0
cm9wLmluAAoJECII0glYwd6wZT4QAJEov57pZfK3lU4JxmmbjrSO8VcmU9d2OmDw
8u4ZFeYOgC+U+QJjGEzXnZNW4QuxZGfOwtC9oxCyAqMXFwMc+hKUL28BG1fBRDH9
kl6Gpn5NzARZt6Ou1xfBYXyqO+iTYzjYo8mKfdKDDI9PAi2dVSeAvkAVZ69QCm/f
K5AuJnZGpfRceGs60p85i88T8IsSWXC72RnJ9osYYCHosvboNCv5YE5UxLbXH/8T
PYMI6tqZvRg6UNtpPUiwLNocLDDghM62Zyb2Q+5iDGcX8ZOkiYLKqq7CgLZBK0kY
Khv4wjJHjFIr7g3/1dFrWQqXzW8uJsGZZY5OvG5cPrcdX3hjFnf4WWPRYxwi+/JK
afyejohUi45464OO8lo0hy+eouE4PcDSwFu4vJhLZORr49zCzIueMXhcBLk/M7++
3CGd4ow30StzUnm/YBxyhh+dku9YXJHXsJNxQV5Wi8q5Nsuk13B1MGLoek054FJt
bD5otRkNqW1gBQLRhles4znt05fLYHKlMESRXRSwUtiTEeO7KEnLyRyRIE6ewk++
l/et9h/fnyHECpvk+imvn2PmVwKyhWtSKyE0/WBxchVCrUnZJwB5bGQJ11XuWM8Y
P5MjEXvboCVwwI5cV6wTInCVRbTqpbQgHxUx3F7itoIqwlLNhky3cbUDLkqg+IS4
Och3Ic1x
=dxhj
-----END PGP SIGNATURE-----

M
M
Maxime Devos wrote on 5 Jul 2021 21:19
6b465d9991c15eb9fc9f8def6aa3293a872352c1.camel@telenet.be
Andrew Tropin schreef op ma 05-07-2021 om 19:19 [+0300]:
Toggle quote (8 lines)
> Maxime Devos <maximedevos@telenet.be> writes:
>
> [...]
>
> BTW, how to add changes to the patches? Do I need to resend a
> particular patch with required updates or have to wait other reviews and
> send a v2 patch series?

I would do a combination of those: reply to the mail of the reviewer with a
revised patch attached. When you have received a ‘sufficient’ number of reviews
from others on the other patches in the series as well, send a v2.

Some benefits of this method:

(1) it should be clear which patches should be applied,
as the number of 'revised patches' without sending a new series
version is limited.

This is also the case if you send a new version after each little change,
but can easily become _not_ the cas if you always respond with a revised
patch without starting a new series version.

(2) you don't clutter the mailboxes with new version after new version
after each little change.

This is particularily important if you have large patch series (say 13 or
more patches), which doesn't seem to apply here.

WDYT?

Greetings,
Maxime.
-----BEGIN PGP SIGNATURE-----

iI0EABYKADUWIQTB8z7iDFKP233XAR9J4+4iGRcl7gUCYONbLRccbWF4aW1lZGV2
b3NAdGVsZW5ldC5iZQAKCRBJ4+4iGRcl7rqyAQCmkk6yS83y0pMlfQLcCbtOBXhB
ftqfGvZNgXttITIrmwD+OUdsc1bXq9uZ5vjhSY45kTNzNBtwhiYB5tQMTCMzDA4=
=Y7+e
-----END PGP SIGNATURE-----


A
A
Andrew Tropin wrote on 6 Jul 2021 09:09
87im1nhq9t.fsf@trop.in
Maxime Devos <maximedevos@telenet.be> writes:

Toggle quote (31 lines)
> Andrew Tropin schreef op ma 05-07-2021 om 19:19 [+0300]:
>> Maxime Devos <maximedevos@telenet.be> writes:
>>
>> [...]
>>
>> BTW, how to add changes to the patches? Do I need to resend a
>> particular patch with required updates or have to wait other reviews and
>> send a v2 patch series?
>
> I would do a combination of those: reply to the mail of the reviewer with a
> revised patch attached. When you have received a ‘sufficient’ number of reviews
> from others on the other patches in the series as well, send a v2.
>
> Some benefits of this method:
>
> (1) it should be clear which patches should be applied,
> as the number of 'revised patches' without sending a new series
> version is limited.
>
> This is also the case if you send a new version after each little change,
> but can easily become _not_ the cas if you always respond with a revised
> patch without starting a new series version.
>
> (2) you don't clutter the mailboxes with new version after new version
> after each little change.
>
> This is particularily important if you have large patch series (say 13 or
> more patches), which doesn't seem to apply here.
>
> WDYT?

I came up with one more approach: I can send a patch, which address the
issues reviewer mentioned and after getting more reviews from other
peers I can rebase my original commits and incorparate all the
later patches to them and prepare v2 series.

[PATCH 0/4]
[PATCH 1/4]
fix1 to address issue from subthread1 reported by r1
fix2 to address issue from subthread2 reported by r2
fix3 to address issue from subthread2 came during discussion with r1 and r2
[PATCH 2/4]
...

Such approach makes it clear how the comments were addressed, because
now you see a diff, not the whole new patch. On the other hand it can
be a little harder to reply, because you don't have the latest version
of the patch, but have only original patch and updates to it, so you
need to pick, which one you want to reply to.

I will try this one, to find its weak points. It's better to practice
on this small patch series, rather something huge)

Another question: Is it better to inline or attach patches?
-----BEGIN PGP SIGNATURE-----

iQJDBAEBCgAtFiEEKEGaxlA4dEDH6S/6IgjSCVjB3rAFAmDkAb4PHGFuZHJld0B0
cm9wLmluAAoJECII0glYwd6wjAMP/3HfCFMBPLkyY3E8LrGZ5y9Y5x4ezbdnvC+I
GeVjML5vMzVQ1RI/eIvtzfF2pCxN1ID+41gFvRv+fJ6JWceu0uwMWhOK9mktkKBG
V5+gB6aX1CuCoVh4ekIt1DcT6TeQlUvE06y6196xspCeCI0OpnH2FJNfvU3Y+reC
1wK6oL5ch9kKjyF+09U/U8DRWyEc1GSrETM7DQ6i5dYiy7l8KVNgbj7THRHI36as
ia5Fw8axZ1uoXPFDqmnbuHuCuGP5ch98e+0K2jJL7+1cysPjtbkzzeXAHKNsVo/l
AH5DhN38zy/Jnsyv55Kdkb6MF9BR+Dehm8aRJoFrAoFzBTgJw7zGRSB4OvwLLdSg
+n7hy8+EGmX8XU4psLS4r1isXTScCiela1rNq/P6t3xmOlP8xNkZ2t/VAg9qeqca
c3pkXtOHjTYlp5eyo1/jPr6Uto2uJL6CkPAJZyyeX8VT7wRvduYLratJ3c33xYnH
tjLVOqdoJwOEPcEu0rnt05y/VbSNsUSz7P/RO9YUDqBI/w913EgN8hz3uR5f8L2/
fZpUfdnUYlcQ1LH2Vbj8UIEIf7c65To+14dQUunoN3z8nwR2pPfO5SCbmjZBFzii
/2IG36ozJ1XL6x9lu79hDkkXJkVQkW50kGuDsM89j86AASgThs4AtWusSma2nqrm
oBqdTYd4
=ePjX
-----END PGP SIGNATURE-----

A
A
Andrew Tropin wrote on 6 Jul 2021 09:23
878s2jsy70.fsf@trop.in
Maxime Devos <maximedevos@telenet.be> writes:

Toggle quote (20 lines)
> Hi,
>
> Andrew Tropin schreef op ma 05-07-2021 om 18:37 [+0300]:
>> + (if (file-exists? (he-init-file new-home))
>> + (let* ((port ((@@ (ice-9 popen) open-input-pipe)
>> + (format #f "source ~a && env"
>> + (he-init-file new-home))))
>> + (result ((@@ (ice-9 rdelim) read-delimited) "" port))
>> + (vars (map (lambda (x)
>> + (let ((si (string-index x #\=)))
>> + (cons (string-take x si)
>> + (string-drop x (1+ si)))))
>> + ((@@ (srfi srfi-1) remove)
>> + string-null?
>> + (string-split result #\newline)))))
>
> Why are you using @@ here? 'open-input-pipe', 'read-delimited' and 'remove'
> are exported variables, so you can just use @ instead of the magic evil @@
> operator.

Addressed the issue with the following patch.
From 27998096bf5b4ccd1c66ef71c1280faf0e11be72 Mon Sep 17 00:00:00 2001
From: Andrew Tropin <andrew@trop.in>
Date: Mon, 5 Jul 2021 19:22:40 +0300
Subject: [PATCH] (toberebased) home-services: Use @ instead of @@

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

Toggle diff (34 lines)
diff --git a/gnu/home-services.scm b/gnu/home-services.scm
index a06cd72459..78e5603edf 100644
--- a/gnu/home-services.scm
+++ b/gnu/home-services.scm
@@ -280,15 +280,15 @@ extended with one gexp.")))
(readlink he-path)
#f))))
(if (file-exists? (he-init-file new-home))
- (let* ((port ((@@ (ice-9 popen) open-input-pipe)
+ (let* ((port ((@ (ice-9 popen) open-input-pipe)
(format #f "source ~a && env"
(he-init-file new-home))))
- (result ((@@ (ice-9 rdelim) read-delimited) "" port))
+ (result ((@ (ice-9 rdelim) read-delimited) "" port))
(vars (map (lambda (x)
(let ((si (string-index x #\=)))
(cons (string-take x si)
(string-drop x (1+ si)))))
- ((@@ (srfi srfi-1) remove)
+ ((@ (srfi srfi-1) remove)
string-null?
(string-split result #\newline)))))
(close-port port)
@@ -340,7 +340,7 @@ with one gexp, but many times, and all gexps must be idempotent.")))
(define (equal-regulars? file1 file2)
"Check if FILE1 and FILE2 are bit for bit identical."
(let* ((cmp-binary #$(file-append
- (@@ (gnu packages base) diffutils) "/bin/cmp"))
+ (@ (gnu packages base) diffutils) "/bin/cmp"))
(status (system* cmp-binary file1 file2)))
(= status 0)))
--
2.32.0
I can use different methods to attach/prepare/send patches and reply to
the reviews, sorry for any inconveniences in advance) I'll stick to some
approach, once I'll practice a few of them.
-----BEGIN PGP SIGNATURE-----

iQJDBAEBCgAtFiEEKEGaxlA4dEDH6S/6IgjSCVjB3rAFAmDkBOMPHGFuZHJld0B0
cm9wLmluAAoJECII0glYwd6wgsAP/2YH58b0q9Rwo1pA5CpCUrbFL5YdMvnt+Xxg
KMssxCwcFWAdXj8sDGULjlU/QzyErBuFaCscUJN0pQNL1Ku3/+9oDVyAKNei94UN
YMY5fX3Fa54VyU2IMItSN7n+fQM0BqEX9h0qplB+4V/NdIy5LedDz7N4WtNMY9B3
DH+co6rkaWWvzUnrUQigHSVzKLmqs4WWo+joa04RVumdmqiGCHAteNSS9dzaq28I
PKVFBj5uW6e9BCWaj5rFYYJJ901NbYQ1LrN0OaIemDfxg1fOB1vZigbQdPMJHLlc
Qy3rvXGG1WewT+fN5x+QUx2TpPIzmZvOh/UBjkGbJvmrxlSotMG+Ewyq1422VXGa
zAoK8H+Pbi5VycffCLp4suKq/1m6TpRM6TFYOc+Toz2tRKKwzgVTq1Ry9ygwsYTz
a8Ow/Apk+wS97iTztjrET0119AQG3yHAp4lhXctfHN3g18mw9wekebJnbGjdGi8E
in/S3bhenElchbIHoujOOr5SjYdUX1H7EJZbaWizsFJLJJn9wl/AHgazxzFYRzfA
pv6bZzFigWPeD+9Io9wKpLu69cp0i+kmqNWDVUNspyrGrUZJueXLzjnLpiOmkK/W
xtMhPAfzw3UKecsq7fSl+O7vgS0opWsFHSB/I6hARxCWZHpe5koy0DqOB75GfbrJ
YKB45Xfx
=5gVZ
-----END PGP SIGNATURE-----

M
M
Maxime Devos wrote on 6 Jul 2021 10:26
886f64b82885530b655dbc619255a1a86eb15f8a.camel@telenet.be
Andrew Tropin schreef op di 06-07-2021 om 10:09 [+0300]:
Toggle quote (2 lines)
> Another question: Is it better to inline or attach patches?

FWIW, I can read both just fine in my e-mail application (evolution).
When it's inline, I can read the patch directly but also have
an option to save it somewhere. When it is attached, there is some
button for ‘expanding’ the attachement so I can read it. Both
work for me. I don't know about other mail applications.

Greetings,
Maxime.
-----BEGIN PGP SIGNATURE-----

iI0EABYKADUWIQTB8z7iDFKP233XAR9J4+4iGRcl7gUCYOQTtxccbWF4aW1lZGV2
b3NAdGVsZW5ldC5iZQAKCRBJ4+4iGRcl7jwLAP0b/7TI/JGpTswqazHP6L/QRTBi
QuRtl3l7ZqfFsGzDtQEA5/z56HnhMkpP648HcjzCgjrGU+uj+vJ3+GktqMPHQAs=
=j9HV
-----END PGP SIGNATURE-----


A
A
Andrew Tropin wrote on 13 Jul 2021 18:17
[PATCH v2 0/4] Essential home services
(address . guix-patches@gnu.org)
87bl76m6b7.fsf@trop.in
Changes since v1: Use @ instead of @@

Andrew Tropin (4):
home-services: Add most essential home services
home-services: Add home-run-on-change-service-type
home-services: Add home-provenance-service-type
home-services: Add fold-home-service-types function

gnu/home-services.scm | 472 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 472 insertions(+)
create mode 100644 gnu/home-services.scm

--
2.32.0
A
A
Andrew Tropin wrote on 13 Jul 2021 20:26
Merging accidentially created tickets
(address . control@debbugs.gnu.org)
87pmvmkr2k.fsf@trop.in
merge 49419 49546 49547 49548 49549
A
A
Andrew Tropin wrote on 19 Jul 2021 10:04
[PATCH v3 0/4] Essential home services
(address . 49419@debbugs.gnu.org)
87v956g1g5.fsf@trop.in
Diff with v2: Prevents unecessary calls to system*

Please, when review finished, apply against guix-home-wip branch.

Andrew Tropin (4):
home-services: Add most essential home services
home-services: Add home-run-on-change-service-type
home-services: Add home-provenance-service-type
home-services: Add fold-home-service-types function

gnu/home-services.scm | 477 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 477 insertions(+)
create mode 100644 gnu/home-services.scm

--
2.32.0
-----BEGIN PGP SIGNATURE-----

iQJDBAEBCgAtFiEEKEGaxlA4dEDH6S/6IgjSCVjB3rAFAmD1NaoPHGFuZHJld0B0
cm9wLmluAAoJECII0glYwd6wwj8P/jeXT/IFM9lgtSkUcbFs+hEsgmTiwwolgNZq
5Uw8+r8gu+xBA6O3emVaDueU4EqQSpskgrYq7OQg0bu4nULvvDBMCC00pDpN+8zF
X9JD28MBfN7s+bWcu3PgXYFuRBF/hr6S1Vq/HBUfdZUNWi6CUee/XvXWwsTY4Ob7
PBuD+tD2MMe8qNmHI/+wLDnKSCQTZK5j0oCNZtgPik8zjOx82FqEW5ahCrjjkWgC
USe3RWTFLoNvjwAFP7lJS6EQvg0T3RL1dEYxul7qFXjyS+TMr2yW/vnBB9GpY0fC
akD2g9dUoUB/HXKQpZVJP5HZzGfWuCMfNh2ja4YAdM9OkGYNAxWBRikdsOsyOuN7
syZLQRdOdWZol4isLYwWUfoeNu2EcYuw0XdmoUMM6jKwBqx/ybd8hNrHX7iHz7qu
lYPyOJ3gLC82UC+7XiQZE5vZnw0DbOLvckd9LeeDiSQKwHWBb88ye4y7r9FlnI+S
aU2Vd7SJ7Qdg4GSYmIA2Vz+G2CiUV3TM3vi0NYVziMSQIIvgLtkhA05gE44uUIm/
mlM94rKKoEeBni4DaHK1e+htJLRfwiMLJL4ODEG1T61NZVHnB+TExrHd6KYh96Eg
kUL7DStwYJOR1qvFLu7uqLz9cQpCqNwtURBsWJJ/DmFhEMuKxqxNRfmJABbEzxjo
IBucrAH9
=REso
-----END PGP SIGNATURE-----

A
A
Andrew Tropin wrote on 5 Jul 2021 17:37
[PATCH v3 1/4] home-services: Add most essential home services
(address . 49419@debbugs.gnu.org)
87tukqg1am.fsf@trop.in
home-service-type is a root of home services DAG.

home-profile-service-type is almost the same as profile-service-type, at least
for now.

home-environment-variables-service-type generates a @file{setup-environment}
shell script, which is expected to be sourced by login shell or other program,
which starts early and spawns all other processes. Home services for shells
automatically add code for sourcing this file, if person do not use those home
services they have to source this script manually in their's shell *profile
file (details described in the manual).

home-files-service-type is similar to etc-service-type, but doesn't extend
home-activation, because deploy mechanism for config files is pluggable and
can be different for different home environments: The default one is called
symlink-manager (will be introudced in a separate patch series), which creates
links for various dotfiles (like $XDG_CONFIG_HOME/$APP/...) to store, but is
possible to implement alternative approaches like read-only home from Julien's
guix-home-manager.

home-run-on-first-login-service-type provides an @file{on-first-login} guile
script, which runs provided gexps once, when user makes first login. It can
be used to start user's Shepherd and maybe some other process. It relies on
assumption that /run/user/$UID will be created on login by some login
manager (elogind for example).

home-activation-service-type provides an @file{activate} guile script, which
do three main things:

- Sets environment variables to the values declared in
@file{setup-environment} shell script. It's necessary, because user can set
for example XDG_CONFIG_HOME and it should be respected by activation gexp of
symlink-manager.

- Sets GUIX_NEW_HOME and possibly GUIX_OLD_HOME vars to paths in the store.
Later those variables can be used by activation gexps, for example by
symlink-manager or run-on-change services.

- Run all activation gexps provided by other home services.
---
gnu/home-services.scm | 328 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 328 insertions(+)
create mode 100644 gnu/home-services.scm

Toggle diff (336 lines)
diff --git a/gnu/home-services.scm b/gnu/home-services.scm
new file mode 100644
index 0000000000..a89a061a81
--- /dev/null
+++ b/gnu/home-services.scm
@@ -0,0 +1,328 @@
+;;; 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 (gnu home-services)
+ #:use-module (gnu services)
+ #:use-module (guix channels)
+ #:use-module (guix monads)
+ #:use-module (guix store)
+ #:use-module (guix gexp)
+ #:use-module (guix profiles)
+ #:use-module (guix sets)
+ #:use-module (guix ui)
+ #:use-module (guix discovery)
+ #:use-module (guix diagnostics)
+
+ #:use-module (srfi srfi-1)
+ #:use-module (ice-9 match)
+
+ #:export (home-service-type
+ home-profile-service-type
+ home-environment-variables-service-type
+ home-files-service-type
+ home-run-on-first-login-service-type
+ home-activation-service-type)
+
+ #:re-export (service
+ service-type
+ service-extension))
+
+;;; Comment:
+;;;
+;;; This module is similar to (gnu system services) module, but
+;;; provides Home Services, which are supposed to be used for building
+;;; home-environment.
+;;;
+;;; Home Services use the same extension as System Services. Consult
+;;; (gnu system services) module or manual for more information.
+;;;
+;;; Code:
+
+
+(define (home-derivation entries mextensions)
+ "Return as a monadic value the derivation of the 'home'
+directory containing the given entries."
+ (mlet %store-monad ((extensions (mapm/accumulate-builds identity
+ mextensions)))
+ (lower-object
+ (file-union "home" (append entries (concatenate extensions))))))
+
+(define home-service-type
+ ;; This is the ultimate service type, the root of the home service
+ ;; DAG. The service of this type is extended by monadic name/item
+ ;; pairs. These items end up in the "home-environment directory" as
+ ;; returned by 'home-environment-derivation'.
+ (service-type (name 'home)
+ (extensions '())
+ (compose identity)
+ (extend home-derivation)
+ (default-value '())
+ (description
+ "Build the home environment top-level directory,
+which in turn refers to everything the home environment needs: its
+packages, configuration files, activation script, and so on.")))
+
+(define (packages->profile-entry packages)
+ "Return a system entry for the profile containing PACKAGES."
+ ;; XXX: 'mlet' is needed here for one reason: to get the proper
+ ;; '%current-target' and '%current-target-system' bindings when
+ ;; 'packages->manifest' is called, and thus when the 'package-inputs'
+ ;; etc. procedures are called on PACKAGES. That way, conditionals in those
+ ;; inputs see the "correct" value of these two parameters. See
+ ;; <https://issues.guix.gnu.org/44952>.
+ (mlet %store-monad ((_ (current-target-system)))
+ (return `(("profile" ,(profile
+ (content (packages->manifest
+ (map identity
+ ;;(options->transformation transformations)
+ (delete-duplicates packages eq?))))))))))
+
+;; MAYBE: Add a list of transformations for packages. It's better to
+;; place it in home-profile-service-type to affect all profile
+;; packages and prevent conflicts, when other packages relies on
+;; non-transformed version of package.
+(define home-profile-service-type
+ (service-type (name 'home-profile)
+ (extensions
+ (list (service-extension home-service-type
+ packages->profile-entry)))
+ (compose concatenate)
+ (extend append)
+ (description
+ "This is the @dfn{home profile} and can be found in
+@file{~/.guix-home/profile}. It contains packages and
+configuration files that the user has declared in their
+@code{home-environment} record.")))
+
+(define (environment-variables->setup-environment-script vars)
+ "Return a file that can be sourced by a POSIX compliant shell which
+initializes the environment. The file will source the home
+environment profile, set some default environment variables, and set
+environment variables provided in @code{vars}. @code{vars} is a list
+of pairs (@code{(key . value)}), @code{key} is a string and
+@code{value} is a string or gexp.
+
+If value is @code{#f} variable will be omitted.
+If value is @code{#t} variable will be just exported.
+For any other, value variable will be set to the @code{value} and
+exported."
+ (define (warn-about-duplicate-defenitions)
+ (fold
+ (lambda (x acc)
+ (when (equal? (car x) (car acc))
+ (warning
+ (G_ "duplicate definition for `~a' environment variable ~%") (car x)))
+ x)
+ (cons "" "")
+ (sort vars (lambda (a b)
+ (string<? (car a) (car b))))))
+
+ (warn-about-duplicate-defenitions)
+ (with-monad
+ %store-monad
+ (return
+ `(("setup-environment"
+ ;; TODO: It's necessary to source ~/.guix-profile too
+ ;; on foreign distros
+ ,(apply mixed-text-file "setup-environment"
+ "\
+HOME_ENVIRONMENT=$HOME/.guix-home
+GUIX_PROFILE=\"$HOME_ENVIRONMENT/profile\"
+PROFILE_FILE=\"$HOME_ENVIRONMENT/profile/etc/profile\"
+[ -f $PROFILE_FILE ] && . $PROFILE_FILE
+
+case $XDG_DATA_DIRS in
+ *$HOME_ENVIRONMENT/profile/share*) ;;
+ *) export XDG_DATA_DIRS=$HOME_ENVIRONMENT/profile/share:$XDG_DATA_DIRS ;;
+esac
+case $MANPATH in
+ *$HOME_ENVIRONMENT/profile/share/man*) ;;
+ *) export MANPATH=$HOME_ENVIRONMENT/profile/share/man:$MANPATH
+esac
+case $INFOPATH in
+ *$HOME_ENVIRONMENT/profile/share/info*) ;;
+ *) export INFOPATH=$HOME_ENVIRONMENT/profile/share/info:$INFOPATH ;;
+esac
+case $XDG_CONFIG_DIRS in
+ *$HOME_ENVIRONMENT/profile/etc/xdg*) ;;
+ *) export XDG_CONFIG_DIRS=$HOME_ENVIRONMENT/profile/etc/xdg:$XDG_CONFIG_DIRS ;;
+esac
+case $XCURSOR_PATH in
+ *$HOME_ENVIRONMENT/profile/share/icons*) ;;
+ *) export XCURSOR_PATH=$HOME_ENVIRONMENT/profile/share/icons:$XCURSOR_PATH ;;
+esac
+
+"
+
+ (append-map
+ (match-lambda
+ ((key . #f)
+ '())
+ ((key . #t)
+ (list "export " key "\n"))
+ ((key . value)
+ (list "export " key "=" value "\n")))
+ vars)))))))
+
+(define home-environment-variables-service-type
+ (service-type (name 'home-environment-variables)
+ (extensions
+ (list (service-extension
+ home-service-type
+ environment-variables->setup-environment-script)))
+ (compose concatenate)
+ (extend append)
+ (default-value '())
+ (description "Set the environment variables.")))
+
+(define (files->files-directory files)
+ "Return a @code{files} directory that contains FILES."
+ (define (assert-no-duplicates files)
+ (let loop ((files files)
+ (seen (set)))
+ (match files
+ (() #t)
+ (((file _) rest ...)
+ (when (set-contains? seen file)
+ (raise (formatted-message (G_ "duplicate '~a' entry for files/")
+ file)))
+ (loop rest (set-insert file seen))))))
+
+ ;; Detect duplicates early instead of letting them through, eventually
+ ;; leading to a build failure of "files.drv".
+ (assert-no-duplicates files)
+
+ (file-union "files" files))
+
+(define (files-entry files)
+ "Return an entry for the @file{~/.guix-home/files}
+directory containing FILES."
+ (with-monad %store-monad
+ (return `(("files" ,(files->files-directory files))))))
+
+(define home-files-service-type
+ (service-type (name 'home-files)
+ (extensions
+ (list (service-extension home-service-type
+ files-entry)))
+ (compose concatenate)
+ (extend append)
+ (default-value '())
+ (description "Configuration files for programs that
+will be put in @file{~/.guix-home/files}.")))
+
+(define (compute-on-first-login-script _ gexps)
+ (gexp->script
+ "on-first-login"
+ #~(let* ((xdg-runtime-dir (or (getenv "XDG_RUNTIME_DIR")
+ (format #f "/run/user/~a" (getuid))))
+ (flag-file-path (string-append
+ xdg-runtime-dir "/on-first-login-executed"))
+ (touch (lambda (file-name)
+ (call-with-output-file file-name (const #t)))))
+ ;; XDG_RUNTIME_DIR dissapears on logout, that means such trick
+ ;; allows to launch on-first-login script on first login only
+ ;; after complete logout/reboot.
+ (when (not (file-exists? flag-file-path))
+ (begin #$@gexps (touch flag-file-path))))))
+
+(define (on-first-login-script-entry m-on-first-login)
+ "Return, as a monadic value, an entry for the on-first-login script
+in the home environment directory."
+ (mlet %store-monad ((on-first-login m-on-first-login))
+ (return `(("on-first-login" ,on-first-login)))))
+
+(define home-run-on-first-login-service-type
+ (service-type (name 'home-run-on-first-login)
+ (extensions
+ (list (service-extension
+ home-service-type
+ on-first-login-script-entry)))
+ (compose identity)
+ (extend compute-on-first-login-script)
+ (default-value #f)
+ (description "Run gexps on first user login. Can be
+extended with one gexp.")))
+
+
+(define (compute-activation-script init-gexp gexps)
+ (gexp->script
+ "activate"
+ #~(let* ((he-init-file (lambda (he) (string-append he "/setup-environment")))
+ (he-path (string-append (getenv "HOME") "/.guix-home"))
+ (new-home-env (getenv "GUIX_NEW_HOME"))
+ (new-home (or new-home-env
+ ;; Path of the activation file if called interactively
+ (dirname (car (command-line)))))
+ (old-home-env (getenv "GUIX_OLD_HOME"))
+ (old-home (or old-home-env
+ (if (file-exists? (he-init-file he-path))
+ (readlink he-path)
+ #f))))
+ (if (file-exists? (he-init-file new-home))
+ (let* ((port ((@ (ice-9 popen) open-input-pipe)
+ (format #f "source ~a && env"
+ (he-init-file new-home))))
+ (result ((@ (ice-9 rdelim) read-delimited) "" port))
+ (vars (map (lambda (x)
+ (let ((si (string-index x #\=)))
+ (cons (string-take x si)
+ (string-drop x (1+ si)))))
+ ((@ (srfi srfi-1) remove)
+ string-null?
+ (string-split result #\newline)))))
+ (close-port port)
+ (map (lambda (x) (setenv (car x) (cdr x))) vars)
+
+ (setenv "GUIX_NEW_HOME" new-home)
+ (setenv "GUIX_OLD_HOME" old-home)
+
+ #$@gexps
+
+ ;; Do not unset env variable if it was set outside.
+ (unless new-home-env (setenv "GUIX_NEW_HOME" #f))
+ (unless old-home-env (setenv "GUIX_OLD_HOME" #f)))
+ (format #t "\
+Activation script was either called or loaded by file from this direcotry:
+~a
+It doesn't seem that home environment is somewhere around.
+Make sure that you call ./activate by symlink from -home store item.\n"
+ new-home)))))
+
+(define (activation-script-entry m-activation)
+ "Return, as a monadic value, an entry for the activation script
+in the home environment directory."
+ (mlet %store-monad ((activation m-activation))
+ (return `(("activate" ,activation)))))
+
+(define home-activation-service-type
+ (service-type (name 'home-activation)
+ (extensions
+ (list (service-extension
+ home-service-type
+ activation-script-entry)))
+ (compose identity)
+ (extend compute-activation-script)
+ (default-value #f)
+ (description "Run gexps to activate the current
+generation of home environment and update the state of the home
+directory. @command{activate} script automatically called during
+reconfiguration or generation switching. This service can be extended
+with one gexp, but many times, and all gexps must be idempotent.")))
+
--
2.32.0
-----BEGIN PGP SIGNATURE-----

iQJDBAEBCgAtFiEEKEGaxlA4dEDH6S/6IgjSCVjB3rAFAmD1NnEPHGFuZHJld0B0
cm9wLmluAAoJECII0glYwd6wKj0P/1yJqD1Co76x/igTqNPHhMpJLsQKUHjm3CyD
DsxZwnO+UuMA3by1lXaBTAyic66yHmnPgE7IPz4pozwAE2Xva8ABBqdPVaexMJzP
0/tQ/gCo3/QNhU1buCzh8NGVkXXiPhwl0m1mf0OGCRGokrR3igYOaFOpmhHxFqhk
y6SBOu4/dtiIgtr2RpmXdqEQXz+PrPjDm45R2ECAKiPrMmxJ7gxEa9wg8j1f5MAV
2ZA6iibuOEszlxsmBS4BMCRy3bqxrX4PH5zGiUJpnTlE8adbYYszl8ZsWfv0uKeA
EJ3jLxr5djLvKwWkNEHPsjP9LEoAdW5pkcz/5MYVu8vws7ipKuHJlG2BdNtjHKFz
jbgQbPKkwJm9+W81rIUoOCUloe6rcfWYIE6UUH5xiMtd7xRv5xqyF60YUfLOgKKi
KR5D6a+pFpZdErdfF3wLYTbdGkGEw+FdC7x8OWUmpXWWBoyX4V44Tqd5o5eQ7c7l
OM2559idBWCNT7BV+ycYrpksV3YTUlK8qMk5vxO8MRKfhRGAOYN9sYwpziksjk0J
ahaMNpcgaXlSbAHOlwUmdT6LuHCZsdm8r1cmN99ztQpnOlLPxB8/QXoTijNBb/ja
NIVghlpSaTt6YItOV8gT5gWf5kKDpuVUs4CnezV+fzigQJhKGweel79ZtBHOA4ud
LSK5fIIb
=5c5Y
-----END PGP SIGNATURE-----

A
A
Andrew Tropin wrote on 5 Jul 2021 17:39
[PATCH v3 2/4] home-services: Add home-run-on-change-service-type
(address . 49419@debbugs.gnu.org)
87sg0ag19m.fsf@trop.in
Service allows to trigger actions during activation if file or directory
specified by pattern is changed.
---
gnu/home-services.scm | 100 +++++++++++++++++++++++++++++++++++++++++-
1 file changed, 99 insertions(+), 1 deletion(-)

Toggle diff (117 lines)
diff --git a/gnu/home-services.scm b/gnu/home-services.scm
index a89a061a81..bcb6dd80df 100644
--- a/gnu/home-services.scm
+++ b/gnu/home-services.scm
@@ -37,7 +37,8 @@
home-environment-variables-service-type
home-files-service-type
home-run-on-first-login-service-type
- home-activation-service-type)
+ home-activation-service-type
+ home-run-on-change-service-type)
#:re-export (service
service-type
@@ -326,3 +327,100 @@ directory. @command{activate} script automatically called during
reconfiguration or generation switching. This service can be extended
with one gexp, but many times, and all gexps must be idempotent.")))
+
+;;;
+;;; On-change.
+;;;
+
+(define (compute-on-change-gexp eval-gexps? pattern-gexp-tuples)
+ #~(begin
+ (define (equal-regulars? file1 file2)
+ "Check if FILE1 and FILE2 are bit for bit identical."
+ (let* ((cmp-binary #$(file-append
+ (@ (gnu packages base) diffutils) "/bin/cmp"))
+ (stats1 (lstat file1))
+ (stats2 (lstat file2)))
+ (cond
+ ((= (stat:ino stats1) (stat:ino stats2)) #t)
+ ((not (= (stat:size stats1) (stat:size stats2))) #f)
+
+ (else (= (system* cmp-binary file1 file2) 0)))))
+
+ (define (equal-symlinks? symlink1 symlink2)
+ "Check if SYMLINK1 and SYMLINK2 are pointing to the same target."
+ (string=? (readlink symlink1) (readlink symlink2)))
+
+ (define (equal-directories? dir1 dir2)
+ "Check if DIR1 and DIR2 have the same content."
+ (define (ordinary-file file)
+ (not (or (string=? file ".")
+ (string=? file ".."))))
+ (let* ((files1 (scandir dir1 ordinary-file))
+ (files2 (scandir dir2 ordinary-file)))
+ (if (equal? files1 files2)
+ (map (lambda (file)
+ (equal-files?
+ (string-append dir1 "/" file)
+ (string-append dir2 "/" file)))
+ files1)
+ #f)))
+
+ (define (equal-files? file1 file2)
+ "Compares files, symlinks or directories of the same type."
+ (case (file-type file1)
+ ((directory) (equal-directories? file1 file2))
+ ((symlink) (equal-symlinks? file1 file2))
+ ((regular) (equal-regulars? file1 file2))
+ (else
+ (display "The file type is unsupported by on-change service.\n")
+ #f)))
+
+ (define (file-type file)
+ (stat:type (lstat file)))
+
+ (define (something-changed? file1 file2)
+ (cond
+ ((and (not (file-exists? file1))
+ (not (file-exists? file2))) #f)
+ ((or (not (file-exists? file1))
+ (not (file-exists? file2))) #t)
+
+ ((not (eq? (file-type file1) (file-type file2))) #t)
+
+ (else
+ (not (equal-files? file1 file2)))))
+
+ (define expressions-to-eval
+ (map
+ (lambda (x)
+ (let* ((file1 (string-append (getenv "GUIX_OLD_HOME") "/" (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))
+ (_ (format #t " done (~a)\n"
+ (if any-changes? "changed" "same"))))
+ (if any-changes? (cadr x) "")))
+ '#$pattern-gexp-tuples))
+
+ (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.\n"))))
+
+(define home-run-on-change-service-type
+ (service-type (name 'home-run-on-change)
+ (extensions
+ (list (service-extension
+ home-activation-service-type
+ identity)))
+ (compose concatenate)
+ (extend compute-on-change-gexp)
+ (default-value #t)
+ (description "\
+G-expressions to run if the specified files have changed since the
+last generation. The extension should be a list of lists where the
+first element is the pattern for file or directory that expected to be
+changed, and the second element is the G-expression to be evaluated.")))
--
2.32.0
-----BEGIN PGP SIGNATURE-----

iQJDBAEBCgAtFiEEKEGaxlA4dEDH6S/6IgjSCVjB3rAFAmD1NpUPHGFuZHJld0B0
cm9wLmluAAoJECII0glYwd6wl0QP/0TbNHav4kQ7KiQKF9M3HPWz3qNeLMO+SgBs
MGx/1kApFVTrph8Ua2u17IRKlvxggxzrj2wOjHgs5z0pauMx7s2sdKQ4ficHIEqv
wuTdo5xI0/eWkYY+fBVd3ErYtSUxv3uqZz5SgJUeq/rUtCul7u1EC0bTDn95aLwX
6NDcb9AwuWCdKUKF+VBODMvdsc4ve34oddlYbVFA7ct6SP8O7KclcUl/p69CHwND
UCzSOrq6D3Nt2pOqbwjLnmhWQr+nJFIoLqRlqf0sBxZBMX6YNk37QqEygVuzvfCZ
vuszh1yjfDggbgd0DeUqAiVI03KO9QgO1Xr1ZlmUOJsdhqy1xqdG8ifu4hoBc2Cb
bcLxj/7Ei6/u3p8+Ls95n9i/C3ir/gGXtyBcNBnYJoPEL7rOEJGstv4VMNF8cMR1
12PAzO5edQbLFaMNLGhKyOncQPDQshQJWaAr7oybXG7GoyJ3uPmWLBSJi+8lLAUi
jbmn8GIrY1x9KyFpVNznjkQ90FQpCAJQwCO0vKnPErhisA4FyKR7NA2d/1Z2djnX
sGQNU04j1JA8TkYNsW6o+WKXkaUqugZGBfc3460MGFBaqA0DNqvj5lisXpRb3R7T
xZIorW8/rojQGqNTQr4qogX5RTQo1I0FoUuHgLvDJ3BA+EAA33zgwlsXzkntXSC8
nU9CQUD/
=J3I4
-----END PGP SIGNATURE-----

A
A
Andrew Tropin wrote on 5 Jul 2021 17:41
[PATCH v3 3/4] home-services: Add home-provenance-service-type
(address . 49419@debbugs.gnu.org)
87r1fug18l.fsf@trop.in
* gnu/home-services.scm (home-provenance-service-type, sexp->home-provenance,
home-provenance): New variables.
---
gnu/home-services.scm | 27 ++++++++++++++++++++++++++-
1 file changed, 26 insertions(+), 1 deletion(-)

Toggle diff (44 lines)
diff --git a/gnu/home-services.scm b/gnu/home-services.scm
index bcb6dd80df..8aa9adeaaf 100644
--- a/gnu/home-services.scm
+++ b/gnu/home-services.scm
@@ -38,7 +38,10 @@
home-files-service-type
home-run-on-first-login-service-type
home-activation-service-type
- home-run-on-change-service-type)
+ home-run-on-change-service-type
+ home-provenance-service-type
+
+ fold-home-service-types)
#:re-export (service
service-type
@@ -424,3 +427,25 @@ G-expressions to run if the specified files have changed since the
last generation. The extension should be a list of lists where the
first element is the pattern for file or directory that expected to be
changed, and the second element is the G-expression to be evaluated.")))
+
+
+;;;
+;;; Provenance tracking.
+;;;
+
+(define home-provenance-service-type
+ (service-type
+ (name 'home-provenance)
+ (extensions
+ (list (service-extension
+ home-service-type
+ (service-extension-compute
+ (first (service-type-extensions provenance-service-type))))))
+ (default-value #f) ;the HE config file
+ (description "\
+Store provenance information about the home environment in the home
+environment itself: the channels used when building the home
+environment, and its configuration file, when available.")))
+
+(define sexp->home-provenance sexp->system-provenance)
+(define home-provenance system-provenance)
--
2.32.0
-----BEGIN PGP SIGNATURE-----

iQJDBAEBCgAtFiEEKEGaxlA4dEDH6S/6IgjSCVjB3rAFAmD1NroPHGFuZHJld0B0
cm9wLmluAAoJECII0glYwd6wlcUP/jiO4UrQ/hKe0FdL7bJZ7m27MvvA1Kqudb6c
LxDWsYDywZla8t9BSNhNZvH0iwKCnKuOr0mP4+aO1nGZ1qXSB1oQ+pLBw/kvXVAi
DSxYFmo3YCZIvIxJLuewz7OlyoRsA7AHFMsgZIyATTbQKo2TggjM8IZwtEFRWqLP
LI30Y1zutLyLrHP6t/1BGozam/wq7db03/UuBtngINP44EUhKc/yezDVUBcotila
hKHqxJGHD6qniDZf77FZXiytjLRqlgQaEZQ8vMmwX6N5geDIfcnZNUoE+aZ4YQCS
XDlW3Nq+J0MxMzqtu5maGF+LoQFJ0LDDao8ryw/qasUi0U0hrA0DGkKwDPlNCcer
LaxEL3KbzjuFUC6cISzNUUd/HOt0Fl+Ri2oBjHWTGs7QTUKecu5Yj9zW47beAtaG
pH9AQgUHu/rd95OrqOT+i+8AXRcaLAbXELAu1Lcgupdwmu/N6vHLV+f7W6CS7arx
XXBhqv9hwmUs4VoYr8JRQt7JdAKaHhnqCicaqKZHAX+bhwxzKcQqyydSIvYrBpP3
1qiiMBJt7S4mHIDBorIw34gS9CasQPgkiU3ItPuVHFDm8lljYdIQ8p9hV6tlRzZZ
M127UjSd8yhx/bSUMMF+WZMiYiJSo/Q4JSXkNigRYwakOvXFF5SnMcMw9QkjBZYy
L9cuLKsp
=bg7c
-----END PGP SIGNATURE-----

A
A
Andrew Tropin wrote on 5 Jul 2021 17:41
[PATCH v3 4/4] home-services: Add fold-home-service-types function
(address . 49419@debbugs.gnu.org)
87pmveg17l.fsf@trop.in
* gnu/home-services.scm (parent-directory, %guix-home-root-directory,
%service-type-path, all-home-service-modules, fold-home-service-types): New
variables.
---
gnu/home-services.scm | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)

Toggle diff (36 lines)
diff --git a/gnu/home-services.scm b/gnu/home-services.scm
index 8aa9adeaaf..9afb70f0a7 100644
--- a/gnu/home-services.scm
+++ b/gnu/home-services.scm
@@ -449,3 +449,29 @@ environment, and its configuration file, when available.")))
(define sexp->home-provenance sexp->system-provenance)
(define home-provenance system-provenance)
+
+
+;;;
+;;; Searching
+;;;
+
+(define (parent-directory directory)
+ "Get the parent directory of DIRECTORY"
+ (string-join (drop-right (string-split directory #\/) 1) "/"))
+
+(define %guix-home-root-directory
+ ;; Absolute file name of the module hierarchy.
+ (parent-directory (dirname (search-path %load-path "gnu/home-services.scm"))))
+
+(define %service-type-path
+ ;; Search path for service types.
+ (make-parameter `((,%guix-home-root-directory . "gnu/home-services"))))
+
+(define (all-home-service-modules)
+ "Return the default set of home-service modules."
+ (cons (resolve-interface '(gnu home-services))
+ (all-modules (%service-type-path)
+ #:warn warn-about-load-error)))
+
+(define* (fold-home-service-types proc seed)
+ (fold-service-types proc seed (all-home-service-modules)))
--
2.32.0
-----BEGIN PGP SIGNATURE-----

iQJDBAEBCgAtFiEEKEGaxlA4dEDH6S/6IgjSCVjB3rAFAmD1Nt4PHGFuZHJld0B0
cm9wLmluAAoJECII0glYwd6wAa8P/iV63UYsf+PUc8z+kUAjP3jvCCEvF3SGuuw7
7eZEMFXScQThWecZYlaUlBKWZEizgWpYHbE3TEdqR2dltARWmsWyxsjZ8VkfCa3b
2PfVeVQfE4qBMqgjCmiNYYWpE8iuSi0Fm2TADrpOwXxjJbTZTAUVwX5+yQa1eiN5
mGjBbr0BTvm/dY84XzPcGmKczRX2xJ9xhh8JBR55PaGq1cyI4EIOLN/64sfS2jBv
XwNHN1EBQJTGCPCcmqhbdU/x5Bsz+0p6FwJH+teZIhbjJhfQtaXfq7Cnr3Y5Rty5
ONigtsIMalKmZ0F94XDwlYoTTFpGdtTGK4kZQ4G2qVksWu28ERVIS/Xg5X/oLbpJ
XIxpvg0KrKldoPciD7Vlqwh4fBC9YFWBggKh/iFWckjYsshoVNLbeTgyBDkDWMDO
DOvyfY66LDXuUsLbaRVJ+eRqZlD/nWKWeYBVDLyLiXDtleDkny4Q7urd9sb4yf2C
SZ4osEcT3I7zqYvUEVpecZI6E8BqUSs8RtSTvEWw0IG/CDf0y70AwTBR7ze+8Y5e
R7J7Gs4Y8jDMK++Io885BCS++L+37oZwBxUo3quzxodbUn7im3w2CfZsReB3BxLc
bFZYiErIa8uYQYIoFTpHDLL2a6mZi9/SUCvf8ZWhZqd0wKtryfaW49aPQr6ulob2
zNpJD4Q4
=0zO+
-----END PGP SIGNATURE-----

L
L
Ludovic Courtès wrote on 21 Jul 2021 17:08
Re: bug#49419: [PATCH 0/4] Essential home services
(name . Andrew Tropin)(address . andrew@trop.in)(address . 49419@debbugs.gnu.org)
87im13g0vs.fsf_-_@gnu.org
Hi Andrew,

Andrew Tropin <andrew@trop.in> skribis:

Toggle quote (10 lines)
> Diff with v2: Prevents unecessary calls to system*
>
> Please, when review finished, apply against guix-home-wip branch.
>
> Andrew Tropin (4):
> home-services: Add most essential home services
> home-services: Add home-run-on-change-service-type
> home-services: Add home-provenance-service-type
> home-services: Add fold-home-service-types function

Thanks for sending this first patch series!

How would you like to proceed? Sending patches that add essential
services, and then (guix scripts home …) modules?

I agree we should apply it all in ‘wip-guix-home’ for now.

Some general comments:

• Please remove tabs from Scheme files.

• Please do not write documentation in commit logs. For example,
patch #1 explains the different service types, but to me, that’d
belong in a comment or (better yet) in a section of the manual. For
commit logs, we use ChangeLog style:


It’s OK if you don’t get the fine points right from the start,
committers can tweak it for you. :-)

• When there are tests or documentation, add them in the commit that
adds the corresponding functionality.

• Regarding module names: what about putting everything in the (gnu
home …) name space. For services, I wonder if we could simply use
(gnu services home), for the essential services, and other (gnu
services …) module, but that assumes some code can be shared between
System and Home. Thoughts?

I’ll look at the actual patches later, but I invite others to chime in
too. :-)

Thanks!

Ludo’.
A
A
Andrew Tropin wrote on 28 Jul 2021 07:35
(name . Ludovic Courtès)(address . ludo@gnu.org)(address . 49419@debbugs.gnu.org)
87lf5rj8zk.fsf@trop.in
Ludovic Courtès <ludo@gnu.org> writes:

Toggle quote (19 lines)
> Hi Andrew,
>
> Andrew Tropin <andrew@trop.in> skribis:
>
>> Diff with v2: Prevents unecessary calls to system*
>>
>> Please, when review finished, apply against guix-home-wip branch.
>>
>> Andrew Tropin (4):
>> home-services: Add most essential home services
>> home-services: Add home-run-on-change-service-type
>> home-services: Add home-provenance-service-type
>> home-services: Add fold-home-service-types function
>
> Thanks for sending this first patch series!
>
> How would you like to proceed? Sending patches that add essential
> services, and then (guix scripts home …) modules?

Yep.

Toggle quote (5 lines)
> I agree we should apply it all in ‘wip-guix-home’ for now.
>
> Some general comments:
>
> • Please remove tabs from Scheme files.
Toggle quote (10 lines)
> • Please do not write documentation in commit logs. For example,
> patch #1 explains the different service types, but to me, that’d
> belong in a comment or (better yet) in a section of the manual. For
> commit logs, we use ChangeLog style:
>
> https://guix.gnu.org/manual/en/html_node/Submitting-Patches.html
>
> It’s OK if you don’t get the fine points right from the start,
> committers can tweak it for you. :-)

True, I forgot to add ChangeLog style parts to first two patches. The
rest of commit message originally was just an explanation for reviewers
to provide a context, but yep it's already looks like a documentation)

Toggle quote (4 lines)
>
> • When there are tests or documentation, add them in the commit that
> adds the corresponding functionality.

Wanted to add documentation with a separate patch series to make patch
series to wip-guix-home be smaller and easier for review, but probably
you are right, I should add related documentation in the same series.

Toggle quote (6 lines)
> • Regarding module names: what about putting everything in the (gnu
> home …) name space. For services, I wonder if we could simply use
> (gnu services home), for the essential services, and other (gnu
> services …) module, but that assumes some code can be shared between
> System and Home. Thoughts?

There was a thread on rde-devel about moving home services to (gnu
services ...), in the second half of the first response I provided some
arguments against this change.

However, I can miss some niceties, so I still open for discussion if you
think that arguments from the thread isn't valid anymore or not valid at
all.

Toggle quote (3 lines)
> I’ll look at the actual patches later, but I invite others to chime in
> too. :-)

Cool, I'll wait for the review of the code and will prepare a new
version of patch series after that.

Thank you for the comments!
-----BEGIN PGP SIGNATURE-----

iQJDBAEBCgAtFiEEKEGaxlA4dEDH6S/6IgjSCVjB3rAFAmEA7L8PHGFuZHJld0B0
cm9wLmluAAoJECII0glYwd6wBtIP/3+dnU+LlveSU43SjRWkPBPNnRvf9E0NIZ2f
RJFTiknp4tswLeVbZAgURYuLUNtWgxWc4JTM5gK1n7U+/BAHZ2sKlrnQ9i6hQmAJ
DapGJti+taseiW52jvaUJMA/G7i05hSk96lrNgsX1ngMljwSUPX3kF8+t0U25uzd
rSVF8cfij1D39xOvrz1P3p6KQ/C26o0RlJNdBpQ1m691h2hCvSN69NYmvloXf7Yl
SJvJgM2byTso9Udp67G32nmvDBEdep7ZQsKoC+3LNCN+8OkkPkaJ+9WAjlx6v0d1
vGHxQMCyWneaaDEhmnm+xSaQ85rHlRVSnHUGaUt3/4DLZoaMBCWaVBi7fKGeZ2/x
QoV4suDPcSAa4RFyiet3tbKApFhc0yAMLKTxi/nxDP3F5uDBKmkm37XRWkDwXcpm
wjWOrw9EW2PSbxAPH/wgVCZYmaYlO7Ks+HCWuqCIPGbba2/aaxo61z0VyvBBe8og
pSAI7+O1e1ccKMYwSA2TMrsM6Foo2Ma9PYGvyFElsXWQS7Elkx/UIYYBbdS8iFsw
yKxluQbt0zgMmKfsu7F9f0NoyDJOjc6EKxBOHPDiDEnpLw8m2BM6+sp38zDNzDmz
dxDiqdOpRKuBH1t/0F7Ct1ogPMDRnKtxDSKt9JWLV8nAizrWWmQU0YZ6sudybzwC
zI5nwjze
=p5iR
-----END PGP SIGNATURE-----

A
A
Andrew Tropin wrote on 5 Aug 2021 07:41
[PATCH v4 0/4] Essential home services
(address . 49419@debbugs.gnu.org)
87tuk4mors.fsf@trop.in
Seems there is no additional comments about implementation, so I just
send cosmetical changes treating comments from previous reviews.

Changes since v3:
- Remove tabs.
- Move Home Services explanation from commit message to comment.
- Add missing ChangeLog-style commit body.

Andrew Tropin (4):
home-services: Add most essential home services
home-services: Add home-run-on-change-service-type
home-services: Add home-provenance-service-type
home-services: Add fold-home-service-types function

gnu/home-services.scm | 520 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 520 insertions(+)
create mode 100644 gnu/home-services.scm

--
2.32.0
-----BEGIN PGP SIGNATURE-----

iQJDBAEBCgAtFiEEKEGaxlA4dEDH6S/6IgjSCVjB3rAFAmELehgPHGFuZHJld0B0
cm9wLmluAAoJECII0glYwd6wze4P/RUwwZCDsUD7s9K91ZZw5TYB53DSselwYYnu
jcJi9PmHyrSI3ZwEmCuaQUJBvSubo6sdspucxCLVn8VXrXU0KbED5fm8AjSphwkH
OA96THL/UM2li3gnvXDPzoR+kG1qumRRmnUb/a4w42G8V01sjTeLXkbBudoKw6SR
t2VL5wxlOaYE1Vx3HhZl8SXgMv1V/C7gq7dGAhJl61j7BKfG743m0AVB6ImS1zE4
uqL9hool4X9yfGvf0NDreFff2swmGrDKIHbCAmGlfPfI1qc4UZu1jhY8JMtZebDr
KCKCy5SyQNP8Ue8jhzStvaOGWtoFPVtve6qziwzhUD78NePX+hgL41hYK7JNYav4
MZe0Sd83txWhwAKg0UEYQWCFlqNKNxDU02B6pQgxgFPZ7NjU5PKWsthj/eBFVacY
BmAUnpfVhP6itXH05mPU99J6QY9tThWC0DkS+Km4gJqi5sttE9bzmgJHdrrJoBsw
01EBjfC7dlGeVzWaecvjcpC1P0DoFL55mbJ/EhEgagc4793A6RT8JgfT34gVzZCE
QLwEj2OqnSxCw0LtBwzjwF2jokhsTX1u7ubSjHFd+47fd1O8IQRpdKXfDeqQ2USp
M7H+une9aYRGegOmQGkbABOgFJfy/0jTl6pAI/WkYm1U7bLJDILM+9QMpitxzQD7
rDxgfbxK
=W/mt
-----END PGP SIGNATURE-----

A
A
Andrew Tropin wrote on 5 Aug 2021 07:45
[PATCH v4 1/4] home-services: Add most essential home services
(address . 49419@debbugs.gnu.org)
87pmusmol9.fsf@trop.in
* gnu/home-services.scm (home-service-type, home-profile-service-type)
(home-environment-variables-service-type, home-files-service-type)
(home-run-on-first-login-service-type, home-activation-service-type): New
variables.
---
gnu/home-services.scm | 368 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 368 insertions(+)
create mode 100644 gnu/home-services.scm

Toggle diff (376 lines)
diff --git a/gnu/home-services.scm b/gnu/home-services.scm
new file mode 100644
index 0000000000..4a6458abec
--- /dev/null
+++ b/gnu/home-services.scm
@@ -0,0 +1,368 @@
+;;; 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 (gnu home-services)
+ #:use-module (gnu services)
+ #:use-module (guix channels)
+ #:use-module (guix monads)
+ #:use-module (guix store)
+ #:use-module (guix gexp)
+ #:use-module (guix profiles)
+ #:use-module (guix sets)
+ #:use-module (guix ui)
+ #:use-module (guix discovery)
+ #:use-module (guix diagnostics)
+
+ #:use-module (srfi srfi-1)
+ #:use-module (ice-9 match)
+
+ #:export (home-service-type
+ home-profile-service-type
+ home-environment-variables-service-type
+ home-files-service-type
+ home-run-on-first-login-service-type
+ home-activation-service-type)
+
+ #:re-export (service
+ service-type
+ service-extension))
+
+;;; Comment:
+;;;
+;;; This module is similar to (gnu system services) module, but
+;;; provides Home Services, which are supposed to be used for building
+;;; home-environment.
+;;;
+;;; Home Services use the same extension as System Services. Consult
+;;; (gnu system services) module or manual for more information.
+;;;
+;;; home-service-type is a root of home services DAG.
+;;;
+;;; home-profile-service-type is almost the same as profile-service-type, at least
+;;; for now.
+;;;
+;;; home-environment-variables-service-type generates a @file{setup-environment}
+;;; shell script, which is expected to be sourced by login shell or other program,
+;;; which starts early and spawns all other processes. Home services for shells
+;;; automatically add code for sourcing this file, if person do not use those home
+;;; services they have to source this script manually in their's shell *profile
+;;; file (details described in the manual).
+;;;
+;;; home-files-service-type is similar to etc-service-type, but doesn't extend
+;;; home-activation, because deploy mechanism for config files is pluggable and
+;;; can be different for different home environments: The default one is called
+;;; symlink-manager (will be introudced in a separate patch series), which creates
+;;; links for various dotfiles (like $XDG_CONFIG_HOME/$APP/...) to store, but is
+;;; possible to implement alternative approaches like read-only home from Julien's
+;;; guix-home-manager.
+;;;
+;;; home-run-on-first-login-service-type provides an @file{on-first-login} guile
+;;; script, which runs provided gexps once, when user makes first login. It can
+;;; be used to start user's Shepherd and maybe some other process. It relies on
+;;; assumption that /run/user/$UID will be created on login by some login
+;;; manager (elogind for example).
+;;;
+;;; home-activation-service-type provides an @file{activate} guile script, which
+;;; do three main things:
+;;;
+;;; - Sets environment variables to the values declared in
+;;; @file{setup-environment} shell script. It's necessary, because user can set
+;;; for example XDG_CONFIG_HOME and it should be respected by activation gexp of
+;;; symlink-manager.
+;;;
+;;; - Sets GUIX_NEW_HOME and possibly GUIX_OLD_HOME vars to paths in the store.
+;;; Later those variables can be used by activation gexps, for example by
+;;; symlink-manager or run-on-change services.
+;;;
+;;; - Run all activation gexps provided by other home services.
+;;;
+;;; Code:
+
+
+(define (home-derivation entries mextensions)
+ "Return as a monadic value the derivation of the 'home'
+directory containing the given entries."
+ (mlet %store-monad ((extensions (mapm/accumulate-builds identity
+ mextensions)))
+ (lower-object
+ (file-union "home" (append entries (concatenate extensions))))))
+
+(define home-service-type
+ ;; This is the ultimate service type, the root of the home service
+ ;; DAG. The service of this type is extended by monadic name/item
+ ;; pairs. These items end up in the "home-environment directory" as
+ ;; returned by 'home-environment-derivation'.
+ (service-type (name 'home)
+ (extensions '())
+ (compose identity)
+ (extend home-derivation)
+ (default-value '())
+ (description
+ "Build the home environment top-level directory,
+which in turn refers to everything the home environment needs: its
+packages, configuration files, activation script, and so on.")))
+
+(define (packages->profile-entry packages)
+ "Return a system entry for the profile containing PACKAGES."
+ ;; XXX: 'mlet' is needed here for one reason: to get the proper
+ ;; '%current-target' and '%current-target-system' bindings when
+ ;; 'packages->manifest' is called, and thus when the 'package-inputs'
+ ;; etc. procedures are called on PACKAGES. That way, conditionals in those
+ ;; inputs see the "correct" value of these two parameters. See
+ ;; <https://issues.guix.gnu.org/44952>.
+ (mlet %store-monad ((_ (current-target-system)))
+ (return `(("profile" ,(profile
+ (content (packages->manifest
+ (map identity
+ ;;(options->transformation transformations)
+ (delete-duplicates packages eq?))))))))))
+
+;; MAYBE: Add a list of transformations for packages. It's better to
+;; place it in home-profile-service-type to affect all profile
+;; packages and prevent conflicts, when other packages relies on
+;; non-transformed version of package.
+(define home-profile-service-type
+ (service-type (name 'home-profile)
+ (extensions
+ (list (service-extension home-service-type
+ packages->profile-entry)))
+ (compose concatenate)
+ (extend append)
+ (description
+ "This is the @dfn{home profile} and can be found in
+@file{~/.guix-home/profile}. It contains packages and
+configuration files that the user has declared in their
+@code{home-environment} record.")))
+
+(define (environment-variables->setup-environment-script vars)
+ "Return a file that can be sourced by a POSIX compliant shell which
+initializes the environment. The file will source the home
+environment profile, set some default environment variables, and set
+environment variables provided in @code{vars}. @code{vars} is a list
+of pairs (@code{(key . value)}), @code{key} is a string and
+@code{value} is a string or gexp.
+
+If value is @code{#f} variable will be omitted.
+If value is @code{#t} variable will be just exported.
+For any other, value variable will be set to the @code{value} and
+exported."
+ (define (warn-about-duplicate-defenitions)
+ (fold
+ (lambda (x acc)
+ (when (equal? (car x) (car acc))
+ (warning
+ (G_ "duplicate definition for `~a' environment variable ~%") (car x)))
+ x)
+ (cons "" "")
+ (sort vars (lambda (a b)
+ (string<? (car a) (car b))))))
+
+ (warn-about-duplicate-defenitions)
+ (with-monad
+ %store-monad
+ (return
+ `(("setup-environment"
+ ;; TODO: It's necessary to source ~/.guix-profile too
+ ;; on foreign distros
+ ,(apply mixed-text-file "setup-environment"
+ "\
+HOME_ENVIRONMENT=$HOME/.guix-home
+GUIX_PROFILE=\"$HOME_ENVIRONMENT/profile\"
+PROFILE_FILE=\"$HOME_ENVIRONMENT/profile/etc/profile\"
+[ -f $PROFILE_FILE ] && . $PROFILE_FILE
+
+case $XDG_DATA_DIRS in
+ *$HOME_ENVIRONMENT/profile/share*) ;;
+ *) export XDG_DATA_DIRS=$HOME_ENVIRONMENT/profile/share:$XDG_DATA_DIRS ;;
+esac
+case $MANPATH in
+ *$HOME_ENVIRONMENT/profile/share/man*) ;;
+ *) export MANPATH=$HOME_ENVIRONMENT/profile/share/man:$MANPATH
+esac
+case $INFOPATH in
+ *$HOME_ENVIRONMENT/profile/share/info*) ;;
+ *) export INFOPATH=$HOME_ENVIRONMENT/profile/share/info:$INFOPATH ;;
+esac
+case $XDG_CONFIG_DIRS in
+ *$HOME_ENVIRONMENT/profile/etc/xdg*) ;;
+ *) export XDG_CONFIG_DIRS=$HOME_ENVIRONMENT/profile/etc/xdg:$XDG_CONFIG_DIRS ;;
+esac
+case $XCURSOR_PATH in
+ *$HOME_ENVIRONMENT/profile/share/icons*) ;;
+ *) export XCURSOR_PATH=$HOME_ENVIRONMENT/profile/share/icons:$XCURSOR_PATH ;;
+esac
+
+"
+
+ (append-map
+ (match-lambda
+ ((key . #f)
+ '())
+ ((key . #t)
+ (list "export " key "\n"))
+ ((key . value)
+ (list "export " key "=" value "\n")))
+ vars)))))))
+
+(define home-environment-variables-service-type
+ (service-type (name 'home-environment-variables)
+ (extensions
+ (list (service-extension
+ home-service-type
+ environment-variables->setup-environment-script)))
+ (compose concatenate)
+ (extend append)
+ (default-value '())
+ (description "Set the environment variables.")))
+
+(define (files->files-directory files)
+ "Return a @code{files} directory that contains FILES."
+ (define (assert-no-duplicates files)
+ (let loop ((files files)
+ (seen (set)))
+ (match files
+ (() #t)
+ (((file _) rest ...)
+ (when (set-contains? seen file)
+ (raise (formatted-message (G_ "duplicate '~a' entry for files/")
+ file)))
+ (loop rest (set-insert file seen))))))
+
+ ;; Detect duplicates early instead of letting them through, eventually
+ ;; leading to a build failure of "files.drv".
+ (assert-no-duplicates files)
+
+ (file-union "files" files))
+
+(define (files-entry files)
+ "Return an entry for the @file{~/.guix-home/files}
+directory containing FILES."
+ (with-monad %store-monad
+ (return `(("files" ,(files->files-directory files))))))
+
+(define home-files-service-type
+ (service-type (name 'home-files)
+ (extensions
+ (list (service-extension home-service-type
+ files-entry)))
+ (compose concatenate)
+ (extend append)
+ (default-value '())
+ (description "Configuration files for programs that
+will be put in @file{~/.guix-home/files}.")))
+
+(define (compute-on-first-login-script _ gexps)
+ (gexp->script
+ "on-first-login"
+ #~(let* ((xdg-runtime-dir (or (getenv "XDG_RUNTIME_DIR")
+ (format #f "/run/user/~a" (getuid))))
+ (flag-file-path (string-append
+ xdg-runtime-dir "/on-first-login-executed"))
+ (touch (lambda (file-name)
+ (call-with-output-file file-name (const #t)))))
+ ;; XDG_RUNTIME_DIR dissapears on logout, that means such trick
+ ;; allows to launch on-first-login script on first login only
+ ;; after complete logout/reboot.
+ (when (not (file-exists? flag-file-path))
+ (begin #$@gexps (touch flag-file-path))))))
+
+(define (on-first-login-script-entry m-on-first-login)
+ "Return, as a monadic value, an entry for the on-first-login script
+in the home environment directory."
+ (mlet %store-monad ((on-first-login m-on-first-login))
+ (return `(("on-first-login" ,on-first-login)))))
+
+(define home-run-on-first-login-service-type
+ (service-type (name 'home-run-on-first-login)
+ (extensions
+ (list (service-extension
+ home-service-type
+ on-first-login-script-entry)))
+ (compose identity)
+ (extend compute-on-first-login-script)
+ (default-value #f)
+ (description "Run gexps on first user login. Can be
+extended with one gexp.")))
+
+
+(define (compute-activation-script init-gexp gexps)
+ (gexp->script
+ "activate"
+ #~(let* ((he-init-file (lambda (he) (string-append he "/setup-environment")))
+ (he-path (string-append (getenv "HOME") "/.guix-home"))
+ (new-home-env (getenv "GUIX_NEW_HOME"))
+ (new-home (or new-home-env
+ ;; Path of the activation file if called interactively
+ (dirname (car (command-line)))))
+ (old-home-env (getenv "GUIX_OLD_HOME"))
+ (old-home (or old-home-env
+ (if (file-exists? (he-init-file he-path))
+ (readlink he-path)
+ #f))))
+ (if (file-exists? (he-init-file new-home))
+ (let* ((port ((@ (ice-9 popen) open-input-pipe)
+ (format #f "source ~a && env"
+ (he-init-file new-home))))
+ (result ((@ (ice-9 rdelim) read-delimited) "" port))
+ (vars (map (lambda (x)
+ (let ((si (string-index x #\=)))
+ (cons (string-take x si)
+ (string-drop x (1+ si)))))
+ ((@ (srfi srfi-1) remove)
+ string-null?
+ (string-split result #\newline)))))
+ (close-port port)
+ (map (lambda (x) (setenv (car x) (cdr x))) vars)
+
+ (setenv "GUIX_NEW_HOME" new-home)
+ (setenv "GUIX_OLD_HOME" old-home)
+
+ #$@gexps
+
+ ;; Do not unset env variable if it was set outside.
+ (unless new-home-env (setenv "GUIX_NEW_HOME" #f))
+ (unless old-home-env (setenv "GUIX_OLD_HOME" #f)))
+ (format #t "\
+Activation script was either called or loaded by file from this direcotry:
+~a
+It doesn't seem that home environment is somewhere around.
+Make sure that you call ./activate by symlink from -home store item.\n"
+ new-home)))))
+
+(define (activation-script-entry m-activation)
+ "Return, as a monadic value, an entry for the activation script
+in the home environment directory."
+ (mlet %store-monad ((activation m-activation))
+ (return `(("activate" ,activation)))))
+
+(define home-activation-service-type
+ (service-type (name 'home-activation)
+ (extensions
+ (list (service-extension
+ home-service-type
+ activation-script-entry)))
+ (compose identity)
+ (extend compute-activation-script)
+ (default-value #f)
+ (description "Run gexps to activate the current
+generation of home environment and update the state of the home
+directory. @command{activate} script automatically called during
+reconfiguration or generation switching. This service can be extended
+with one gexp, but many times, and all gexps must be idempotent.")))
+
--
2.32.0
-----BEGIN PGP SIGNATURE-----

iQJDBAEBCgAtFiEEKEGaxlA4dEDH6S/6IgjSCVjB3rAFAmELewIPHGFuZHJld0B0
cm9wLmluAAoJECII0glYwd6wq5sP/06qZLWOs6kZeLLXPzXW/AVyBalLXk+dfbey
lHpjen64CG5mU6QP2XI+R8YnaeQnZ4fi9wEFU2JI7uXp+xy8n53UpMRWIv6UnO47
Tw5waFjMtCM8SkFbORxPHCpJ9a9nEPki9tVZTUvNwMAf+DyM9tB/15wA1WsoklbW
e5bj7dVR+Vl399PnKFccfQYAknaBF61yEtk/U+PBvGRivvXG12+hj48CO+5Gv1we
3u14z7iKwuJmiZgBcCrXJhx0/4lIhd1lC+0wxKLvHfiEjfam79FSNg0Age8q1Kfv
ZkjaaeiUahZ+Xrb9wW+Nb/oWFLfOSC2ZHvj+PTgqv67CYG8TLOgK5V/RbgS00wio
66q8V8kSDuTXOB9OI0UCZZ8HMY7u4lX9IdezTJoWL5DUknjhd0His2RQRTr3ds2e
mQolBJVjJICWgkBmHgemU1C4uxqpT+eSNWACdtb2FfsRM4B197ehEYzjvt4ojzNp
Kmt/+0OanYAOoEyVScTQMyhxXo0PaKX6vuqTAhFbqocLE+BxN4caG/DYy/M+g4wm
B76oksZVn6zmiMk3iQHrdtx2+NBvaOSSyXoeoYF4un/pI5FxQlaN5q/mqJxf9rN5
ilb8JorQovJ8nbzOts8PHo4fg7sTU1T1nlDziPcVpJX7z0mst2m2d0w+jEB5xHWu
Oppk+7Hn
=5TXb
-----END PGP SIGNATURE-----

A
A
Andrew Tropin wrote on 5 Aug 2021 07:46
[PATCH v4 2/4] home-services: Add home-run-on-change-service-type
(address . 49419@debbugs.gnu.org)
87mtpwmok1.fsf@trop.in
* gnu/home-services.scm (home-run-on-change-service-type): New variable.
---
gnu/home-services.scm | 103 +++++++++++++++++++++++++++++++++++++++++-
1 file changed, 102 insertions(+), 1 deletion(-)

Toggle diff (127 lines)
diff --git a/gnu/home-services.scm b/gnu/home-services.scm
index 4a6458abec..32b59f55df 100644
--- a/gnu/home-services.scm
+++ b/gnu/home-services.scm
@@ -37,7 +37,8 @@
home-environment-variables-service-type
home-files-service-type
home-run-on-first-login-service-type
- home-activation-service-type)
+ home-activation-service-type
+ home-run-on-change-service-type)
#:re-export (service
service-type
@@ -92,6 +93,9 @@
;;;
;;; - Run all activation gexps provided by other home services.
;;;
+;;; home-run-on-change-service-type allows to trigger actions during
+;;; activation if file or directory specified by pattern is changed.
+;;;
;;; Code:
@@ -366,3 +370,100 @@ directory. @command{activate} script automatically called during
reconfiguration or generation switching. This service can be extended
with one gexp, but many times, and all gexps must be idempotent.")))
+
+;;;
+;;; On-change.
+;;;
+
+(define (compute-on-change-gexp eval-gexps? pattern-gexp-tuples)
+ #~(begin
+ (define (equal-regulars? file1 file2)
+ "Check if FILE1 and FILE2 are bit for bit identical."
+ (let* ((cmp-binary #$(file-append
+ (@ (gnu packages base) diffutils) "/bin/cmp"))
+ (stats1 (lstat file1))
+ (stats2 (lstat file2)))
+ (cond
+ ((= (stat:ino stats1) (stat:ino stats2)) #t)
+ ((not (= (stat:size stats1) (stat:size stats2))) #f)
+
+ (else (= (system* cmp-binary file1 file2) 0)))))
+
+ (define (equal-symlinks? symlink1 symlink2)
+ "Check if SYMLINK1 and SYMLINK2 are pointing to the same target."
+ (string=? (readlink symlink1) (readlink symlink2)))
+
+ (define (equal-directories? dir1 dir2)
+ "Check if DIR1 and DIR2 have the same content."
+ (define (ordinary-file file)
+ (not (or (string=? file ".")
+ (string=? file ".."))))
+ (let* ((files1 (scandir dir1 ordinary-file))
+ (files2 (scandir dir2 ordinary-file)))
+ (if (equal? files1 files2)
+ (map (lambda (file)
+ (equal-files?
+ (string-append dir1 "/" file)
+ (string-append dir2 "/" file)))
+ files1)
+ #f)))
+
+ (define (equal-files? file1 file2)
+ "Compares files, symlinks or directories of the same type."
+ (case (file-type file1)
+ ((directory) (equal-directories? file1 file2))
+ ((symlink) (equal-symlinks? file1 file2))
+ ((regular) (equal-regulars? file1 file2))
+ (else
+ (display "The file type is unsupported by on-change service.\n")
+ #f)))
+
+ (define (file-type file)
+ (stat:type (lstat file)))
+
+ (define (something-changed? file1 file2)
+ (cond
+ ((and (not (file-exists? file1))
+ (not (file-exists? file2))) #f)
+ ((or (not (file-exists? file1))
+ (not (file-exists? file2))) #t)
+
+ ((not (eq? (file-type file1) (file-type file2))) #t)
+
+ (else
+ (not (equal-files? file1 file2)))))
+
+ (define expressions-to-eval
+ (map
+ (lambda (x)
+ (let* ((file1 (string-append (getenv "GUIX_OLD_HOME") "/" (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))
+ (_ (format #t " done (~a)\n"
+ (if any-changes? "changed" "same"))))
+ (if any-changes? (cadr x) "")))
+ '#$pattern-gexp-tuples))
+
+ (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.\n"))))
+
+(define home-run-on-change-service-type
+ (service-type (name 'home-run-on-change)
+ (extensions
+ (list (service-extension
+ home-activation-service-type
+ identity)))
+ (compose concatenate)
+ (extend compute-on-change-gexp)
+ (default-value #t)
+ (description "\
+G-expressions to run if the specified files have changed since the
+last generation. The extension should be a list of lists where the
+first element is the pattern for file or directory that expected to be
+changed, and the second element is the G-expression to be evaluated.")))
--
2.32.0
-----BEGIN PGP SIGNATURE-----

iQJDBAEBCgAtFiEEKEGaxlA4dEDH6S/6IgjSCVjB3rAFAmELey4PHGFuZHJld0B0
cm9wLmluAAoJECII0glYwd6wBiUP/i7ILAYn7hh1SE8feonHznL7sbUOZqosToMy
rXfI3XIW8xGQr3Br4rDzWnYSgPYVnrBYzibzBV7K8Wl6oNhQNARneHKAsgNNEPXN
yLkzc1IDsHtcF8MGOZ4/2ANvyckkS6u0xz3/P0qjlsP60Zew5fGvMJb/+MFthq5+
4hynnDk8XuRlQN/4qq6Zwhr7Mgzuaq9n8L7IyVusWYmgh4M2WviOzTlST01Q/2ta
XgaRJ6XNz0QtP0dLNaIG+5LEVSfxtZfVW5/xVBxo+VRhNG8i/adTnsAcL+/gpFiy
lDiblx+nrwwk6ybuk8ms+QlR0FSE5j4Oz6NQglsZ+JMZe8JqvGZoZs+lL6ZaIWMH
JAaZfWLJhZRxaCX9Kej3Z9TsKweR/ettYZHPRXFc+5AlolPUUB0IppUPQJYxg+jn
Idcd8P893GUqHcEp6m7Bz5aotIGuMGumWECw3pXiMGOYx9vfjlCr32u3J/fqy2cg
zzF3nFyEejCa+SZp3d/uzkBPuFabzhy+/uaxXk8aXlyBCUk/w9ZCjqtb0eqpnrGd
tbdSkz/R7XhDgJlgoK/st5bidP/pCRR1lRmBoUR/4imZzO6WCwxIp2rUjb268rh2
sZsf7iOX00Gg1NlPACPIwJwa6IS0lce8V0gRgxOnCm+AsdIn8u+6/oFa65emyU1S
W2ljCkCO
=WGSU
-----END PGP SIGNATURE-----

A
A
Andrew Tropin wrote on 5 Aug 2021 07:46
[PATCH v4 3/4] home-services: Add home-provenance-service-type
(address . 49419@debbugs.gnu.org)
87k0l0moj1.fsf@trop.in
* gnu/home-services.scm (home-provenance-service-type, sexp->home-provenance,
home-provenance): New variables.
---
gnu/home-services.scm | 27 ++++++++++++++++++++++++++-
1 file changed, 26 insertions(+), 1 deletion(-)

Toggle diff (44 lines)
diff --git a/gnu/home-services.scm b/gnu/home-services.scm
index 32b59f55df..d320d3a44d 100644
--- a/gnu/home-services.scm
+++ b/gnu/home-services.scm
@@ -38,7 +38,10 @@
home-files-service-type
home-run-on-first-login-service-type
home-activation-service-type
- home-run-on-change-service-type)
+ home-run-on-change-service-type
+ home-provenance-service-type
+
+ fold-home-service-types)
#:re-export (service
service-type
@@ -467,3 +470,25 @@ G-expressions to run if the specified files have changed since the
last generation. The extension should be a list of lists where the
first element is the pattern for file or directory that expected to be
changed, and the second element is the G-expression to be evaluated.")))
+
+
+;;;
+;;; Provenance tracking.
+;;;
+
+(define home-provenance-service-type
+ (service-type
+ (name 'home-provenance)
+ (extensions
+ (list (service-extension
+ home-service-type
+ (service-extension-compute
+ (first (service-type-extensions provenance-service-type))))))
+ (default-value #f) ;the HE config file
+ (description "\
+Store provenance information about the home environment in the home
+environment itself: the channels used when building the home
+environment, and its configuration file, when available.")))
+
+(define sexp->home-provenance sexp->system-provenance)
+(define home-provenance system-provenance)
--
2.32.0
-----BEGIN PGP SIGNATURE-----

iQJDBAEBCgAtFiEEKEGaxlA4dEDH6S/6IgjSCVjB3rAFAmELe1IPHGFuZHJld0B0
cm9wLmluAAoJECII0glYwd6wbLcP/iEJTPV0B59ezPSYYCYTTNQaijU6wJTfkXkf
1MB9DnQLK0eVnTrmPzSNW18BNiwrbJKA3BUcnw1u7+Ht23FvArKb7t0m0A/rbQtw
PkH8HEJMPFlGKOY/speO6dIH6c64b9f4erCLWh/If63w7ojAudp/y2faj632NhdH
ntAqTwzbmd8a6SkaXtEXjE5HRzoWThUmCvI+Zr4LJ3WxGBY6hFzxKiTAljyRWgnH
XEkCJUvWHJkh4+4U9Ih+3NagFbrBWzed1XTz97PgSYgrzkzG2OTVA6ElKwWPJAZG
6VThrBnGmyjMP28nN+wd0v7wnLu65hFs5SQhAVgBg72BkjW5EDTPFd0CnV254mh5
2pS59vWBTdShjlv4okNhqF972Ja87qKyZNgG063XW8g1w4ylfYy3g3L/FZHSjvKb
0OrMwl4/Xw8YcHrZF+F42ZAYgoCp3lxeSHp95On2m2IlacVTOJ4f6KIURmpZI9OT
4bdUZsM7Uvpwlit/G759onYZK4tCOX40b4+UhVUEHdcCz0O1o+r/J1BIBZ3DcDrA
1G4c38V9K0Ch5yNDprW0DsinA/51bgXlkjGAuMx/Vqp/2sZCSJN82w2q1vrysD/v
baKtyUWW0QoMy7TPHjYYm8RvZkZTiDtDaNGaeesEPQP4LHwD6AwijYfLAs/rhUEr
suCiQ8j9
=6vmB
-----END PGP SIGNATURE-----

A
A
Andrew Tropin wrote on 5 Aug 2021 07:47
[PATCH v4 4/4] home-services: Add fold-home-service-types function
(address . 49419@debbugs.gnu.org)
87h7g4mohv.fsf@trop.in
* gnu/home-services.scm (parent-directory, %guix-home-root-directory,
%service-type-path, all-home-service-modules, fold-home-service-types): New
variables.
---
gnu/home-services.scm | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)

Toggle diff (36 lines)
diff --git a/gnu/home-services.scm b/gnu/home-services.scm
index d320d3a44d..16b9736d64 100644
--- a/gnu/home-services.scm
+++ b/gnu/home-services.scm
@@ -492,3 +492,29 @@ environment, and its configuration file, when available.")))
(define sexp->home-provenance sexp->system-provenance)
(define home-provenance system-provenance)
+
+
+;;;
+;;; Searching
+;;;
+
+(define (parent-directory directory)
+ "Get the parent directory of DIRECTORY"
+ (string-join (drop-right (string-split directory #\/) 1) "/"))
+
+(define %guix-home-root-directory
+ ;; Absolute file name of the module hierarchy.
+ (parent-directory (dirname (search-path %load-path "gnu/home-services.scm"))))
+
+(define %service-type-path
+ ;; Search path for service types.
+ (make-parameter `((,%guix-home-root-directory . "gnu/home-services"))))
+
+(define (all-home-service-modules)
+ "Return the default set of home-service modules."
+ (cons (resolve-interface '(gnu home-services))
+ (all-modules (%service-type-path)
+ #:warn warn-about-load-error)))
+
+(define* (fold-home-service-types proc seed)
+ (fold-service-types proc seed (all-home-service-modules)))
--
2.32.0
-----BEGIN PGP SIGNATURE-----

iQJDBAEBCgAtFiEEKEGaxlA4dEDH6S/6IgjSCVjB3rAFAmELe3wPHGFuZHJld0B0
cm9wLmluAAoJECII0glYwd6wWMMP+wZ4fP/zaU11arRXnWhHiFGM+4f4cY4XNW53
UWgxIYW4cqAe4U7K2UzIPQ1wBUuMpO+54l5f0qOIn629JVeEt5tvc2l8aLyHql75
BJ9u82bPk7Zk2kbWW/h7N1Anvp87PNwP2hqmpi9NSWHDHcWLyZMXUaqi099yb8BF
Xyw++P9Ugy/nhE8Ml0sLLBVuJfZG0QT3dwVn/LdcqcbFM9KcmnW01ysukjSkiIXP
WFxyb2W3XI5hQo/JKR15Remi8L8YudChXoVaXwRGbbgeIyuvkY+p3ocxwfHWCDjX
V9BmaT4NAIjCrkA3tP0a7TrNTbJjfOdPfNg0hA7FU4IjFOYtMFmK9dnuLuTr31zQ
EcsKBEyLUCj45I+lhmZ1yhbMmnrc76gR1VxwKozTEcbnizRfr0oG5Fu3mGdebha3
VeHEilLAj8QOm+bsaWfsV2TVfPkDc8ySRoIm+xzt18s0Fy3mLVv3WoFiT8XrL6sb
sNJqxcjH+BUuQ1zFv4/XIwKFd5xPKHfxC/GveZsPIz2d2bCTW8WqBuveA4WQYgjk
mF/T6ZHZgSwUF5DQxDDsHeReKwYEA+tUnOvyGI8UcGlaVOANm9K+7wWpLAp16jVd
DrCRm6WuWD6Jbp5TyQpyGSZZKEperkuilhjbihxj6mTXTSXEcI6oDmBEzLwiW6Ez
r6b4q7h/
=lxRc
-----END PGP SIGNATURE-----

A
A
Andrew Tropin wrote on 23 Aug 2021 11:57
Re: [PATCH v4 0/4] Essential home services
(address . 49419@debbugs.gnu.org)
87h7fgbi1a.fsf@trop.in
On 2021-08-05 08:41, Andrew Tropin wrote:

Toggle quote (18 lines)
> Seems there is no additional comments about implementation, so I just
> send cosmetical changes treating comments from previous reviews.
>
> Changes since v3:
> - Remove tabs.
> - Move Home Services explanation from commit message to comment.
> - Add missing ChangeLog-style commit body.
>
> Andrew Tropin (4):
> home-services: Add most essential home services
> home-services: Add home-run-on-change-service-type
> home-services: Add home-provenance-service-type
> home-services: Add fold-home-service-types function
>
> gnu/home-services.scm | 520 ++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 520 insertions(+)
> create mode 100644 gnu/home-services.scm

Guys, review v4 patches, please.
-----BEGIN PGP SIGNATURE-----

iQJDBAEBCgAtFiEEKEGaxlA4dEDH6S/6IgjSCVjB3rAFAmEjcPEPHGFuZHJld0B0
cm9wLmluAAoJECII0glYwd6wAUAP/RbYZxu119qlh9ljgBkefbKPBYV7vTm6evyK
fJS5o89IWUhgdzODasLXmLOI5aDc4yy0akJDv5XBl4xmqHn/+UOAkOo+sc7+tisE
YxE/Jh60p5JpnrMKGIwhQS9dXK3YfqPE/Bdq1MDIzLw1KtZmnVZA1gCkFxOiH1I/
MNgfc2bVhue9DmlW6pIjWiI/3XYzmFfr1nPED5zlFUGWrMawF4vXn2CBg2ID7aR7
eWtfXNptQzIYPl0wSHaSQK2WxF4U8LRM6hrUD+AG688O4jXw/4wx/Tpr1LGAH/gJ
pVZODAuC/U0HKGY61anrIknyz3NAYFDeK7ynnFWx7XNY17SHdrQZwqJ/DwLN1tSL
YRm/8fxEX5I7jeP5LWI9Ks33VkowVVHGHESeihiOlMf4uS9gNyDUaFIFMfBmXGKN
frq1s+TjOu7UXV8lafg/oZ+IRNzGXcx0skEsQN5FvkS2+lKbVGIWGeqqd2To7bit
7UVPpyaYW6DTBkbmOHUBCrC/6GR63sgp5yry5IcLpv6X/imXZcQ/Iq+j98SOyDmL
/0QxGF7+6QM/LOjJRjI3REKAHXJlUDhjNbGja4geWLsGBamOmeS5aBDNzWCN8Ycr
pClXqvwpqmYvjm7JuaMs+JFAdmDyWEOhBCtLbTSVAGHQidTOCaIt6raoDg2mbsOt
y83L1daH
=XwFU
-----END PGP SIGNATURE-----

O
O
Oleg Pykhalov wrote on 23 Aug 2021 18:24
Re: bug#49419: [PATCH 0/4] Essential home services
(name . Andrew Tropin)(address . andrew@trop.in)
87h7fgxh6u.fsf_-_@gmail.com
Hi Andrew,

Andrew Tropin <andrew@trop.in> writes:

[…]

Toggle quote (2 lines)
> Guys, review v4 patches, please.

These patch series looks good for me.

As Ludovic suggested, we could move modules to another namespace for
code sharing, but it is not a blocker from merging changes and we could
do it later when we need to share the code. I think we should go
forward and push to the master. WDYT?

As I remember you have an access to push. Otherwise, please, ping me to
push it.<

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

iQJIBAEBCgAyFiEEcjhxI46s62NFSFhXFn+OpQAa+pwFAmEjy7kUHGdvLndpZ3Vz
dEBnbWFpbC5jb20ACgkQFn+OpQAa+pw8sxAApf+jD9R7xO3ofAjyCgn5uzujvgsY
QBu12tIkEpAREL683D1TdMudTfGbDEByARMFdreIvS6NNfZyOEJHJmaN1ENE2MsI
kztOYV/S7ZDmOIfyONNo7JFjam+4a0WqKoUvU736T8V1hh6CQQYBKbL0yOJQxB2W
ANjEo6TpmHEMdCQSasxylTceujebrjsy8H+xq8EQtq4+GIU3rJmTf1R3G+/BoO6/
0MLlDjX8vRIZL0o2f7JjicdmOoLw0H2E096bZMuySeW2LxxExS+b3DNBjrTEi+Kl
+s0Z9jHAqB7ohC44A9ftcs6xsoHjlcUGHCYvNk/QZz1Cj5xFk8jIfrcZFKn/F0AW
T+8qAxiPpjkJ+UciOftHONxr/gBWrLiee2Jp6Edui9G2K3Anzk3C6zlRKaajNeUm
1aLpa7AMbKrJEJHi4YHlpKKjWlqm7+jSvoH3V8XK3Y0mNJzpDvU4fN7XVLfDGuzE
1F3GpqVjFy4Qsdg3Tlx8kE4Gll33k/Jb/apemsh68btFGwEZDv4jwzqCsPOWeeoC
F+9bQqsMZRkAPOpbYeExW/wh+Rc8LtRUFASSHna/dIIVTD77HfgS2vF4Df0Tuwpn
ZxqHeEwMkODrtsEgLPLKUqWoiXgzpCiBje0ZiovX97Uzq8ayUaAMOWAlpKpxWGSc
hu/ebg8wxxLhbhQ=
=9inX
-----END PGP SIGNATURE-----

A
A
Andrew Tropin wrote on 24 Aug 2021 10:53
(name . Oleg Pykhalov)(address . go.wigust@gmail.com)
875yvvnrz1.fsf@trop.in
On 2021-08-23 19:24, Oleg Pykhalov wrote:

Toggle quote (3 lines)
> Hi Andrew,
>

Hi Oleg!

Toggle quote (8 lines)
>
> These patch series looks good for me.
>
> As Ludovic suggested, we could move modules to another namespace for
> code sharing, but it is not a blocker from merging changes and we could
> do it later when we need to share the code. I think we should go
> forward and push to the master. WDYT?

Yep, let's postpone moving modules to another namespace until it will be
needed. Later, when the necessity appears, we will decide how to better
organize the code.

We can push it to master, but I planned to keep it in wip-guix-home for
a while to bring all related stuff like documentation and cli to the
branch and merge it to the master after everything is complete.

Also, merging only part of Guix Home to the master will arise conflicts
for users of rde channel (which contains current implementation of Guix
Home). However, it is solvable by removing already merged parts from
rde repository, so, it's not a big deal and I'm fine with both merging
options.

Toggle quote (3 lines)
>
> As I remember you have an access to push.

Nope, I don't have commit access yet)

Toggle quote (2 lines)
> Otherwise, please, ping me to push it.<

If everything seems ok, merge the changes, please. I'll prepare the
next patch series soon.

Toggle quote (3 lines)
>
> Thanks,
> Oleg.
-----BEGIN PGP SIGNATURE-----

iQJDBAEBCgAtFiEEKEGaxlA4dEDH6S/6IgjSCVjB3rAFAmEks6IPHGFuZHJld0B0
cm9wLmluAAoJECII0glYwd6w7WIP/0KYD7Cs9sJHmU4lOpB0wWsVm/OwLxSV13eT
TRdwePTizPrIuHuSg3EJMLM0BAZxyTzy0gPg6if8PlgJVnegzZaMUoGvc4sUfkTW
zw3a+l1YU4ZsrIrl2CY8cqocPJznWSZuq2uYCfXiCQ7T2xfleOIXBpMSR6a0YOTn
iMGnLVsbuqDcJVsNHR09t4dIFNX3mzGjXj/PrJkU0qB5fAsk7RccvSDryi1px/y6
7YXY5F0YIgcbnaT0ZN4JlYPFkNIsHOToQo/q16qzIGcRvOINlTytx9kGXgoCBcuO
4MW0PzSleE6GpXNyJT/s6kFgNGMHJQVQYxAb9M6eMeFW5T8ifVmTJlZs6ZngooX5
GX8JcwJYWNzSEiPJTpHqZAKTV2Lt9G1/58aQWOl0BlBOj2pNZsr8lyrcDqeLnBdA
1SWeOlxgXDGZQTiLaO8TMEoJct5iH52r0PG2qzTEpnCJEb09j0DMkDNPBm4bmdqB
irZ52pZ0VzwXACT/r/+Psmrdsf3JeXZuJEaRCDqae658l4YLtPDUao5jS+ozIAg9
axggyeB5lga7mukDvW6TADlbUP+swrCKFZDA0FFy7tVSl8dz33TXGa4qvOKNoxHR
wbG9V7RuEpqwlkl3x2hCVkLivz1yN+KdzZEh0TwpozQ38609G1FNFKu/5ZpBmTgj
Gjeb1Lzo
=hfxK
-----END PGP SIGNATURE-----

O
O
Oleg Pykhalov wrote on 24 Aug 2021 14:14
(name . Andrew Tropin)(address . andrew@trop.in)(address . 49419-done@debbugs.gnu.org)
87h7ffujj2.fsf@gmail.com
Andrew Tropin <andrew@trop.in> writes:

[…]

Toggle quote (19 lines)
>> As Ludovic suggested, we could move modules to another namespace for
>> code sharing, but it is not a blocker from merging changes and we could
>> do it later when we need to share the code. I think we should go
>> forward and push to the master. WDYT?
>
> Yep, let's postpone moving modules to another namespace until it will be
> needed. Later, when the necessity appears, we will decide how to better
> organize the code.
>
> We can push it to master, but I planned to keep it in wip-guix-home for
> a while to bring all related stuff like documentation and cli to the
> branch and merge it to the master after everything is complete.
>
> Also, merging only part of Guix Home to the master will arise conflicts
> for users of rde channel (which contains current implementation of Guix
> Home). However, it is solvable by removing already merged parts from
> rde repository, so, it's not a big deal and I'm fine with both merging
> options.

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

iQJIBAEBCgAyFiEEcjhxI46s62NFSFhXFn+OpQAa+pwFAmEk4qEUHGdvLndpZ3Vz
dEBnbWFpbC5jb20ACgkQFn+OpQAa+pyYuhAAyHVQrGM+CR6TY1LRtyW3Es32Egt2
ubRyL7I9JduQUgtdKkW7Tl364P6yGUB7SIkeSoYFMSqHAmvPMyn7geUko/u1iFmb
jy9PfizxhMUTRHR3pUT0qU7PYjexF9mU7kRYoT62ICjXBgq6UVEfhs9EFPC/8n0a
3HRtyIFpWWRq+Hw/KixqZ9K6XFQVZjeSzK6ll8KFSyizlipQvT5J6IN+QwhLjDIK
v9BU37GoJoSkTMBG3pu+EfFNiPtR1FGRQOXBrDjZkJ+PGXQW0MVKDxTI/KTb+9/V
+QAUtrcvz8d3I3dEfLJTHjsWdp6TLTUzv3X/zGUY30qy3M36/Ukbx82+OQ1dr2mg
tvKwf4sdjYaG6Iod02Bkd4KZQ/rJq/nDqpzed9YJ+b4QdKDZvqVaGwtbqJO/MQLG
DEUZAL9Wvr3av/wwWAnDYW3bTbR6xPuuQdnE9YrNBzldJ9G6fq1m1fEtILEx17oK
ve0ImAb69CSu3R+Z3wOep9ueuohraVRuc8JiGX/Y8CY5bbtRH45Leum8aGE4EiRG
qaDZmZI1dCEiP/j+VOrokgSQCsuUA57UJMqTMHmFEXsENifJ+zl2lKynM1rbxKFV
vzbzmHURpQHPvpkuLZLSDyRyoanWKD/5my+ObhG/wpeF8oGs6CZqoBg71A7R5Fuf
ryJyXET+LuN/PCs=
=dUIt
-----END PGP SIGNATURE-----

Closed
A
A
Andrew Tropin wrote on 26 Aug 2021 09:01
(name . Oleg Pykhalov)(address . go.wigust@gmail.com)(address . 49419-done@debbugs.gnu.org)
878s0obsfr.fsf@trop.in
On 2021-08-24 15:14, Oleg Pykhalov wrote:

Toggle quote (27 lines)
> Andrew Tropin <andrew@trop.in> writes:
>
> […]
>
>>> As Ludovic suggested, we could move modules to another namespace for
>>> code sharing, but it is not a blocker from merging changes and we could
>>> do it later when we need to share the code. I think we should go
>>> forward and push to the master. WDYT?
>>
>> Yep, let's postpone moving modules to another namespace until it will be
>> needed. Later, when the necessity appears, we will decide how to better
>> organize the code.
>>
>> We can push it to master, but I planned to keep it in wip-guix-home for
>> a while to bring all related stuff like documentation and cli to the
>> branch and merge it to the master after everything is complete.
>>
>> Also, merging only part of Guix Home to the master will arise conflicts
>> for users of rde channel (which contains current implementation of Guix
>> Home). However, it is solvable by removing already merged parts from
>> rde repository, so, it's not a big deal and I'm fine with both merging
>> options.
>
> OK, pushed to the wip-guix-home.
>
> https://git.savannah.gnu.org/cgit/guix.git/?h=wip-guix-home

Thank you very much!)

Sent a next patch for Guix Home. #50208
-----BEGIN PGP SIGNATURE-----

iQJDBAEBCgAtFiEEKEGaxlA4dEDH6S/6IgjSCVjB3rAFAmEnPEgPHGFuZHJld0B0
cm9wLmluAAoJECII0glYwd6wWkYQAJCI+EQQ7BtfreCXyjdskcT1qtUhfaGvU9IT
uqC22kha6kSVic71jFOUSgrjlABLiuf9T9uBfKUamYVPu4zwpFMKeMBbIeKOKH14
83QIl5g4AE/KFLaT0n9U+i+n14KOJwr32uR81R6++bkVrPJCYIF4Jw9bASNgEt24
PsfLF5LgH7PinbLje9EEUNTOoNlP8ba5ReMK6H1eVTOQECK/zR9UREhzOvOXAs6a
utayZtizfhXvByCtbWLhzn1eMHYXioesukSqLuaEzKFeAZDSk0JoAeEUjJ1eyPNq
J+fG+pMzfDmjpOJ2fOsZqdCfubBG6Wsv79Hz/7yI2ey7dVOeS2cE0E0P7rIZa9Fn
kaCAva6wIzNGTDGtfDF/RKACHVi0nCoiuY91ByxqCFNaYGTReQcciKlSossE7q/f
hayrmbScXTsV6aVEjGc1kGMsd1GtXai6TbCvKUQPuRrmiDzTdpvL8/E1EN6TYph+
2zAhTwif7SEdbqp/VjdTm17lq3tv7tZ3vuAQ333tWF0n+eF8u9T2/z+PHY8tTTku
/VLbYeRkiLOWha9NfYEH+QDuGhW5urDuls9M0cGe3TMHjeZtmm6DcmFgPdQq2Dth
imj/E7OycR5/O2K1Y41p7JsyVFD1LAl0PL5fXl2QNcYOa8D1/DVN7C6Zp3EhIexi
JJEg7cgy
=AM+3
-----END PGP SIGNATURE-----

Closed
?