* [bug#50967] [PATCH 00/12] Move (gnu home-services XYZ) to (gnu services XYZ) @ 2021-10-02 13:43 Oleg Pykhalov 2021-10-02 13:45 ` [bug#50967] [PATCH 01/12] tests: Add tests for guix home cli Oleg Pykhalov ` (2 more replies) 0 siblings, 3 replies; 64+ messages in thread From: Oleg Pykhalov @ 2021-10-02 13:43 UTC (permalink / raw) To: 50967; +Cc: Oleg Pykhalov This patch series moves (gnu home-services XYZ) to (gnu services XYZ) for: 1. Better module naming (discussed at https://lists.gnu.org/archive/html/guix-devel/2021-09/msg00169.html ) 2. Easier code sharing. E.g. (gnu home-services mcron) uses ‘@@’ which should never be used, and not guaranteed to work these days, due to inlining. Tests: passes ‘make check TESTS=tests/guix-home.sh’ succeeded ‘./pre-inst-env guix home build …/home.scm’ succeeded ‘./pre-inst-env guix home reconfigure …/home.scm’ Andrew Tropin (1): tests: Add tests for guix home cli. Oleg Pykhalov (11): gnu: home-services: Move configuration to (gnu services). gnu: home-services: Move symlink-manager to (gnu services). gnu: home-services: Move utils to (gnu services). gnu: home-services: Move fontutils to (gnu services). gnu: home-services: Move shells to (gnu services). gnu: home-services: Move xdg to (gnu services). gnu: home-services: Move shepherd to (gnu services). gnu: home-services: Move mcron to (gnu services). gnu: home-services: Change %service-type-path and filter services. scripts: home: (gnu home-services bash) -> (gnu services bash). doc: (gnu home-services) -> (gnu services). Makefile.am | 1 + doc/guix.texi | 8 +- doc/he-config-bare-bones.scm | 2 +- gnu/home-services.scm | 9 +- gnu/home-services/configuration.scm | 109 -------------- gnu/home-services/mcron.scm | 115 --------------- gnu/home-services/shepherd.scm | 134 ------------------ gnu/home.scm | 8 +- gnu/local.mk | 13 +- gnu/services/configuration.scm | 89 +++++++++++- gnu/{home-services => services}/fontutils.scm | 2 +- gnu/services/mcron.scm | 89 +++++++++++- gnu/{home-services => services}/shells.scm | 6 +- gnu/services/shepherd.scm | 112 ++++++++++++++- .../symlink-manager.scm | 2 +- gnu/{home-services => services}/utils.scm | 2 +- gnu/{home-services => services}/xdg.scm | 6 +- guix/scripts/home/import.scm | 2 +- tests/guix-home.sh | 99 +++++++++++++ 19 files changed, 417 insertions(+), 391 deletions(-) delete mode 100644 gnu/home-services/configuration.scm delete mode 100644 gnu/home-services/mcron.scm delete mode 100644 gnu/home-services/shepherd.scm rename gnu/{home-services => services}/fontutils.scm (98%) rename gnu/{home-services => services}/shells.scm (99%) rename gnu/{home-services => services}/symlink-manager.scm (99%) rename gnu/{home-services => services}/utils.scm (98%) rename gnu/{home-services => services}/xdg.scm (99%) create mode 100644 tests/guix-home.sh -- 2.33.0 ^ permalink raw reply [flat|nested] 64+ messages in thread
* [bug#50967] [PATCH 01/12] tests: Add tests for guix home cli. 2021-10-02 13:43 [bug#50967] [PATCH 00/12] Move (gnu home-services XYZ) to (gnu services XYZ) Oleg Pykhalov @ 2021-10-02 13:45 ` Oleg Pykhalov 2021-10-02 13:45 ` [bug#50967] [PATCH 02/12] gnu: home-services: Move configuration to (gnu services) Oleg Pykhalov ` (10 more replies) 2021-10-02 16:38 ` [bug#50967] [PATCH 01/14] tests: Add tests for guix home cli Oleg Pykhalov 2021-10-02 20:13 ` [bug#50967] [PATCH] home: services: configuration: Move and refactor content Oleg Pykhalov 2 siblings, 11 replies; 64+ messages in thread From: Oleg Pykhalov @ 2021-10-02 13:45 UTC (permalink / raw) To: 50967; +Cc: Oleg Pykhalov, Andrew Tropin From: Andrew Tropin <andrew@trop.in> * tests/guix-home.sh: New file. * Makefile.am (SH_TESTS): Add tests/guix-home.sh. Signed-off-by: Oleg Pykhalov <go.wigust@gmail.com> --- Makefile.am | 1 + tests/guix-home.sh | 99 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 100 insertions(+) create mode 100644 tests/guix-home.sh diff --git a/Makefile.am b/Makefile.am index b66789fa0b..5bf2567dc8 100644 --- a/Makefile.am +++ b/Makefile.am @@ -546,6 +546,7 @@ SH_TESTS = \ tests/guix-package-aliases.sh \ tests/guix-package-net.sh \ tests/guix-system.sh \ + tests/guix-home.sh \ tests/guix-archive.sh \ tests/guix-authenticate.sh \ tests/guix-environment.sh \ diff --git a/tests/guix-home.sh b/tests/guix-home.sh new file mode 100644 index 0000000000..cb015c907f --- /dev/null +++ b/tests/guix-home.sh @@ -0,0 +1,99 @@ +# GNU Guix --- Functional package management for GNU +# Copyright © 2021 Andrew Tropin <andrew@trop.in> +# +# This file is part of GNU Guix. +# +# GNU Guix is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or (at +# your option) any later version. +# +# GNU Guix is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. + +# +# Test 'guix home' cli. +# + +set -e + +guix home --version + +tmpfile="t-guix-home-$$" +errorfile="t-guix-home-error-$$" + +# Note: This directory is chosen outside $builddir so that relative file name +# canonicalization doesn't mess up with 'current-source-directory', used by +# 'local-file' ('load' forces 'relative' for +# %FILE-PORT-NAME-CANONICALIZATION.) +tmpdir="${TMPDIR:-/tmp}/t-guix-home-$$" +mkdir "$tmpdir" + +trap 'rm -f "$tmpfile" "$errorfile" "$tmpdir"/*; rmdir "$tmpdir"' EXIT + +# Reporting of syntax errors. + +cat > "$tmpfile"<<EOF +;; This is line 1, and the next one is line 2. + (home-environment + (packages)) +;; The 'T' is at column 3. +EOF + +if guix home build "$tmpfile" 2> "$errorfile" +then + # This must not succeed. + exit 1 +else + grep "$tmpfile:3:4: error: (packages): invalid field specifier" "$errorfile" +fi + + +cat > "$tmpfile"<<EOF +;; This is line 1, and the next one is line 2. + (home-environment +;; This is line 3, and there is no closing paren! +EOF + +if guix home build "$tmpfile" 2> "$errorfile" +then + # This must not succeed. + exit 1 +else + # Guile 3.0.6 gets line/column numbers for 'read-error' wrong + # (zero-indexed): <https://bugs.gnu.org/48089>. + grep "$tmpfile:4:1: missing closing paren" "$errorfile" || \ + grep "$tmpfile:3:0: missing closing paren" "$errorfile" +fi + +# Reporting of duplicate system service declaration. + +cat > "$tmpfile" <<EOF +(use-modules (gnu)) +(use-modules (gnu home-services shepherd)) + +(home-environment + (services (list (service home-shepherd-service-type) + (simple-service 'test-shepherd-extension + home-shepherd-service-type '()) + (service home-shepherd-service-type) + (service home-shepherd-service-type)))) +EOF + +if guix home build "$tmpfile" 2> "$errorfile" +then + # This must not succeed. + exit 1 +else + grep "guix home: error: more than one target service of type 'home-shepherd'" "$errorfile" +fi + +# Searching. + +guix home search mcron | grep "^name: home-mcron" +guix home search job manager | grep "^name: home-mcron" -- 2.33.0 ^ permalink raw reply related [flat|nested] 64+ messages in thread
* [bug#50967] [PATCH 02/12] gnu: home-services: Move configuration to (gnu services). 2021-10-02 13:45 ` [bug#50967] [PATCH 01/12] tests: Add tests for guix home cli Oleg Pykhalov @ 2021-10-02 13:45 ` Oleg Pykhalov 2021-10-02 13:45 ` [bug#50967] [PATCH 03/12] gnu: home-services: Move symlink-manager " Oleg Pykhalov ` (9 subsequent siblings) 10 siblings, 0 replies; 64+ messages in thread From: Oleg Pykhalov @ 2021-10-02 13:45 UTC (permalink / raw) To: 50967; +Cc: Oleg Pykhalov * gnu/home-services/configuration.scm: Move the content ... * gnu/services/configuration.scm: ... here. * gnu/local.mk (GNU_SYSTEM_MODULES): Delete gnu/home-services/configuration. * gnu/home-services/shells.scm: Replace (gnu home-services configuration) with (gnu services configuration). * gnu/home-services/xdg.scm: Same. --- gnu/home-services/configuration.scm | 109 ---------------------------- gnu/home-services/shells.scm | 2 +- gnu/home-services/xdg.scm | 2 +- gnu/local.mk | 1 - gnu/services/configuration.scm | 89 ++++++++++++++++++++++- 5 files changed, 89 insertions(+), 114 deletions(-) delete mode 100644 gnu/home-services/configuration.scm diff --git a/gnu/home-services/configuration.scm b/gnu/home-services/configuration.scm deleted file mode 100644 index e8f4bc77ec..0000000000 --- a/gnu/home-services/configuration.scm +++ /dev/null @@ -1,109 +0,0 @@ -;;; 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 configuration) - #:use-module (gnu services configuration) - #:use-module (guix gexp) - #:use-module (srfi srfi-1) - #:use-module (ice-9 curried-definitions) - #:use-module (ice-9 match) - #:use-module (guix i18n) - #:use-module (guix diagnostics) - - #:export (filter-configuration-fields - - interpose - list-of - - list-of-strings? - alist? - string-or-gexp? - serialize-string-or-gexp - text-config? - serialize-text-config - generic-serialize-alist-entry - generic-serialize-alist)) - -(define* (filter-configuration-fields configuration-fields fields - #:optional negate?) - "Retrieve the fields listed in FIELDS from CONFIGURATION-FIELDS. -If NEGATE? is @code{#t}, retrieve all fields except FIELDS." - (filter (lambda (field) - (let ((member? (member (configuration-field-name field) fields))) - (if (not negate?) member? (not member?)))) - configuration-fields)) - - -(define* (interpose ls #:optional (delimiter "\n") (grammar 'infix)) - "Same as @code{string-join}, but without join and string, returns an -DELIMITER interposed LS. Support 'infix and 'suffix GRAMMAR values." - (when (not (member grammar '(infix suffix))) - (raise - (formatted-message - (G_ "The GRAMMAR value must be 'infix or 'suffix, but ~a provided.") - grammar))) - (fold-right (lambda (e acc) - (cons e - (if (and (null? acc) (eq? grammar 'infix)) - acc - (cons delimiter acc)))) - '() ls)) - -(define (list-of pred?) - "Return a procedure that takes a list and check if all the elements of -the list result in @code{#t} when applying PRED? on them." - (lambda (x) - (if (list? x) - (every pred? x) - #f))) - - -(define list-of-strings? - (list-of string?)) - -(define alist? list?) - -(define (string-or-gexp? sg) (or (string? sg) (gexp? sg))) -(define (serialize-string-or-gexp field-name val) "") - -(define (text-config? config) - (and (list? config) (every string-or-gexp? config))) -(define (serialize-text-config field-name val) - #~(string-append #$@(interpose val "\n" 'suffix))) - -(define ((generic-serialize-alist-entry serialize-field) entry) - "Apply the SERIALIZE-FIELD procedure on the field and value of ENTRY." - (match entry - ((field . val) (serialize-field field val)))) - -(define (generic-serialize-alist combine serialize-field fields) - "Generate a configuration from an association list FIELDS. - -SERIALIZE-FIELD is a procedure that takes two arguments, it will be -applied on the fields and values of FIELDS using the -@code{generic-serialize-alist-entry} procedure. - -COMBINE is a procedure that takes one or more arguments and combines -all the alist entries into one value, @code{string-append} or -@code{append} are usually good candidates for this. - -See the @code{serialize-alist} procedure in `@code{(gnu home-services -version-control}' for an example usage.)}" - (apply combine - (map (generic-serialize-alist-entry serialize-field) fields))) diff --git a/gnu/home-services/shells.scm b/gnu/home-services/shells.scm index ecb02098f7..f9057cc8a2 100644 --- a/gnu/home-services/shells.scm +++ b/gnu/home-services/shells.scm @@ -19,7 +19,7 @@ (define-module (gnu home-services shells) #:use-module (gnu services configuration) - #:use-module (gnu home-services configuration) + #:use-module (gnu services configuration) #:use-module (gnu home-services utils) #:use-module (gnu home-services) #:use-module (gnu packages shells) diff --git a/gnu/home-services/xdg.scm b/gnu/home-services/xdg.scm index 94275f3b65..efc1870c28 100644 --- a/gnu/home-services/xdg.scm +++ b/gnu/home-services/xdg.scm @@ -19,7 +19,7 @@ (define-module (gnu home-services xdg) #:use-module (gnu services configuration) - #:use-module (gnu home-services configuration) + #:use-module (gnu services configuration) #:use-module (gnu home-services) #:use-module (gnu packages freedesktop) #:use-module (gnu home-services utils) diff --git a/gnu/local.mk b/gnu/local.mk index d415b892e9..0e1ff9f462 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -77,7 +77,6 @@ GNU_SYSTEM_MODULES = \ %D%/home-services.scm \ %D%/home-services/symlink-manager.scm \ %D%/home-services/fontutils.scm \ - %D%/home-services/configuration.scm \ %D%/home-services/shells.scm \ %D%/home-services/shepherd.scm \ %D%/home-services/mcron.scm \ diff --git a/gnu/services/configuration.scm b/gnu/services/configuration.scm index df3d3b6f9b..54e5cd1a79 100644 --- a/gnu/services/configuration.scm +++ b/gnu/services/configuration.scm @@ -4,6 +4,7 @@ ;;; Copyright © 2017, 2018 Clément Lassieur <clement@lassieur.org> ;;; Copyright © 2021 Xinglu Chen <public@yoctocell.xyz> ;;; Copyright © 2021 Maxim Cournoyer <maxim.cournoyer@gmail.com> +;;; Copyright © 2021 Andrew Tropin <andrew@trop.in> ;;; ;;; This file is part of GNU Guix. ;;; @@ -25,10 +26,12 @@ #:use-module (guix records) #:use-module (guix gexp) #:use-module ((guix utils) #:select (source-properties->location)) - #:use-module ((guix diagnostics) #:select (location-file)) + #:use-module ((guix diagnostics) #:select (formatted-message location-file)) #:use-module ((guix modules) #:select (file-name->module-name)) + #:use-module (guix i18n) #:autoload (texinfo) (texi-fragment->stexi) #:autoload (texinfo serialize) (stexi->texi) + #:use-module (ice-9 curried-definitions) #:use-module (ice-9 match) #:use-module (srfi srfi-1) #:use-module (srfi srfi-34) @@ -56,7 +59,21 @@ generate-documentation configuration->documentation empty-serializer - serialize-package)) + serialize-package + + filter-configuration-fields + + interpose + list-of + + list-of-strings? + alist? + string-or-gexp? + serialize-string-or-gexp + text-config? + serialize-text-config + generic-serialize-alist-entry + generic-serialize-alist)) ;;; Commentary: ;;; @@ -323,3 +340,71 @@ Texinfo documentation of its fields." '-fields)))) (display (generate-documentation `((,configuration-symbol ,fields-getter)) configuration-symbol)))) + +(define* (filter-configuration-fields configuration-fields fields + #:optional negate?) + "Retrieve the fields listed in FIELDS from CONFIGURATION-FIELDS. +If NEGATE? is @code{#t}, retrieve all fields except FIELDS." + (filter (lambda (field) + (let ((member? (member (configuration-field-name field) fields))) + (if (not negate?) member? (not member?)))) + configuration-fields)) + + +(define* (interpose ls #:optional (delimiter "\n") (grammar 'infix)) + "Same as @code{string-join}, but without join and string, returns an +DELIMITER interposed LS. Support 'infix and 'suffix GRAMMAR values." + (when (not (member grammar '(infix suffix))) + (raise + (formatted-message + (G_ "The GRAMMAR value must be 'infix or 'suffix, but ~a provided.") + grammar))) + (fold-right (lambda (e acc) + (cons e + (if (and (null? acc) (eq? grammar 'infix)) + acc + (cons delimiter acc)))) + '() ls)) + +(define (list-of pred?) + "Return a procedure that takes a list and check if all the elements of +the list result in @code{#t} when applying PRED? on them." + (lambda (x) + (if (list? x) + (every pred? x) + #f))) + + +(define list-of-strings? + (list-of string?)) + +(define alist? list?) + +(define (string-or-gexp? sg) (or (string? sg) (gexp? sg))) +(define (serialize-string-or-gexp field-name val) "") + +(define (text-config? config) + (and (list? config) (every string-or-gexp? config))) +(define (serialize-text-config field-name val) + #~(string-append #$@(interpose val "\n" 'suffix))) + +(define ((generic-serialize-alist-entry serialize-field) entry) + "Apply the SERIALIZE-FIELD procedure on the field and value of ENTRY." + (match entry + ((field . val) (serialize-field field val)))) + +(define (generic-serialize-alist combine serialize-field fields) + "Generate a configuration from an association list FIELDS. + +SERIALIZE-FIELD is a procedure that takes two arguments, it will be +applied on the fields and values of FIELDS using the +@code{generic-serialize-alist-entry} procedure. + +COMBINE is a procedure that takes one or more arguments and combines +all the alist entries into one value, @code{string-append} or +@code{append} are usually good candidates for this. + +See the @code{serialize-alist} procedure in `@code{(gnu home-services +version-control}' for an example usage.)}" + (apply combine + (map (generic-serialize-alist-entry serialize-field) fields))) -- 2.33.0 ^ permalink raw reply related [flat|nested] 64+ messages in thread
* [bug#50967] [PATCH 03/12] gnu: home-services: Move symlink-manager to (gnu services). 2021-10-02 13:45 ` [bug#50967] [PATCH 01/12] tests: Add tests for guix home cli Oleg Pykhalov 2021-10-02 13:45 ` [bug#50967] [PATCH 02/12] gnu: home-services: Move configuration to (gnu services) Oleg Pykhalov @ 2021-10-02 13:45 ` Oleg Pykhalov 2021-10-02 13:45 ` [bug#50967] [PATCH 04/12] gnu: home-services: Move utils " Oleg Pykhalov ` (8 subsequent siblings) 10 siblings, 0 replies; 64+ messages in thread From: Oleg Pykhalov @ 2021-10-02 13:45 UTC (permalink / raw) To: 50967; +Cc: Oleg Pykhalov * gnu/home-services/symlink-manager.scm: Rename to gnu/services/symlink-manager.scm. * gnu/local.mk: Same. * gnu/home.scm: Replace (gnu home-services symlink-manager) with (gnu services symlink-manager). --- gnu/home.scm | 2 +- gnu/local.mk | 2 +- gnu/{home-services => services}/symlink-manager.scm | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) rename gnu/{home-services => services}/symlink-manager.scm (99%) diff --git a/gnu/home.scm b/gnu/home.scm index f4c9359e25..9a25a20b6c 100644 --- a/gnu/home.scm +++ b/gnu/home.scm @@ -18,7 +18,7 @@ (define-module (gnu home) #:use-module (gnu home-services) - #:use-module (gnu home-services symlink-manager) + #:use-module (gnu services symlink-manager) #:use-module (gnu home-services shells) #:use-module (gnu home-services xdg) #:use-module (gnu home-services fontutils) diff --git a/gnu/local.mk b/gnu/local.mk index 0e1ff9f462..1c30763ff2 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -75,7 +75,6 @@ GNU_SYSTEM_MODULES = \ %D%/ci.scm \ %D%/home.scm \ %D%/home-services.scm \ - %D%/home-services/symlink-manager.scm \ %D%/home-services/fontutils.scm \ %D%/home-services/shells.scm \ %D%/home-services/shepherd.scm \ @@ -660,6 +659,7 @@ GNU_SYSTEM_MODULES = \ %D%/services/spice.scm \ %D%/services/ssh.scm \ %D%/services/syncthing.scm \ + %D%/services/symlink-manager.scm \ %D%/services/sysctl.scm \ %D%/services/telephony.scm \ %D%/services/version-control.scm \ diff --git a/gnu/home-services/symlink-manager.scm b/gnu/services/symlink-manager.scm similarity index 99% rename from gnu/home-services/symlink-manager.scm rename to gnu/services/symlink-manager.scm index 11f5d503d4..84adec8d44 100644 --- a/gnu/home-services/symlink-manager.scm +++ b/gnu/services/symlink-manager.scm @@ -17,7 +17,7 @@ ;;; 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 symlink-manager) +(define-module (gnu services symlink-manager) #:use-module (gnu home-services) #:use-module (guix gexp) -- 2.33.0 ^ permalink raw reply related [flat|nested] 64+ messages in thread
* [bug#50967] [PATCH 04/12] gnu: home-services: Move utils to (gnu services). 2021-10-02 13:45 ` [bug#50967] [PATCH 01/12] tests: Add tests for guix home cli Oleg Pykhalov 2021-10-02 13:45 ` [bug#50967] [PATCH 02/12] gnu: home-services: Move configuration to (gnu services) Oleg Pykhalov 2021-10-02 13:45 ` [bug#50967] [PATCH 03/12] gnu: home-services: Move symlink-manager " Oleg Pykhalov @ 2021-10-02 13:45 ` Oleg Pykhalov 2021-10-02 13:45 ` [bug#50967] [PATCH 05/12] gnu: home-services: Move fontutils " Oleg Pykhalov ` (7 subsequent siblings) 10 siblings, 0 replies; 64+ messages in thread From: Oleg Pykhalov @ 2021-10-02 13:45 UTC (permalink / raw) To: 50967; +Cc: Oleg Pykhalov * gnu/home-services/utils.scm: Rename to gnu/services/utils.scm. * gnu/local.mk: Same. * gnu/home-services/shells.scm: Replace (gnu home-services utils) with (gnu services utils) * gnu/home-services/xdg.scm: Same. --- gnu/home-services/shells.scm | 2 +- gnu/home-services/xdg.scm | 2 +- gnu/local.mk | 2 +- gnu/{home-services => services}/utils.scm | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) rename gnu/{home-services => services}/utils.scm (98%) diff --git a/gnu/home-services/shells.scm b/gnu/home-services/shells.scm index f9057cc8a2..377ff74542 100644 --- a/gnu/home-services/shells.scm +++ b/gnu/home-services/shells.scm @@ -20,7 +20,7 @@ (define-module (gnu home-services shells) #:use-module (gnu services configuration) #:use-module (gnu services configuration) - #:use-module (gnu home-services utils) + #:use-module (gnu services utils) #:use-module (gnu home-services) #:use-module (gnu packages shells) #:use-module (gnu packages bash) diff --git a/gnu/home-services/xdg.scm b/gnu/home-services/xdg.scm index efc1870c28..183bca630c 100644 --- a/gnu/home-services/xdg.scm +++ b/gnu/home-services/xdg.scm @@ -22,7 +22,7 @@ #:use-module (gnu services configuration) #:use-module (gnu home-services) #:use-module (gnu packages freedesktop) - #:use-module (gnu home-services utils) + #:use-module (gnu services utils) #:use-module (guix gexp) #:use-module (guix records) #:use-module (guix i18n) diff --git a/gnu/local.mk b/gnu/local.mk index 1c30763ff2..50f5e58fbc 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -79,7 +79,6 @@ GNU_SYSTEM_MODULES = \ %D%/home-services/shells.scm \ %D%/home-services/shepherd.scm \ %D%/home-services/mcron.scm \ - %D%/home-services/utils.scm \ %D%/home-services/xdg.scm \ %D%/image.scm \ %D%/packages.scm \ @@ -664,6 +663,7 @@ GNU_SYSTEM_MODULES = \ %D%/services/telephony.scm \ %D%/services/version-control.scm \ %D%/services/vpn.scm \ + %D%/services/utils.scm \ %D%/services/web.scm \ %D%/services/xorg.scm \ \ diff --git a/gnu/home-services/utils.scm b/gnu/services/utils.scm similarity index 98% rename from gnu/home-services/utils.scm rename to gnu/services/utils.scm index f13133a7ae..b95f2395c4 100644 --- a/gnu/home-services/utils.scm +++ b/gnu/services/utils.scm @@ -17,7 +17,7 @@ ;;; 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 utils) +(define-module (gnu services utils) #:use-module (ice-9 string-fun) #:use-module (srfi srfi-1) #:use-module (srfi srfi-26) -- 2.33.0 ^ permalink raw reply related [flat|nested] 64+ messages in thread
* [bug#50967] [PATCH 05/12] gnu: home-services: Move fontutils to (gnu services). 2021-10-02 13:45 ` [bug#50967] [PATCH 01/12] tests: Add tests for guix home cli Oleg Pykhalov ` (2 preceding siblings ...) 2021-10-02 13:45 ` [bug#50967] [PATCH 04/12] gnu: home-services: Move utils " Oleg Pykhalov @ 2021-10-02 13:45 ` Oleg Pykhalov 2021-10-02 13:45 ` [bug#50967] [PATCH 06/12] gnu: home-services: Move shells " Oleg Pykhalov ` (6 subsequent siblings) 10 siblings, 0 replies; 64+ messages in thread From: Oleg Pykhalov @ 2021-10-02 13:45 UTC (permalink / raw) To: 50967; +Cc: Oleg Pykhalov * gnu/home-services/fontutils.scm: Rename to gnu/services/fontutils.scm. * gnu/local.mk: Same. * gnu/home.scm: Replace (gnu home-services fontutils) with (gnu services fontutils). --- gnu/home.scm | 2 +- gnu/local.mk | 2 +- gnu/{home-services => services}/fontutils.scm | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) rename gnu/{home-services => services}/fontutils.scm (98%) diff --git a/gnu/home.scm b/gnu/home.scm index 9a25a20b6c..352f19ea06 100644 --- a/gnu/home.scm +++ b/gnu/home.scm @@ -21,7 +21,7 @@ #:use-module (gnu services symlink-manager) #:use-module (gnu home-services shells) #:use-module (gnu home-services xdg) - #:use-module (gnu home-services fontutils) + #:use-module (gnu services fontutils) #:use-module (gnu services) #:use-module (guix records) #:use-module (guix diagnostics) diff --git a/gnu/local.mk b/gnu/local.mk index 50f5e58fbc..5df35435e7 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -75,7 +75,6 @@ GNU_SYSTEM_MODULES = \ %D%/ci.scm \ %D%/home.scm \ %D%/home-services.scm \ - %D%/home-services/fontutils.scm \ %D%/home-services/shells.scm \ %D%/home-services/shepherd.scm \ %D%/home-services/mcron.scm \ @@ -630,6 +629,7 @@ GNU_SYSTEM_MODULES = \ %D%/services/docker.scm \ %D%/services/authentication.scm \ %D%/services/file-sharing.scm \ + %D%/services/fontutils.scm \ %D%/services/games.scm \ %D%/services/ganeti.scm \ %D%/services/getmail.scm \ diff --git a/gnu/home-services/fontutils.scm b/gnu/services/fontutils.scm similarity index 98% rename from gnu/home-services/fontutils.scm rename to gnu/services/fontutils.scm index 28bfc3d3f7..82c6048bb4 100644 --- a/gnu/home-services/fontutils.scm +++ b/gnu/services/fontutils.scm @@ -17,7 +17,7 @@ ;;; 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 fontutils) +(define-module (gnu services fontutils) #:use-module (gnu home-services) #:use-module (gnu packages fontutils) #:use-module (guix gexp) -- 2.33.0 ^ permalink raw reply related [flat|nested] 64+ messages in thread
* [bug#50967] [PATCH 06/12] gnu: home-services: Move shells to (gnu services). 2021-10-02 13:45 ` [bug#50967] [PATCH 01/12] tests: Add tests for guix home cli Oleg Pykhalov ` (3 preceding siblings ...) 2021-10-02 13:45 ` [bug#50967] [PATCH 05/12] gnu: home-services: Move fontutils " Oleg Pykhalov @ 2021-10-02 13:45 ` Oleg Pykhalov 2021-10-02 13:45 ` [bug#50967] [PATCH 07/12] gnu: home-services: Move xdg " Oleg Pykhalov ` (5 subsequent siblings) 10 siblings, 0 replies; 64+ messages in thread From: Oleg Pykhalov @ 2021-10-02 13:45 UTC (permalink / raw) To: 50967; +Cc: Oleg Pykhalov * gnu/home-services/shells.scm: Rename to gnu/services/shells.scm. * gnu/local.mk: Same. * gnu/home.scm: Replace (gnu home-services shells) with (gnu services shells). * doc/he-config-bare-bones.scm: Same. --- doc/he-config-bare-bones.scm | 2 +- gnu/home.scm | 2 +- gnu/local.mk | 2 +- gnu/{home-services => services}/shells.scm | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) rename gnu/{home-services => services}/shells.scm (99%) diff --git a/doc/he-config-bare-bones.scm b/doc/he-config-bare-bones.scm index 01be46a7b0..c6c5866a17 100644 --- a/doc/he-config-bare-bones.scm +++ b/doc/he-config-bare-bones.scm @@ -1,6 +1,6 @@ (use-modules (gnu home) (gnu home-services) - (gnu home-services shells) + (gnu services shells) (gnu services) (gnu packages admin) (guix gexp)) diff --git a/gnu/home.scm b/gnu/home.scm index 352f19ea06..a36b41daf9 100644 --- a/gnu/home.scm +++ b/gnu/home.scm @@ -19,7 +19,7 @@ (define-module (gnu home) #:use-module (gnu home-services) #:use-module (gnu services symlink-manager) - #:use-module (gnu home-services shells) + #:use-module (gnu services shells) #:use-module (gnu home-services xdg) #:use-module (gnu services fontutils) #:use-module (gnu services) diff --git a/gnu/local.mk b/gnu/local.mk index 5df35435e7..c549a96966 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -75,7 +75,6 @@ GNU_SYSTEM_MODULES = \ %D%/ci.scm \ %D%/home.scm \ %D%/home-services.scm \ - %D%/home-services/shells.scm \ %D%/home-services/shepherd.scm \ %D%/home-services/mcron.scm \ %D%/home-services/xdg.scm \ @@ -655,6 +654,7 @@ GNU_SYSTEM_MODULES = \ %D%/services/pm.scm \ %D%/services/rsync.scm \ %D%/services/sddm.scm \ + %D%/services/shells.scm \ %D%/services/spice.scm \ %D%/services/ssh.scm \ %D%/services/syncthing.scm \ diff --git a/gnu/home-services/shells.scm b/gnu/services/shells.scm similarity index 99% rename from gnu/home-services/shells.scm rename to gnu/services/shells.scm index 377ff74542..1e51fa99df 100644 --- a/gnu/home-services/shells.scm +++ b/gnu/services/shells.scm @@ -17,7 +17,7 @@ ;;; 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 shells) +(define-module (gnu services shells) #:use-module (gnu services configuration) #:use-module (gnu services configuration) #:use-module (gnu services utils) -- 2.33.0 ^ permalink raw reply related [flat|nested] 64+ messages in thread
* [bug#50967] [PATCH 07/12] gnu: home-services: Move xdg to (gnu services). 2021-10-02 13:45 ` [bug#50967] [PATCH 01/12] tests: Add tests for guix home cli Oleg Pykhalov ` (4 preceding siblings ...) 2021-10-02 13:45 ` [bug#50967] [PATCH 06/12] gnu: home-services: Move shells " Oleg Pykhalov @ 2021-10-02 13:45 ` Oleg Pykhalov 2021-10-02 13:45 ` [bug#50967] [PATCH 08/12] gnu: home-services: Move shepherd " Oleg Pykhalov ` (4 subsequent siblings) 10 siblings, 0 replies; 64+ messages in thread From: Oleg Pykhalov @ 2021-10-02 13:45 UTC (permalink / raw) To: 50967; +Cc: Oleg Pykhalov * gnu/home-services/xdg.scm: Rename to gnu/services/xdg.scm. * gnu/local.mk: Same. * gnu/home.scm: Replace (gnu home-services xdg) with (gnu services xdg). --- gnu/home.scm | 2 +- gnu/local.mk | 2 +- gnu/{home-services => services}/xdg.scm | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) rename gnu/{home-services => services}/xdg.scm (99%) diff --git a/gnu/home.scm b/gnu/home.scm index a36b41daf9..fc4193385e 100644 --- a/gnu/home.scm +++ b/gnu/home.scm @@ -20,7 +20,7 @@ #:use-module (gnu home-services) #:use-module (gnu services symlink-manager) #:use-module (gnu services shells) - #:use-module (gnu home-services xdg) + #:use-module (gnu services xdg) #:use-module (gnu services fontutils) #:use-module (gnu services) #:use-module (guix records) diff --git a/gnu/local.mk b/gnu/local.mk index c549a96966..97ff893bf7 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -77,7 +77,6 @@ GNU_SYSTEM_MODULES = \ %D%/home-services.scm \ %D%/home-services/shepherd.scm \ %D%/home-services/mcron.scm \ - %D%/home-services/xdg.scm \ %D%/image.scm \ %D%/packages.scm \ %D%/packages/abduco.scm \ @@ -665,6 +664,7 @@ GNU_SYSTEM_MODULES = \ %D%/services/vpn.scm \ %D%/services/utils.scm \ %D%/services/web.scm \ + %D%/services/xdg.scm \ %D%/services/xorg.scm \ \ %D%/system.scm \ diff --git a/gnu/home-services/xdg.scm b/gnu/services/xdg.scm similarity index 99% rename from gnu/home-services/xdg.scm rename to gnu/services/xdg.scm index 183bca630c..47e1751f75 100644 --- a/gnu/home-services/xdg.scm +++ b/gnu/services/xdg.scm @@ -17,7 +17,7 @@ ;;; 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 xdg) +(define-module (gnu services xdg) #:use-module (gnu services configuration) #:use-module (gnu services configuration) #:use-module (gnu home-services) -- 2.33.0 ^ permalink raw reply related [flat|nested] 64+ messages in thread
* [bug#50967] [PATCH 08/12] gnu: home-services: Move shepherd to (gnu services). 2021-10-02 13:45 ` [bug#50967] [PATCH 01/12] tests: Add tests for guix home cli Oleg Pykhalov ` (5 preceding siblings ...) 2021-10-02 13:45 ` [bug#50967] [PATCH 07/12] gnu: home-services: Move xdg " Oleg Pykhalov @ 2021-10-02 13:45 ` Oleg Pykhalov 2021-10-02 13:46 ` [bug#50967] [PATCH 09/12] gnu: home-services: Move mcron " Oleg Pykhalov ` (3 subsequent siblings) 10 siblings, 0 replies; 64+ messages in thread From: Oleg Pykhalov @ 2021-10-02 13:45 UTC (permalink / raw) To: 50967; +Cc: Oleg Pykhalov * gnu/home-services/shepherd.scm: Move content ... * gnu/services/shepherd.scm: ... here. * gnu/local.mk: Delete gnu/home-services/shepherd.scm. * gnu/home-services/mcron.scm: Replace (gnu home-services shepherd) with (gnu services shepherd). * tests/guix-home.sh: Same. --- gnu/home-services/mcron.scm | 2 +- gnu/home-services/shepherd.scm | 134 --------------------------------- gnu/local.mk | 1 - gnu/services/shepherd.scm | 112 ++++++++++++++++++++++++++- tests/guix-home.sh | 2 +- 5 files changed, 113 insertions(+), 138 deletions(-) delete mode 100644 gnu/home-services/shepherd.scm diff --git a/gnu/home-services/mcron.scm b/gnu/home-services/mcron.scm index fdfde179a5..a4e09f509c 100644 --- a/gnu/home-services/mcron.scm +++ b/gnu/home-services/mcron.scm @@ -20,7 +20,7 @@ (define-module (gnu home-services mcron) #:use-module (gnu packages guile-xyz) #:use-module (gnu home-services) - #:use-module (gnu home-services shepherd) + #:use-module (gnu services shepherd) #:use-module (gnu services shepherd) #:use-module (guix records) #:use-module (guix gexp) diff --git a/gnu/home-services/shepherd.scm b/gnu/home-services/shepherd.scm deleted file mode 100644 index 120cfde1a1..0000000000 --- a/gnu/home-services/shepherd.scm +++ /dev/null @@ -1,134 +0,0 @@ -;;; 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 shepherd) - #:use-module (gnu home-services) - #:use-module (gnu packages admin) - #:use-module (gnu services shepherd) - #:use-module (guix sets) - #:use-module (guix gexp) - #:use-module (guix records) - - #:use-module (srfi srfi-1) - - #:export (home-shepherd-service-type - home-shepherd-configuration) - #:re-export (shepherd-service - shepherd-action)) - -(define-record-type* <home-shepherd-configuration> - home-shepherd-configuration make-home-shepherd-configuration - home-shepherd-configuration? - (shepherd home-shepherd-configuration-shepherd - (default shepherd)) ; package - (auto-start? home-shepherd-configuration-auto-start? - (default #t)) - (services home-shepherd-configuration-services - (default '()))) - -(define (home-shepherd-configuration-file services shepherd) - "Return the shepherd configuration file for SERVICES. SHEPHERD is used -as shepherd package." - (assert-valid-graph services) - - (let ((files (map shepherd-service-file services)) - ;; TODO: Add compilation of services, it can improve start - ;; time. - ;; (scm->go (cute scm->go <> shepherd)) - ) - (define config - #~(begin - (use-modules (srfi srfi-34) - (system repl error-handling)) - (apply - register-services - (map - (lambda (file) (load file)) - '#$files)) - (action 'root 'daemonize) - (format #t "Starting services...~%") - (for-each - (lambda (service) (start service)) - '#$(append-map shepherd-service-provision - (filter shepherd-service-auto-start? - services))) - (newline))) - - (scheme-file "shepherd.conf" config))) - -(define (launch-shepherd-gexp config) - (let* ((shepherd (home-shepherd-configuration-shepherd config)) - (services (home-shepherd-configuration-services config))) - (if (home-shepherd-configuration-auto-start? config) - (with-imported-modules '((guix build utils)) - #~(let ((log-dir (or (getenv "XDG_LOG_HOME") - (format #f "~a/.local/var/log" (getenv "HOME"))))) - ((@ (guix build utils) mkdir-p) log-dir) - (system* - #$(file-append shepherd "/bin/shepherd") - "--logfile" - (string-append - log-dir - "/shepherd.log") - "--config" - #$(home-shepherd-configuration-file services shepherd)))) - #~""))) - -(define (reload-configuration-gexp config) - (let* ((shepherd (home-shepherd-configuration-shepherd config)) - (services (home-shepherd-configuration-services config))) - #~(system* - #$(file-append shepherd "/bin/herd") - "load" "root" - #$(home-shepherd-configuration-file services shepherd)))) - -(define (ensure-shepherd-gexp config) - #~(if (file-exists? - (string-append - (or (getenv "XDG_RUNTIME_DIR") - (format #f "/run/user/~a" (getuid))) - "/shepherd/socket")) - #$(reload-configuration-gexp config) - #$(launch-shepherd-gexp config))) - -(define-public home-shepherd-service-type - (service-type (name 'home-shepherd) - (extensions - (list (service-extension - home-run-on-first-login-service-type - launch-shepherd-gexp) - (service-extension - home-activation-service-type - ensure-shepherd-gexp) - (service-extension - home-profile-service-type - (lambda (config) - `(,(home-shepherd-configuration-shepherd config)))))) - (compose concatenate) - (extend - (lambda (config extra-services) - (home-shepherd-configuration - (inherit config) - (services - (append (home-shepherd-configuration-services config) - extra-services))))) - (default-value (home-shepherd-configuration)) - (description "Configure and install userland Shepherd."))) - - diff --git a/gnu/local.mk b/gnu/local.mk index 97ff893bf7..fb60e6492e 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -75,7 +75,6 @@ GNU_SYSTEM_MODULES = \ %D%/ci.scm \ %D%/home.scm \ %D%/home-services.scm \ - %D%/home-services/shepherd.scm \ %D%/home-services/mcron.scm \ %D%/image.scm \ %D%/packages.scm \ diff --git a/gnu/services/shepherd.scm b/gnu/services/shepherd.scm index 7277273686..46c80472dc 100644 --- a/gnu/services/shepherd.scm +++ b/gnu/services/shepherd.scm @@ -4,6 +4,8 @@ ;;; Copyright © 2018 Carlo Zancanaro <carlo@zancanaro.id.au> ;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org> ;;; Copyright © 2021 Maxime Devos <maximedevos@telenet.be> +;;; Copyright © 2021 Andrew Tropin <andrew@trop.in> +;;; Copyright © 2021 Xinglu Chen <public@yoctocell.xyz> ;;; ;;; This file is part of GNU Guix. ;;; @@ -28,6 +30,7 @@ #:use-module (guix records) #:use-module (guix derivations) ;imported-modules, etc. #:use-module (guix utils) + #:use-module (gnu home-services) #:use-module (gnu services) #:use-module (gnu services herd) #:use-module (gnu packages admin) @@ -75,7 +78,10 @@ user-processes-service-type - assert-valid-graph)) + assert-valid-graph + + home-shepherd-service-type + home-shepherd-configuration)) ;;; Commentary: ;;; @@ -590,4 +596,108 @@ read-only, just before rebooting/halting. Processes still running after a few seconds after @code{SIGTERM} has been sent are terminated with @code{SIGKILL}."))) +\f +;;; +;;; Home services +;;; + +(define-record-type* <home-shepherd-configuration> + home-shepherd-configuration make-home-shepherd-configuration + home-shepherd-configuration? + (shepherd home-shepherd-configuration-shepherd + (default shepherd)) ; package + (auto-start? home-shepherd-configuration-auto-start? + (default #t)) + (services home-shepherd-configuration-services + (default '()))) + +(define (home-shepherd-configuration-file services shepherd) + "Return the shepherd configuration file for SERVICES. SHEPHERD is used +as shepherd package." + (assert-valid-graph services) + + (let ((files (map shepherd-service-file services)) + ;; TODO: Add compilation of services, it can improve start + ;; time. + ;; (scm->go (cute scm->go <> shepherd)) + ) + (define config + #~(begin + (use-modules (srfi srfi-34) + (system repl error-handling)) + (apply + register-services + (map + (lambda (file) (load file)) + '#$files)) + (action 'root 'daemonize) + (format #t "Starting services...~%") + (for-each + (lambda (service) (start service)) + '#$(append-map shepherd-service-provision + (filter shepherd-service-auto-start? + services))) + (newline))) + + (scheme-file "shepherd.conf" config))) + +(define (launch-shepherd-gexp config) + (let* ((shepherd (home-shepherd-configuration-shepherd config)) + (services (home-shepherd-configuration-services config))) + (if (home-shepherd-configuration-auto-start? config) + (with-imported-modules '((guix build utils)) + #~(let ((log-dir (or (getenv "XDG_LOG_HOME") + (format #f "~a/.local/var/log" (getenv "HOME"))))) + ((@ (guix build utils) mkdir-p) log-dir) + (system* + #$(file-append shepherd "/bin/shepherd") + "--logfile" + (string-append + log-dir + "/shepherd.log") + "--config" + #$(home-shepherd-configuration-file services shepherd)))) + #~""))) + +(define (reload-configuration-gexp config) + (let* ((shepherd (home-shepherd-configuration-shepherd config)) + (services (home-shepherd-configuration-services config))) + #~(system* + #$(file-append shepherd "/bin/herd") + "load" "root" + #$(home-shepherd-configuration-file services shepherd)))) + +(define (ensure-shepherd-gexp config) + #~(if (file-exists? + (string-append + (or (getenv "XDG_RUNTIME_DIR") + (format #f "/run/user/~a" (getuid))) + "/shepherd/socket")) + #$(reload-configuration-gexp config) + #$(launch-shepherd-gexp config))) + +(define-public home-shepherd-service-type + (service-type (name 'home-shepherd) + (extensions + (list (service-extension + home-run-on-first-login-service-type + launch-shepherd-gexp) + (service-extension + home-activation-service-type + ensure-shepherd-gexp) + (service-extension + home-profile-service-type + (lambda (config) + `(,(home-shepherd-configuration-shepherd config)))))) + (compose concatenate) + (extend + (lambda (config extra-services) + (home-shepherd-configuration + (inherit config) + (services + (append (home-shepherd-configuration-services config) + extra-services))))) + (default-value (home-shepherd-configuration)) + (description "Configure and install userland Shepherd."))) + ;;; shepherd.scm ends here diff --git a/tests/guix-home.sh b/tests/guix-home.sh index cb015c907f..46cd779c81 100644 --- a/tests/guix-home.sh +++ b/tests/guix-home.sh @@ -75,7 +75,7 @@ fi cat > "$tmpfile" <<EOF (use-modules (gnu)) -(use-modules (gnu home-services shepherd)) +(use-modules (gnu services shepherd)) (home-environment (services (list (service home-shepherd-service-type) -- 2.33.0 ^ permalink raw reply related [flat|nested] 64+ messages in thread
* [bug#50967] [PATCH 09/12] gnu: home-services: Move mcron to (gnu services). 2021-10-02 13:45 ` [bug#50967] [PATCH 01/12] tests: Add tests for guix home cli Oleg Pykhalov ` (6 preceding siblings ...) 2021-10-02 13:45 ` [bug#50967] [PATCH 08/12] gnu: home-services: Move shepherd " Oleg Pykhalov @ 2021-10-02 13:46 ` Oleg Pykhalov 2021-10-02 13:46 ` [bug#50967] [PATCH 10/12] gnu: home-services: Change %service-type-path and filter services Oleg Pykhalov ` (2 subsequent siblings) 10 siblings, 0 replies; 64+ messages in thread From: Oleg Pykhalov @ 2021-10-02 13:46 UTC (permalink / raw) To: 50967; +Cc: Oleg Pykhalov * gnu/home-services/mcron.scm: Move content without delete job-files and shepherd-schedule-action ... * gnu/services/mcron.scm: ... here. * gnu/local.mk: Delete gnu/home-services/mcron.scm. * doc/guix.texi: Replace (gnu home-services mcron) with (gnu services mcron). --- doc/guix.texi | 2 +- gnu/home-services/mcron.scm | 115 ------------------------------------ gnu/local.mk | 1 - gnu/services/mcron.scm | 89 +++++++++++++++++++++++++++- 4 files changed, 89 insertions(+), 118 deletions(-) delete mode 100644 gnu/home-services/mcron.scm diff --git a/doc/guix.texi b/doc/guix.texi index a72a726b54..d06590ab8c 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -35810,7 +35810,7 @@ for example). @cindex mcron @cindex scheduling jobs -The @code{(gnu home-services mcron)} module provides an interface to +The @code{(gnu services mcron)} module provides an interface to GNU@tie{}mcron, a daemon to run jobs at scheduled times (@pxref{Top,,, mcron, GNU@tie{}mcron}). The information about system's mcron is applicable here (@pxref{Scheduled Job Execution}), the only difference diff --git a/gnu/home-services/mcron.scm b/gnu/home-services/mcron.scm deleted file mode 100644 index a4e09f509c..0000000000 --- a/gnu/home-services/mcron.scm +++ /dev/null @@ -1,115 +0,0 @@ -;;; 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 mcron) - #:use-module (gnu packages guile-xyz) - #:use-module (gnu home-services) - #:use-module (gnu services shepherd) - #:use-module (gnu services shepherd) - #:use-module (guix records) - #:use-module (guix gexp) - #:use-module (srfi srfi-1) - #:use-module (ice-9 match) - - #:export (home-mcron-configuration - home-mcron-service-type)) - -;;; Commentary: -;; -;; Service for the GNU mcron cron job manager. -;; -;; Example configuration, the first job runs mbsync once every ten -;; minutes, the second one writes "Mcron service" to ~/mcron-file once -;; every minute. -;; -;; (service home-mcron-service-type -;; (home-mcron-configuration -;; (jobs (list #~(job '(next-minute -;; (range 0 60 10)) -;; (lambda () -;; (system* "mbsync" "--all"))) -;; #~(job next-minute-from -;; (lambda () -;; (call-with-output-file (string-append (getenv "HOME") -;; "/mcron-file") -;; (lambda (port) -;; (display "Mcron service" port))))))))) -;; -;;; Code: - -(define-record-type* <home-mcron-configuration> home-mcron-configuration - make-home-mcron-configuration - home-mcron-configuration? - (package home-mcron-configuration-package ; package - (default mcron)) - (jobs home-mcron-configuration-jobs ; list of jobs - (default '()))) - -(define job-files (@@ (gnu services mcron) job-files)) -(define shepherd-schedule-action - (@@ (gnu services mcron) shepherd-schedule-action)) - -(define home-mcron-shepherd-services - (match-lambda - (($ <home-mcron-configuration> mcron '()) ; no jobs to run - '()) - (($ <home-mcron-configuration> mcron jobs) - (let ((files (job-files mcron jobs))) - (list (shepherd-service - (documentation "User cron jobs.") - (provision '(mcron)) - (modules `((srfi srfi-1) - (srfi srfi-26) - (ice-9 popen) ; for the 'schedule' action - (ice-9 rdelim) - (ice-9 match) - ,@%default-modules)) - (start #~(make-forkexec-constructor - (list #$(file-append mcron "/bin/mcron") #$@files) - #:log-file (string-append - (or (getenv "XDG_LOG_HOME") - (format #f "~a/.local/var/log" - (getenv "HOME"))) - "/mcron.log"))) - (stop #~(make-kill-destructor)) - (actions - (list (shepherd-schedule-action mcron files))))))))) - -(define home-mcron-profile (compose list home-mcron-configuration-package)) - -(define (home-mcron-extend config jobs) - (home-mcron-configuration - (inherit config) - (jobs (append (home-mcron-configuration-jobs config) - jobs)))) - -(define home-mcron-service-type - (service-type (name 'home-mcron) - (extensions - (list (service-extension - home-shepherd-service-type - home-mcron-shepherd-services) - (service-extension - home-profile-service-type - home-mcron-profile))) - (compose concatenate) - (extend home-mcron-extend) - (default-value (home-mcron-configuration)) - (description - "Install and configure the GNU mcron cron job manager."))) diff --git a/gnu/local.mk b/gnu/local.mk index fb60e6492e..ca4c15ba25 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -75,7 +75,6 @@ GNU_SYSTEM_MODULES = \ %D%/ci.scm \ %D%/home.scm \ %D%/home-services.scm \ - %D%/home-services/mcron.scm \ %D%/image.scm \ %D%/packages.scm \ %D%/packages/abduco.scm \ diff --git a/gnu/services/mcron.scm b/gnu/services/mcron.scm index 0e675607f3..79639caee4 100644 --- a/gnu/services/mcron.scm +++ b/gnu/services/mcron.scm @@ -1,5 +1,7 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2016, 2017, 2018, 2019, 2020 Ludovic Courtès <ludo@gnu.org> +;;; Copyright © 2021 Andrew Tropin <andrew@trop.in> +;;; Copyright © 2021 Xinglu Chen <public@yoctocell.xyz> ;;; ;;; This file is part of GNU Guix. ;;; @@ -19,6 +21,7 @@ (define-module (gnu services mcron) #:use-module (gnu services) #:use-module (gnu services shepherd) + #:use-module (gnu home-services) #:use-module (gnu packages guile-xyz) #:use-module (guix deprecation) #:use-module (guix records) @@ -31,7 +34,10 @@ mcron-configuration-mcron mcron-configuration-jobs - mcron-service-type)) + mcron-service-type + + home-mcron-configuration + home-mcron-service-type)) ;;; Commentary: ;;; @@ -172,4 +178,85 @@ files." jobs))))) (default-value (mcron-configuration)))) ;empty job list +\f +;;; +;;; Home services +;;; + +;; Service for the GNU mcron cron job manager. +;; +;; Example configuration, the first job runs mbsync once every ten +;; minutes, the second one writes "Mcron service" to ~/mcron-file once +;; every minute. +;; +;; (service home-mcron-service-type +;; (home-mcron-configuration +;; (jobs (list #~(job '(next-minute +;; (range 0 60 10)) +;; (lambda () +;; (system* "mbsync" "--all"))) +;; #~(job next-minute-from +;; (lambda () +;; (call-with-output-file (string-append (getenv "HOME") +;; "/mcron-file") +;; (lambda (port) +;; (display "Mcron service" port))))))))) + +(define-record-type* <home-mcron-configuration> home-mcron-configuration + make-home-mcron-configuration + home-mcron-configuration? + (package home-mcron-configuration-package ; package + (default mcron)) + (jobs home-mcron-configuration-jobs ; list of jobs + (default '()))) + +(define home-mcron-shepherd-services + (match-lambda + (($ <home-mcron-configuration> mcron '()) ; no jobs to run + '()) + (($ <home-mcron-configuration> mcron jobs) + (let ((files (job-files mcron jobs))) + (list (shepherd-service + (documentation "User cron jobs.") + (provision '(mcron)) + (modules `((srfi srfi-1) + (srfi srfi-26) + (ice-9 popen) ; for the 'schedule' action + (ice-9 rdelim) + (ice-9 match) + ,@%default-modules)) + (start #~(make-forkexec-constructor + (list #$(file-append mcron "/bin/mcron") #$@files) + #:log-file (string-append + (or (getenv "XDG_LOG_HOME") + (format #f "~a/.local/var/log" + (getenv "HOME"))) + "/mcron.log"))) + (stop #~(make-kill-destructor)) + (actions + (list (shepherd-schedule-action mcron files))))))))) + +(define home-mcron-profile (compose list home-mcron-configuration-package)) + +(define (home-mcron-extend config jobs) + (home-mcron-configuration + (inherit config) + (jobs (append (home-mcron-configuration-jobs config) + jobs)))) + +(define home-mcron-service-type + (service-type (name 'home-mcron) + (extensions + (list (service-extension + home-shepherd-service-type + home-mcron-shepherd-services) + (service-extension + home-profile-service-type + home-mcron-profile))) + (compose concatenate) + (extend home-mcron-extend) + (default-value (home-mcron-configuration)) + (description + "Install and configure the GNU mcron cron job manager."))) + ;;; mcron.scm ends here -- 2.33.0 ^ permalink raw reply related [flat|nested] 64+ messages in thread
* [bug#50967] [PATCH 10/12] gnu: home-services: Change %service-type-path and filter services. 2021-10-02 13:45 ` [bug#50967] [PATCH 01/12] tests: Add tests for guix home cli Oleg Pykhalov ` (7 preceding siblings ...) 2021-10-02 13:46 ` [bug#50967] [PATCH 09/12] gnu: home-services: Move mcron " Oleg Pykhalov @ 2021-10-02 13:46 ` Oleg Pykhalov 2021-10-02 13:46 ` [bug#50967] [PATCH 11/12] scripts: home: (gnu home-services bash) -> (gnu services bash) Oleg Pykhalov 2021-10-02 13:46 ` [bug#50967] [PATCH 12/12] doc: (gnu home-services) -> (gnu services) Oleg Pykhalov 10 siblings, 0 replies; 64+ messages in thread From: Oleg Pykhalov @ 2021-10-02 13:46 UTC (permalink / raw) To: 50967; +Cc: Oleg Pykhalov * gnu/home-services.scm (%service-type-path): Search home services in "gnu/services". * gnu/home-services.scm (fold-home-service-types): Filter home services. --- gnu/home-services.scm | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/gnu/home-services.scm b/gnu/home-services.scm index 9f1e986616..bc4b857715 100644 --- a/gnu/home-services.scm +++ b/gnu/home-services.scm @@ -512,7 +512,7 @@ environment, and its configuration file, when available."))) (define %service-type-path ;; Search path for service types. - (make-parameter `((,%guix-home-root-directory . "gnu/home-services")))) + (make-parameter `((,%guix-home-root-directory . "gnu/services")))) (define (all-home-service-modules) "Return the default set of home-service modules." @@ -521,4 +521,9 @@ environment, and its configuration file, when available."))) #:warn warn-about-load-error))) (define* (fold-home-service-types proc seed) - (fold-service-types proc seed (all-home-service-modules))) + (filter (match-lambda + ((service-type . _) + (string-prefix? "home-" + (symbol->string + (service-type-name service-type))))) + (fold-service-types proc seed (all-home-service-modules)))) -- 2.33.0 ^ permalink raw reply related [flat|nested] 64+ messages in thread
* [bug#50967] [PATCH 11/12] scripts: home: (gnu home-services bash) -> (gnu services bash). 2021-10-02 13:45 ` [bug#50967] [PATCH 01/12] tests: Add tests for guix home cli Oleg Pykhalov ` (8 preceding siblings ...) 2021-10-02 13:46 ` [bug#50967] [PATCH 10/12] gnu: home-services: Change %service-type-path and filter services Oleg Pykhalov @ 2021-10-02 13:46 ` Oleg Pykhalov 2021-10-02 13:46 ` [bug#50967] [PATCH 12/12] doc: (gnu home-services) -> (gnu services) Oleg Pykhalov 10 siblings, 0 replies; 64+ messages in thread From: Oleg Pykhalov @ 2021-10-02 13:46 UTC (permalink / raw) To: 50967; +Cc: Oleg Pykhalov * guix/scripts/home/import.scm: Replace (gnu home-services bash) with (gnu services bash). --- guix/scripts/home/import.scm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/guix/scripts/home/import.scm b/guix/scripts/home/import.scm index 79fb23a2fd..98dcdea388 100644 --- a/guix/scripts/home/import.scm +++ b/guix/scripts/home/import.scm @@ -41,7 +41,7 @@ (let ((rc (string-append (getenv "HOME") "/.bashrc")) (profile (string-append (getenv "HOME") "/.bash_profile")) (logout (string-append (getenv "HOME") "/.bash_logout"))) - `((gnu home-services bash) + `((gnu services bash) (service home-bash-service-type (home-bash-configuration ,@(if (file-exists? rc) -- 2.33.0 ^ permalink raw reply related [flat|nested] 64+ messages in thread
* [bug#50967] [PATCH 12/12] doc: (gnu home-services) -> (gnu services). 2021-10-02 13:45 ` [bug#50967] [PATCH 01/12] tests: Add tests for guix home cli Oleg Pykhalov ` (9 preceding siblings ...) 2021-10-02 13:46 ` [bug#50967] [PATCH 11/12] scripts: home: (gnu home-services bash) -> (gnu services bash) Oleg Pykhalov @ 2021-10-02 13:46 ` Oleg Pykhalov 10 siblings, 0 replies; 64+ messages in thread From: Oleg Pykhalov @ 2021-10-02 13:46 UTC (permalink / raw) To: 50967; +Cc: Oleg Pykhalov * doc/guix.texi: Replace (gnu home-services) with (gnu services). --- doc/guix.texi | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index d06590ab8c..a647ea150a 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -35555,9 +35555,9 @@ services)}. @node Essential Home Services @subsection Essential Home Services -There are a few essential services defined in @code{(gnu -home-services)}, they are mostly for internal use and are required to -build a home environment, but some of them will be useful for the end +There are a few essential home services defined in +@code{(gnu services)}, they are mostly for internal use and are required +to build a home environment, but some of them will be useful for the end user. @cindex environment variables -- 2.33.0 ^ permalink raw reply related [flat|nested] 64+ messages in thread
* [bug#50967] [PATCH 01/14] tests: Add tests for guix home cli. 2021-10-02 13:43 [bug#50967] [PATCH 00/12] Move (gnu home-services XYZ) to (gnu services XYZ) Oleg Pykhalov 2021-10-02 13:45 ` [bug#50967] [PATCH 01/12] tests: Add tests for guix home cli Oleg Pykhalov @ 2021-10-02 16:38 ` Oleg Pykhalov 2021-10-02 16:38 ` [bug#50967] [PATCH 02/14] gnu: home-services: Move configuration to (gnu home services) Oleg Pykhalov ` (13 more replies) 2021-10-02 20:13 ` [bug#50967] [PATCH] home: services: configuration: Move and refactor content Oleg Pykhalov 2 siblings, 14 replies; 64+ messages in thread From: Oleg Pykhalov @ 2021-10-02 16:38 UTC (permalink / raw) To: 50967; +Cc: Oleg Pykhalov, Andrew Tropin From: Andrew Tropin <andrew@trop.in> * tests/guix-home.sh: New file. * Makefile.am (SH_TESTS): Add tests/guix-home.sh. Signed-off-by: Oleg Pykhalov <go.wigust@gmail.com> --- Makefile.am | 1 + tests/guix-home.sh | 99 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 100 insertions(+) create mode 100644 tests/guix-home.sh diff --git a/Makefile.am b/Makefile.am index b66789fa0b..5bf2567dc8 100644 --- a/Makefile.am +++ b/Makefile.am @@ -546,6 +546,7 @@ SH_TESTS = \ tests/guix-package-aliases.sh \ tests/guix-package-net.sh \ tests/guix-system.sh \ + tests/guix-home.sh \ tests/guix-archive.sh \ tests/guix-authenticate.sh \ tests/guix-environment.sh \ diff --git a/tests/guix-home.sh b/tests/guix-home.sh new file mode 100644 index 0000000000..cb015c907f --- /dev/null +++ b/tests/guix-home.sh @@ -0,0 +1,99 @@ +# GNU Guix --- Functional package management for GNU +# Copyright © 2021 Andrew Tropin <andrew@trop.in> +# +# This file is part of GNU Guix. +# +# GNU Guix is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or (at +# your option) any later version. +# +# GNU Guix is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. + +# +# Test 'guix home' cli. +# + +set -e + +guix home --version + +tmpfile="t-guix-home-$$" +errorfile="t-guix-home-error-$$" + +# Note: This directory is chosen outside $builddir so that relative file name +# canonicalization doesn't mess up with 'current-source-directory', used by +# 'local-file' ('load' forces 'relative' for +# %FILE-PORT-NAME-CANONICALIZATION.) +tmpdir="${TMPDIR:-/tmp}/t-guix-home-$$" +mkdir "$tmpdir" + +trap 'rm -f "$tmpfile" "$errorfile" "$tmpdir"/*; rmdir "$tmpdir"' EXIT + +# Reporting of syntax errors. + +cat > "$tmpfile"<<EOF +;; This is line 1, and the next one is line 2. + (home-environment + (packages)) +;; The 'T' is at column 3. +EOF + +if guix home build "$tmpfile" 2> "$errorfile" +then + # This must not succeed. + exit 1 +else + grep "$tmpfile:3:4: error: (packages): invalid field specifier" "$errorfile" +fi + + +cat > "$tmpfile"<<EOF +;; This is line 1, and the next one is line 2. + (home-environment +;; This is line 3, and there is no closing paren! +EOF + +if guix home build "$tmpfile" 2> "$errorfile" +then + # This must not succeed. + exit 1 +else + # Guile 3.0.6 gets line/column numbers for 'read-error' wrong + # (zero-indexed): <https://bugs.gnu.org/48089>. + grep "$tmpfile:4:1: missing closing paren" "$errorfile" || \ + grep "$tmpfile:3:0: missing closing paren" "$errorfile" +fi + +# Reporting of duplicate system service declaration. + +cat > "$tmpfile" <<EOF +(use-modules (gnu)) +(use-modules (gnu home-services shepherd)) + +(home-environment + (services (list (service home-shepherd-service-type) + (simple-service 'test-shepherd-extension + home-shepherd-service-type '()) + (service home-shepherd-service-type) + (service home-shepherd-service-type)))) +EOF + +if guix home build "$tmpfile" 2> "$errorfile" +then + # This must not succeed. + exit 1 +else + grep "guix home: error: more than one target service of type 'home-shepherd'" "$errorfile" +fi + +# Searching. + +guix home search mcron | grep "^name: home-mcron" +guix home search job manager | grep "^name: home-mcron" -- 2.33.0 ^ permalink raw reply related [flat|nested] 64+ messages in thread
* [bug#50967] [PATCH 02/14] gnu: home-services: Move configuration to (gnu home services). 2021-10-02 16:38 ` [bug#50967] [PATCH 01/14] tests: Add tests for guix home cli Oleg Pykhalov @ 2021-10-02 16:38 ` Oleg Pykhalov 2021-10-02 18:37 ` Xinglu Chen 2021-10-02 16:38 ` [bug#50967] [PATCH 03/14] gnu: home-services: Move symlink-manager " Oleg Pykhalov ` (12 subsequent siblings) 13 siblings, 1 reply; 64+ messages in thread From: Oleg Pykhalov @ 2021-10-02 16:38 UTC (permalink / raw) To: 50967; +Cc: Oleg Pykhalov * gnu/home-services/configuration.scm: Move the content ... * gnu/home/services/configuration.scm: ... here. * gnu/local.mk (GNU_SYSTEM_MODULES): Same. * gnu/home-services/shells.scm: Replace (gnu home-services configuration) with (gnu home services configuration). * gnu/home-services/xdg.scm: Same. --- gnu/home-services/shells.scm | 2 +- gnu/home-services/xdg.scm | 2 +- gnu/{home-services => home/services}/configuration.scm | 2 +- gnu/local.mk | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) rename gnu/{home-services => home/services}/configuration.scm (98%) diff --git a/gnu/home-services/shells.scm b/gnu/home-services/shells.scm index ecb02098f7..2be35ac56e 100644 --- a/gnu/home-services/shells.scm +++ b/gnu/home-services/shells.scm @@ -19,7 +19,7 @@ (define-module (gnu home-services shells) #:use-module (gnu services configuration) - #:use-module (gnu home-services configuration) + #:use-module (gnu home services configuration) #:use-module (gnu home-services utils) #:use-module (gnu home-services) #:use-module (gnu packages shells) diff --git a/gnu/home-services/xdg.scm b/gnu/home-services/xdg.scm index 94275f3b65..07b25e9e12 100644 --- a/gnu/home-services/xdg.scm +++ b/gnu/home-services/xdg.scm @@ -19,7 +19,7 @@ (define-module (gnu home-services xdg) #:use-module (gnu services configuration) - #:use-module (gnu home-services configuration) + #:use-module (gnu home services configuration) #:use-module (gnu home-services) #:use-module (gnu packages freedesktop) #:use-module (gnu home-services utils) diff --git a/gnu/home-services/configuration.scm b/gnu/home/services/configuration.scm similarity index 98% rename from gnu/home-services/configuration.scm rename to gnu/home/services/configuration.scm index e8f4bc77ec..5e7743e7d6 100644 --- a/gnu/home-services/configuration.scm +++ b/gnu/home/services/configuration.scm @@ -17,7 +17,7 @@ ;;; 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 configuration) +(define-module (gnu home services configuration) #:use-module (gnu services configuration) #:use-module (guix gexp) #:use-module (srfi srfi-1) diff --git a/gnu/local.mk b/gnu/local.mk index d415b892e9..ac0b8947d5 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -77,7 +77,7 @@ GNU_SYSTEM_MODULES = \ %D%/home-services.scm \ %D%/home-services/symlink-manager.scm \ %D%/home-services/fontutils.scm \ - %D%/home-services/configuration.scm \ + %D%/home/services/configuration.scm \ %D%/home-services/shells.scm \ %D%/home-services/shepherd.scm \ %D%/home-services/mcron.scm \ -- 2.33.0 ^ permalink raw reply related [flat|nested] 64+ messages in thread
* [bug#50967] [PATCH 02/14] gnu: home-services: Move configuration to (gnu home services). 2021-10-02 16:38 ` [bug#50967] [PATCH 02/14] gnu: home-services: Move configuration to (gnu home services) Oleg Pykhalov @ 2021-10-02 18:37 ` Xinglu Chen 0 siblings, 0 replies; 64+ messages in thread From: Xinglu Chen @ 2021-10-02 18:37 UTC (permalink / raw) To: Oleg Pykhalov, 50967; +Cc: Oleg Pykhalov [-- Attachment #1: Type: text/plain, Size: 819 bytes --] On Sat, Oct 02 2021, Oleg Pykhalov wrote: > * gnu/home-services/configuration.scm: Move the content ... > * gnu/home/services/configuration.scm: ... here. > * gnu/local.mk (GNU_SYSTEM_MODULES): Same. > * gnu/home-services/shells.scm: Replace (gnu home-services configuration) > with (gnu home services configuration). > * gnu/home-services/xdg.scm: Same. > --- > gnu/home-services/shells.scm | 2 +- > gnu/home-services/xdg.scm | 2 +- > gnu/{home-services => home/services}/configuration.scm | 2 +- > gnu/local.mk | 2 +- I think it makes more sense to move (gnu home-services configuration) to (gnu services configuration) since none of the things in (gnu home-services configuration) seem specific to home services. [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 861 bytes --] ^ permalink raw reply [flat|nested] 64+ messages in thread
* [bug#50967] [PATCH 03/14] gnu: home-services: Move symlink-manager to (gnu home services). 2021-10-02 16:38 ` [bug#50967] [PATCH 01/14] tests: Add tests for guix home cli Oleg Pykhalov 2021-10-02 16:38 ` [bug#50967] [PATCH 02/14] gnu: home-services: Move configuration to (gnu home services) Oleg Pykhalov @ 2021-10-02 16:38 ` Oleg Pykhalov 2021-10-02 16:38 ` [bug#50967] [PATCH 04/14] gnu: home-services: Move utils " Oleg Pykhalov ` (11 subsequent siblings) 13 siblings, 0 replies; 64+ messages in thread From: Oleg Pykhalov @ 2021-10-02 16:38 UTC (permalink / raw) To: 50967; +Cc: Oleg Pykhalov * gnu/home-services/symlink-manager.scm: Rename to gnu/home/services/symlink-manager.scm. * gnu/local.mk: Same. * gnu/home.scm: Replace (gnu home-services symlink-manager) with (gnu home services symlink-manager). --- gnu/home.scm | 2 +- gnu/{home-services => home/services}/symlink-manager.scm | 2 +- gnu/local.mk | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) rename gnu/{home-services => home/services}/symlink-manager.scm (99%) diff --git a/gnu/home.scm b/gnu/home.scm index f4c9359e25..c981c5aef9 100644 --- a/gnu/home.scm +++ b/gnu/home.scm @@ -18,7 +18,7 @@ (define-module (gnu home) #:use-module (gnu home-services) - #:use-module (gnu home-services symlink-manager) + #:use-module (gnu home services symlink-manager) #:use-module (gnu home-services shells) #:use-module (gnu home-services xdg) #:use-module (gnu home-services fontutils) diff --git a/gnu/home-services/symlink-manager.scm b/gnu/home/services/symlink-manager.scm similarity index 99% rename from gnu/home-services/symlink-manager.scm rename to gnu/home/services/symlink-manager.scm index 11f5d503d4..d53e8f5046 100644 --- a/gnu/home-services/symlink-manager.scm +++ b/gnu/home/services/symlink-manager.scm @@ -17,7 +17,7 @@ ;;; 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 symlink-manager) +(define-module (gnu home services symlink-manager) #:use-module (gnu home-services) #:use-module (guix gexp) diff --git a/gnu/local.mk b/gnu/local.mk index ac0b8947d5..29dd4ae5b5 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -75,7 +75,7 @@ GNU_SYSTEM_MODULES = \ %D%/ci.scm \ %D%/home.scm \ %D%/home-services.scm \ - %D%/home-services/symlink-manager.scm \ + %D%/home/services/symlink-manager.scm \ %D%/home-services/fontutils.scm \ %D%/home/services/configuration.scm \ %D%/home-services/shells.scm \ -- 2.33.0 ^ permalink raw reply related [flat|nested] 64+ messages in thread
* [bug#50967] [PATCH 04/14] gnu: home-services: Move utils to (gnu home services). 2021-10-02 16:38 ` [bug#50967] [PATCH 01/14] tests: Add tests for guix home cli Oleg Pykhalov 2021-10-02 16:38 ` [bug#50967] [PATCH 02/14] gnu: home-services: Move configuration to (gnu home services) Oleg Pykhalov 2021-10-02 16:38 ` [bug#50967] [PATCH 03/14] gnu: home-services: Move symlink-manager " Oleg Pykhalov @ 2021-10-02 16:38 ` Oleg Pykhalov 2021-10-02 16:38 ` [bug#50967] [PATCH 05/14] gnu: home-services: Move fontutils to (gnu services) Oleg Pykhalov ` (10 subsequent siblings) 13 siblings, 0 replies; 64+ messages in thread From: Oleg Pykhalov @ 2021-10-02 16:38 UTC (permalink / raw) To: 50967; +Cc: Oleg Pykhalov * gnu/home-services/utils.scm: Rename to gnu/home/services/utils.scm. * gnu/local.mk: Same. * gnu/home-services/shells.scm: Replace (gnu home-services utils) with (gnu home services utils) * gnu/home-services/xdg.scm: Same. --- gnu/home-services/shells.scm | 2 +- gnu/home-services/xdg.scm | 2 +- gnu/{home-services => home/services}/utils.scm | 2 +- gnu/local.mk | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) rename gnu/{home-services => home/services}/utils.scm (98%) diff --git a/gnu/home-services/shells.scm b/gnu/home-services/shells.scm index 2be35ac56e..4939f86b2c 100644 --- a/gnu/home-services/shells.scm +++ b/gnu/home-services/shells.scm @@ -20,7 +20,7 @@ (define-module (gnu home-services shells) #:use-module (gnu services configuration) #:use-module (gnu home services configuration) - #:use-module (gnu home-services utils) + #:use-module (gnu home services utils) #:use-module (gnu home-services) #:use-module (gnu packages shells) #:use-module (gnu packages bash) diff --git a/gnu/home-services/xdg.scm b/gnu/home-services/xdg.scm index 07b25e9e12..7f91da9ece 100644 --- a/gnu/home-services/xdg.scm +++ b/gnu/home-services/xdg.scm @@ -22,7 +22,7 @@ #:use-module (gnu home services configuration) #:use-module (gnu home-services) #:use-module (gnu packages freedesktop) - #:use-module (gnu home-services utils) + #:use-module (gnu home services utils) #:use-module (guix gexp) #:use-module (guix records) #:use-module (guix i18n) diff --git a/gnu/home-services/utils.scm b/gnu/home/services/utils.scm similarity index 98% rename from gnu/home-services/utils.scm rename to gnu/home/services/utils.scm index f13133a7ae..cea75ee896 100644 --- a/gnu/home-services/utils.scm +++ b/gnu/home/services/utils.scm @@ -17,7 +17,7 @@ ;;; 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 utils) +(define-module (gnu home services utils) #:use-module (ice-9 string-fun) #:use-module (srfi srfi-1) #:use-module (srfi srfi-26) diff --git a/gnu/local.mk b/gnu/local.mk index 29dd4ae5b5..729cfda100 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -81,7 +81,7 @@ GNU_SYSTEM_MODULES = \ %D%/home-services/shells.scm \ %D%/home-services/shepherd.scm \ %D%/home-services/mcron.scm \ - %D%/home-services/utils.scm \ + %D%/home/services/utils.scm \ %D%/home-services/xdg.scm \ %D%/image.scm \ %D%/packages.scm \ -- 2.33.0 ^ permalink raw reply related [flat|nested] 64+ messages in thread
* [bug#50967] [PATCH 05/14] gnu: home-services: Move fontutils to (gnu services). 2021-10-02 16:38 ` [bug#50967] [PATCH 01/14] tests: Add tests for guix home cli Oleg Pykhalov ` (2 preceding siblings ...) 2021-10-02 16:38 ` [bug#50967] [PATCH 04/14] gnu: home-services: Move utils " Oleg Pykhalov @ 2021-10-02 16:38 ` Oleg Pykhalov 2021-10-02 16:38 ` [bug#50967] [PATCH 06/14] gnu: home-services: Move shells to (gnu home services) Oleg Pykhalov ` (9 subsequent siblings) 13 siblings, 0 replies; 64+ messages in thread From: Oleg Pykhalov @ 2021-10-02 16:38 UTC (permalink / raw) To: 50967; +Cc: Oleg Pykhalov * gnu/home-services/fontutils.scm: Rename to gnu/services/fontutils.scm. * gnu/local.mk: Same. * gnu/home.scm: Replace (gnu home-services fontutils) with (gnu services fontutils). --- gnu/home.scm | 2 +- gnu/{home-services => home/services}/fontutils.scm | 2 +- gnu/local.mk | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) rename gnu/{home-services => home/services}/fontutils.scm (98%) diff --git a/gnu/home.scm b/gnu/home.scm index c981c5aef9..5591d12704 100644 --- a/gnu/home.scm +++ b/gnu/home.scm @@ -21,7 +21,7 @@ #:use-module (gnu home services symlink-manager) #:use-module (gnu home-services shells) #:use-module (gnu home-services xdg) - #:use-module (gnu home-services fontutils) + #:use-module (gnu home services fontutils) #:use-module (gnu services) #:use-module (guix records) #:use-module (guix diagnostics) diff --git a/gnu/home-services/fontutils.scm b/gnu/home/services/fontutils.scm similarity index 98% rename from gnu/home-services/fontutils.scm rename to gnu/home/services/fontutils.scm index 28bfc3d3f7..72a84fdecd 100644 --- a/gnu/home-services/fontutils.scm +++ b/gnu/home/services/fontutils.scm @@ -17,7 +17,7 @@ ;;; 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 fontutils) +(define-module (gnu home services fontutils) #:use-module (gnu home-services) #:use-module (gnu packages fontutils) #:use-module (guix gexp) diff --git a/gnu/local.mk b/gnu/local.mk index 729cfda100..dbc4221937 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -76,7 +76,7 @@ GNU_SYSTEM_MODULES = \ %D%/home.scm \ %D%/home-services.scm \ %D%/home/services/symlink-manager.scm \ - %D%/home-services/fontutils.scm \ + %D%/home/services/fontutils.scm \ %D%/home/services/configuration.scm \ %D%/home-services/shells.scm \ %D%/home-services/shepherd.scm \ -- 2.33.0 ^ permalink raw reply related [flat|nested] 64+ messages in thread
* [bug#50967] [PATCH 06/14] gnu: home-services: Move shells to (gnu home services). 2021-10-02 16:38 ` [bug#50967] [PATCH 01/14] tests: Add tests for guix home cli Oleg Pykhalov ` (3 preceding siblings ...) 2021-10-02 16:38 ` [bug#50967] [PATCH 05/14] gnu: home-services: Move fontutils to (gnu services) Oleg Pykhalov @ 2021-10-02 16:38 ` Oleg Pykhalov 2021-10-02 16:38 ` [bug#50967] [PATCH 07/14] gnu: home-services: Move xdg " Oleg Pykhalov ` (8 subsequent siblings) 13 siblings, 0 replies; 64+ messages in thread From: Oleg Pykhalov @ 2021-10-02 16:38 UTC (permalink / raw) To: 50967; +Cc: Oleg Pykhalov * gnu/home-services/shells.scm: Rename to gnu/home/services/shells.scm. * gnu/local.mk: Same. * gnu/home.scm: Replace (gnu home-services shells) with (gnu home services shells). * doc/he-config-bare-bones.scm: Same. --- doc/he-config-bare-bones.scm | 2 +- gnu/home.scm | 2 +- gnu/{home-services => home/services}/shells.scm | 2 +- gnu/local.mk | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) rename gnu/{home-services => home/services}/shells.scm (99%) diff --git a/doc/he-config-bare-bones.scm b/doc/he-config-bare-bones.scm index 01be46a7b0..1faf75b871 100644 --- a/doc/he-config-bare-bones.scm +++ b/doc/he-config-bare-bones.scm @@ -1,6 +1,6 @@ (use-modules (gnu home) (gnu home-services) - (gnu home-services shells) + (gnu home services shells) (gnu services) (gnu packages admin) (guix gexp)) diff --git a/gnu/home.scm b/gnu/home.scm index 5591d12704..c0d4c71d51 100644 --- a/gnu/home.scm +++ b/gnu/home.scm @@ -19,7 +19,7 @@ (define-module (gnu home) #:use-module (gnu home-services) #:use-module (gnu home services symlink-manager) - #:use-module (gnu home-services shells) + #:use-module (gnu home services shells) #:use-module (gnu home-services xdg) #:use-module (gnu home services fontutils) #:use-module (gnu services) diff --git a/gnu/home-services/shells.scm b/gnu/home/services/shells.scm similarity index 99% rename from gnu/home-services/shells.scm rename to gnu/home/services/shells.scm index 4939f86b2c..2308371dd0 100644 --- a/gnu/home-services/shells.scm +++ b/gnu/home/services/shells.scm @@ -17,7 +17,7 @@ ;;; 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 shells) +(define-module (gnu home services shells) #:use-module (gnu services configuration) #:use-module (gnu home services configuration) #:use-module (gnu home services utils) diff --git a/gnu/local.mk b/gnu/local.mk index dbc4221937..2e48a70130 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -78,7 +78,7 @@ GNU_SYSTEM_MODULES = \ %D%/home/services/symlink-manager.scm \ %D%/home/services/fontutils.scm \ %D%/home/services/configuration.scm \ - %D%/home-services/shells.scm \ + %D%/home/services/shells.scm \ %D%/home-services/shepherd.scm \ %D%/home-services/mcron.scm \ %D%/home/services/utils.scm \ -- 2.33.0 ^ permalink raw reply related [flat|nested] 64+ messages in thread
* [bug#50967] [PATCH 07/14] gnu: home-services: Move xdg to (gnu home services). 2021-10-02 16:38 ` [bug#50967] [PATCH 01/14] tests: Add tests for guix home cli Oleg Pykhalov ` (4 preceding siblings ...) 2021-10-02 16:38 ` [bug#50967] [PATCH 06/14] gnu: home-services: Move shells to (gnu home services) Oleg Pykhalov @ 2021-10-02 16:38 ` Oleg Pykhalov 2021-10-02 16:38 ` [bug#50967] [PATCH 08/14] gnu: home-services: Move shepherd " Oleg Pykhalov ` (7 subsequent siblings) 13 siblings, 0 replies; 64+ messages in thread From: Oleg Pykhalov @ 2021-10-02 16:38 UTC (permalink / raw) To: 50967; +Cc: Oleg Pykhalov * gnu/home-services/xdg.scm: Rename to gnu/home/services/xdg.scm. * gnu/local.mk: Same. * gnu/home.scm: Replace (gnu home-services xdg) with (gnu home services xdg). --- gnu/home.scm | 2 +- gnu/{home-services => home/services}/xdg.scm | 2 +- gnu/local.mk | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) rename gnu/{home-services => home/services}/xdg.scm (99%) diff --git a/gnu/home.scm b/gnu/home.scm index c0d4c71d51..5ac382dc5a 100644 --- a/gnu/home.scm +++ b/gnu/home.scm @@ -20,7 +20,7 @@ #:use-module (gnu home-services) #:use-module (gnu home services symlink-manager) #:use-module (gnu home services shells) - #:use-module (gnu home-services xdg) + #:use-module (gnu home services xdg) #:use-module (gnu home services fontutils) #:use-module (gnu services) #:use-module (guix records) diff --git a/gnu/home-services/xdg.scm b/gnu/home/services/xdg.scm similarity index 99% rename from gnu/home-services/xdg.scm rename to gnu/home/services/xdg.scm index 7f91da9ece..4aed9a5803 100644 --- a/gnu/home-services/xdg.scm +++ b/gnu/home/services/xdg.scm @@ -17,7 +17,7 @@ ;;; 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 xdg) +(define-module (gnu home services xdg) #:use-module (gnu services configuration) #:use-module (gnu home services configuration) #:use-module (gnu home-services) diff --git a/gnu/local.mk b/gnu/local.mk index 2e48a70130..78ca4688e3 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -82,7 +82,7 @@ GNU_SYSTEM_MODULES = \ %D%/home-services/shepherd.scm \ %D%/home-services/mcron.scm \ %D%/home/services/utils.scm \ - %D%/home-services/xdg.scm \ + %D%/home/services/xdg.scm \ %D%/image.scm \ %D%/packages.scm \ %D%/packages/abduco.scm \ -- 2.33.0 ^ permalink raw reply related [flat|nested] 64+ messages in thread
* [bug#50967] [PATCH 08/14] gnu: home-services: Move shepherd to (gnu home services). 2021-10-02 16:38 ` [bug#50967] [PATCH 01/14] tests: Add tests for guix home cli Oleg Pykhalov ` (5 preceding siblings ...) 2021-10-02 16:38 ` [bug#50967] [PATCH 07/14] gnu: home-services: Move xdg " Oleg Pykhalov @ 2021-10-02 16:38 ` Oleg Pykhalov 2021-10-02 16:38 ` [bug#50967] [PATCH 09/14] gnu: home-services: Move mcron " Oleg Pykhalov ` (6 subsequent siblings) 13 siblings, 0 replies; 64+ messages in thread From: Oleg Pykhalov @ 2021-10-02 16:38 UTC (permalink / raw) To: 50967; +Cc: Oleg Pykhalov * gnu/home-services/shepherd.scm: Move to gnu/home/services/shepherd.scm. * gnu/local.mk: Same. * gnu/home-services/mcron.scm: Replace (gnu home-services shepherd) with (gnu home services shepherd). * tests/guix-home.sh: Same. --- gnu/home-services/mcron.scm | 2 +- gnu/{home-services => home/services}/shepherd.scm | 2 +- gnu/local.mk | 2 +- tests/guix-home.sh | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) rename gnu/{home-services => home/services}/shepherd.scm (99%) diff --git a/gnu/home-services/mcron.scm b/gnu/home-services/mcron.scm index fdfde179a5..fb044351a9 100644 --- a/gnu/home-services/mcron.scm +++ b/gnu/home-services/mcron.scm @@ -20,8 +20,8 @@ (define-module (gnu home-services mcron) #:use-module (gnu packages guile-xyz) #:use-module (gnu home-services) - #:use-module (gnu home-services shepherd) #:use-module (gnu services shepherd) + #:use-module (gnu home services shepherd) #:use-module (guix records) #:use-module (guix gexp) #:use-module (srfi srfi-1) diff --git a/gnu/home-services/shepherd.scm b/gnu/home/services/shepherd.scm similarity index 99% rename from gnu/home-services/shepherd.scm rename to gnu/home/services/shepherd.scm index 120cfde1a1..1a3e849bb2 100644 --- a/gnu/home-services/shepherd.scm +++ b/gnu/home/services/shepherd.scm @@ -17,7 +17,7 @@ ;;; 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 shepherd) +(define-module (gnu home services shepherd) #:use-module (gnu home-services) #:use-module (gnu packages admin) #:use-module (gnu services shepherd) diff --git a/gnu/local.mk b/gnu/local.mk index 78ca4688e3..5e3722a2d8 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -79,7 +79,7 @@ GNU_SYSTEM_MODULES = \ %D%/home/services/fontutils.scm \ %D%/home/services/configuration.scm \ %D%/home/services/shells.scm \ - %D%/home-services/shepherd.scm \ + %D%/home/services/shepherd.scm \ %D%/home-services/mcron.scm \ %D%/home/services/utils.scm \ %D%/home/services/xdg.scm \ diff --git a/tests/guix-home.sh b/tests/guix-home.sh index cb015c907f..86ba42bb8b 100644 --- a/tests/guix-home.sh +++ b/tests/guix-home.sh @@ -75,7 +75,7 @@ fi cat > "$tmpfile" <<EOF (use-modules (gnu)) -(use-modules (gnu home-services shepherd)) +(use-modules (gnu home services shepherd)) (home-environment (services (list (service home-shepherd-service-type) -- 2.33.0 ^ permalink raw reply related [flat|nested] 64+ messages in thread
* [bug#50967] [PATCH 09/14] gnu: home-services: Move mcron to (gnu home services). 2021-10-02 16:38 ` [bug#50967] [PATCH 01/14] tests: Add tests for guix home cli Oleg Pykhalov ` (6 preceding siblings ...) 2021-10-02 16:38 ` [bug#50967] [PATCH 08/14] gnu: home-services: Move shepherd " Oleg Pykhalov @ 2021-10-02 16:38 ` Oleg Pykhalov 2021-10-02 16:38 ` [bug#50967] [PATCH 10/14] scripts: home: (gnu home-services bash) -> (gnu home services bash) Oleg Pykhalov ` (5 subsequent siblings) 13 siblings, 0 replies; 64+ messages in thread From: Oleg Pykhalov @ 2021-10-02 16:38 UTC (permalink / raw) To: 50967; +Cc: Oleg Pykhalov * gnu/home-services/mcron.scm: Move to gnu/home/services/mcron.scm. * gnu/local.mk: Same. * doc/guix.texi: Replace (gnu home-services mcron) with (gnu home services mcron). --- doc/guix.texi | 2 +- gnu/{home-services => home/services}/mcron.scm | 2 +- gnu/local.mk | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) rename gnu/{home-services => home/services}/mcron.scm (99%) diff --git a/doc/guix.texi b/doc/guix.texi index a72a726b54..8edbcd4edf 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -35810,7 +35810,7 @@ for example). @cindex mcron @cindex scheduling jobs -The @code{(gnu home-services mcron)} module provides an interface to +The @code{(gnu home services mcron)} module provides an interface to GNU@tie{}mcron, a daemon to run jobs at scheduled times (@pxref{Top,,, mcron, GNU@tie{}mcron}). The information about system's mcron is applicable here (@pxref{Scheduled Job Execution}), the only difference diff --git a/gnu/home-services/mcron.scm b/gnu/home/services/mcron.scm similarity index 99% rename from gnu/home-services/mcron.scm rename to gnu/home/services/mcron.scm index fb044351a9..cc6faac47f 100644 --- a/gnu/home-services/mcron.scm +++ b/gnu/home/services/mcron.scm @@ -17,7 +17,7 @@ ;;; 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 mcron) +(define-module (gnu home services mcron) #:use-module (gnu packages guile-xyz) #:use-module (gnu home-services) #:use-module (gnu services shepherd) diff --git a/gnu/local.mk b/gnu/local.mk index 5e3722a2d8..5e8b769ce9 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -80,7 +80,7 @@ GNU_SYSTEM_MODULES = \ %D%/home/services/configuration.scm \ %D%/home/services/shells.scm \ %D%/home/services/shepherd.scm \ - %D%/home-services/mcron.scm \ + %D%/home/services/mcron.scm \ %D%/home/services/utils.scm \ %D%/home/services/xdg.scm \ %D%/image.scm \ -- 2.33.0 ^ permalink raw reply related [flat|nested] 64+ messages in thread
* [bug#50967] [PATCH 10/14] scripts: home: (gnu home-services bash) -> (gnu home services bash). 2021-10-02 16:38 ` [bug#50967] [PATCH 01/14] tests: Add tests for guix home cli Oleg Pykhalov ` (7 preceding siblings ...) 2021-10-02 16:38 ` [bug#50967] [PATCH 09/14] gnu: home-services: Move mcron " Oleg Pykhalov @ 2021-10-02 16:38 ` Oleg Pykhalov 2021-10-02 16:38 ` [bug#50967] [PATCH 11/14] doc: (gnu home-services) -> (gnu home services) Oleg Pykhalov ` (4 subsequent siblings) 13 siblings, 0 replies; 64+ messages in thread From: Oleg Pykhalov @ 2021-10-02 16:38 UTC (permalink / raw) To: 50967; +Cc: Oleg Pykhalov * guix/scripts/home/import.scm: Replace (gnu home-services bash) with (gnu home services bash). --- guix/scripts/home/import.scm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/guix/scripts/home/import.scm b/guix/scripts/home/import.scm index 79fb23a2fd..c977ec3861 100644 --- a/guix/scripts/home/import.scm +++ b/guix/scripts/home/import.scm @@ -41,7 +41,7 @@ (let ((rc (string-append (getenv "HOME") "/.bashrc")) (profile (string-append (getenv "HOME") "/.bash_profile")) (logout (string-append (getenv "HOME") "/.bash_logout"))) - `((gnu home-services bash) + `((gnu home services bash) (service home-bash-service-type (home-bash-configuration ,@(if (file-exists? rc) -- 2.33.0 ^ permalink raw reply related [flat|nested] 64+ messages in thread
* [bug#50967] [PATCH 11/14] doc: (gnu home-services) -> (gnu home services). 2021-10-02 16:38 ` [bug#50967] [PATCH 01/14] tests: Add tests for guix home cli Oleg Pykhalov ` (8 preceding siblings ...) 2021-10-02 16:38 ` [bug#50967] [PATCH 10/14] scripts: home: (gnu home-services bash) -> (gnu home services bash) Oleg Pykhalov @ 2021-10-02 16:38 ` Oleg Pykhalov 2021-10-02 16:38 ` [bug#50967] [PATCH 12/14] gnu: home-services: Update %service-type-path Oleg Pykhalov ` (3 subsequent siblings) 13 siblings, 0 replies; 64+ messages in thread From: Oleg Pykhalov @ 2021-10-02 16:38 UTC (permalink / raw) To: 50967; +Cc: Oleg Pykhalov * doc/guix.texi: Replace (gnu home-services) with (gnu home services). --- doc/guix.texi | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index 8edbcd4edf..d641935e0f 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -35555,9 +35555,9 @@ services)}. @node Essential Home Services @subsection Essential Home Services -There are a few essential services defined in @code{(gnu -home-services)}, they are mostly for internal use and are required to -build a home environment, but some of them will be useful for the end +There are a few essential home services defined in +@code{(gnu services)}, they are mostly for internal use and are required +to build a home environment, but some of them will be useful for the end user. @cindex environment variables -- 2.33.0 ^ permalink raw reply related [flat|nested] 64+ messages in thread
* [bug#50967] [PATCH 12/14] gnu: home-services: Update %service-type-path. 2021-10-02 16:38 ` [bug#50967] [PATCH 01/14] tests: Add tests for guix home cli Oleg Pykhalov ` (9 preceding siblings ...) 2021-10-02 16:38 ` [bug#50967] [PATCH 11/14] doc: (gnu home-services) -> (gnu home services) Oleg Pykhalov @ 2021-10-02 16:38 ` Oleg Pykhalov 2021-10-04 14:01 ` [bug#50967] [PATCH 00/12] Move (gnu home-services XYZ) to (gnu services XYZ) Ludovic Courtès 2021-10-02 16:38 ` [bug#50967] [PATCH 13/14] home: services: configuration: Support file-like objects Oleg Pykhalov ` (2 subsequent siblings) 13 siblings, 1 reply; 64+ messages in thread From: Oleg Pykhalov @ 2021-10-02 16:38 UTC (permalink / raw) To: 50967; +Cc: Oleg Pykhalov * gnu/home-services.scm (%service-type-path): Search home services in "gnu/services". * gnu/home-services.scm: Update documentation string. --- gnu/home-services.scm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gnu/home-services.scm b/gnu/home-services.scm index 9f1e986616..a244a15511 100644 --- a/gnu/home-services.scm +++ b/gnu/home-services.scm @@ -512,10 +512,10 @@ environment, and its configuration file, when available."))) (define %service-type-path ;; Search path for service types. - (make-parameter `((,%guix-home-root-directory . "gnu/home-services")))) + (make-parameter `((,%guix-home-root-directory . "gnu/home/services")))) (define (all-home-service-modules) - "Return the default set of 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))) -- 2.33.0 ^ permalink raw reply related [flat|nested] 64+ messages in thread
* [bug#50967] [PATCH 00/12] Move (gnu home-services XYZ) to (gnu services XYZ) 2021-10-02 16:38 ` [bug#50967] [PATCH 12/14] gnu: home-services: Update %service-type-path Oleg Pykhalov @ 2021-10-04 14:01 ` Ludovic Courtès 0 siblings, 0 replies; 64+ messages in thread From: Ludovic Courtès @ 2021-10-04 14:01 UTC (permalink / raw) To: Oleg Pykhalov; +Cc: 50967 Oleg Pykhalov <go.wigust@gmail.com> skribis: > * gnu/home-services.scm > (%service-type-path): Search home services in "gnu/services". > * gnu/home-services.scm: Update documentation string. > --- > gnu/home-services.scm | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/gnu/home-services.scm b/gnu/home-services.scm > index 9f1e986616..a244a15511 100644 > --- a/gnu/home-services.scm > +++ b/gnu/home-services.scm > @@ -512,10 +512,10 @@ environment, and its configuration file, when available."))) > > (define %service-type-path > ;; Search path for service types. > - (make-parameter `((,%guix-home-root-directory . "gnu/home-services")))) > + (make-parameter `((,%guix-home-root-directory . "gnu/home/services")))) > I think it would make more sense to squeeze patches 2 to 12 (inclusive) as a single patch. That way, both the previous and the next commit would be in working state, which may not be the case when we rename things one by one (for example, renamed service modules won’t be discovered until the hunk above is applied.) Otherwise LGTM, thanks! Ludo’. ^ permalink raw reply [flat|nested] 64+ messages in thread
* [bug#50967] [PATCH 13/14] home: services: configuration: Support file-like objects. 2021-10-02 16:38 ` [bug#50967] [PATCH 01/14] tests: Add tests for guix home cli Oleg Pykhalov ` (10 preceding siblings ...) 2021-10-02 16:38 ` [bug#50967] [PATCH 12/14] gnu: home-services: Update %service-type-path Oleg Pykhalov @ 2021-10-02 16:38 ` Oleg Pykhalov 2021-10-02 18:35 ` Xinglu Chen ` (2 more replies) 2021-10-02 16:38 ` [bug#50967] [PATCH 14/14] doc: Document guix home import Oleg Pykhalov 2021-10-04 13:58 ` [bug#50967] [PATCH 00/12] Move (gnu home-services XYZ) to (gnu services XYZ) Ludovic Courtès 13 siblings, 3 replies; 64+ messages in thread From: Oleg Pykhalov @ 2021-10-02 16:38 UTC (permalink / raw) To: 50967; +Cc: Oleg Pykhalov * gnu/home/services/configuration.scm (interpose): Include content of files. (string-or-gexp?): Rename to 'file-or-string-or-gexp?' and check for file-like object. (serialize-string-or-gexp): Rename to 'serialize-file-or-string-or-gexp'. (text-config?): Call 'file-or-string-or-gexp?' intead of 'string-or-gexp?'. * guix/scripts/home/import.scm: (generate-bash-module+configuration): Don't call slurp-file-gexp. --- gnu/home/services/configuration.scm | 14 ++++++++++---- guix/scripts/home/import.scm | 8 +++----- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/gnu/home/services/configuration.scm b/gnu/home/services/configuration.scm index 5e7743e7d6..39db7a5693 100644 --- a/gnu/home/services/configuration.scm +++ b/gnu/home/services/configuration.scm @@ -59,7 +59,12 @@ DELIMITER interposed LS. Support 'infix and 'suffix GRAMMAR values." (G_ "The GRAMMAR value must be 'infix or 'suffix, but ~a provided.") grammar))) (fold-right (lambda (e acc) - (cons e + (cons (if (file-like? e) + #~(begin + (use-modules (ice-9 rdelim)) + (with-fluids ((%default-port-encoding "UTF-8")) + (with-input-from-file #$e read-string))) + e) (if (and (null? acc) (eq? grammar 'infix)) acc (cons delimiter acc)))) @@ -79,11 +84,12 @@ the list result in @code{#t} when applying PRED? on them." (define alist? list?) -(define (string-or-gexp? sg) (or (string? sg) (gexp? sg))) -(define (serialize-string-or-gexp field-name val) "") +(define (file-or-string-or-gexp? fsg) + (or (string? fsg) (gexp? fsg) (file-like? fsg))) +(define (serialize-file-or-string-or-gexp field-name val) "") (define (text-config? config) - (and (list? config) (every string-or-gexp? config))) + (and (list? config) (every file-or-string-or-gexp? config))) (define (serialize-text-config field-name val) #~(string-append #$@(interpose val "\n" 'suffix))) diff --git a/guix/scripts/home/import.scm b/guix/scripts/home/import.scm index c977ec3861..611f580e85 100644 --- a/guix/scripts/home/import.scm +++ b/guix/scripts/home/import.scm @@ -46,17 +46,15 @@ (home-bash-configuration ,@(if (file-exists? rc) `((bashrc - (list (slurp-file-gexp (local-file ,rc))))) + (list (local-file ,rc)))) '()) ,@(if (file-exists? profile) `((bash-profile - (list (slurp-file-gexp - (local-file ,profile))))) + (list (local-file ,profile)))) '()) ,@(if (file-exists? logout) `((bash-logout - (list (slurp-file-gexp - (local-file ,logout))))) + (list (local-file ,logout)))) '())))))) -- 2.33.0 ^ permalink raw reply related [flat|nested] 64+ messages in thread
* [bug#50967] [PATCH 13/14] home: services: configuration: Support file-like objects. 2021-10-02 16:38 ` [bug#50967] [PATCH 13/14] home: services: configuration: Support file-like objects Oleg Pykhalov @ 2021-10-02 18:35 ` Xinglu Chen 2021-10-04 14:04 ` [bug#50967] [PATCH 00/12] Move (gnu home-services XYZ) to (gnu services XYZ) Ludovic Courtès 2021-10-08 10:06 ` [bug#50967] [PATCH 13/14] home: services: configuration: Support file-like objects Andrew Tropin 2021-10-14 7:08 ` Andrew Tropin 2 siblings, 1 reply; 64+ messages in thread From: Xinglu Chen @ 2021-10-02 18:35 UTC (permalink / raw) To: Oleg Pykhalov, 50967; +Cc: Oleg Pykhalov [-- Attachment #1: Type: text/plain, Size: 3688 bytes --] On Sat, Oct 02 2021, Oleg Pykhalov wrote: > * gnu/home/services/configuration.scm (interpose): Include content of files. > (string-or-gexp?): Rename to 'file-or-string-or-gexp?' and check for file-like > object. I would call it ‘file-like-or-string-or-gexp?’, just ‘files’ doesn’t really make it clear that it should be a “file-like object”. > (serialize-string-or-gexp): Rename to 'serialize-file-or-string-or-gexp'. > (text-config?): Call 'file-or-string-or-gexp?' intead of 'string-or-gexp?'. > * guix/scripts/home/import.scm: > (generate-bash-module+configuration): Don't call slurp-file-gexp. > --- > gnu/home/services/configuration.scm | 14 ++++++++++---- > guix/scripts/home/import.scm | 8 +++----- > 2 files changed, 13 insertions(+), 9 deletions(-) > > diff --git a/gnu/home/services/configuration.scm b/gnu/home/services/configuration.scm > index 5e7743e7d6..39db7a5693 100644 > --- a/gnu/home/services/configuration.scm > +++ b/gnu/home/services/configuration.scm > @@ -59,7 +59,12 @@ DELIMITER interposed LS. Support 'infix and 'suffix GRAMMAR values." > (G_ "The GRAMMAR value must be 'infix or 'suffix, but ~a provided.") > grammar))) > (fold-right (lambda (e acc) > - (cons e > + (cons (if (file-like? e) > + #~(begin > + (use-modules (ice-9 rdelim)) > + (with-fluids ((%default-port-encoding "UTF-8")) > + (with-input-from-file #$e read-string))) > + e) > (if (and (null? acc) (eq? grammar 'infix)) > acc > (cons delimiter acc)))) > @@ -79,11 +84,12 @@ the list result in @code{#t} when applying PRED? on them." > > (define alist? list?) > > -(define (string-or-gexp? sg) (or (string? sg) (gexp? sg))) > -(define (serialize-string-or-gexp field-name val) "") > +(define (file-or-string-or-gexp? fsg) > + (or (string? fsg) (gexp? fsg) (file-like? fsg))) > +(define (serialize-file-or-string-or-gexp field-name val) "") This could defined as ‘empty-serializer’ from (gnu services configuration). > > (define (text-config? config) > - (and (list? config) (every string-or-gexp? config))) > + (and (list? config) (every file-or-string-or-gexp? config))) ‘text-config?’ could be defined as (list-of file-or-string-or-gexp?) > (define (serialize-text-config field-name val) > #~(string-append #$@(interpose val "\n" 'suffix))) > > diff --git a/guix/scripts/home/import.scm b/guix/scripts/home/import.scm > index c977ec3861..611f580e85 100644 > --- a/guix/scripts/home/import.scm > +++ b/guix/scripts/home/import.scm > @@ -46,17 +46,15 @@ > (home-bash-configuration > ,@(if (file-exists? rc) > `((bashrc > - (list (slurp-file-gexp (local-file ,rc))))) > + (list (local-file ,rc)))) > '()) > ,@(if (file-exists? profile) > `((bash-profile > - (list (slurp-file-gexp > - (local-file ,profile))))) > + (list (local-file ,profile)))) > '()) > ,@(if (file-exists? logout) > `((bash-logout > - (list (slurp-file-gexp > - (local-file ,logout))))) > + (list (local-file ,logout)))) > '())))))) > > > -- > 2.33.0 [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 861 bytes --] ^ permalink raw reply [flat|nested] 64+ messages in thread
* [bug#50967] [PATCH 00/12] Move (gnu home-services XYZ) to (gnu services XYZ) 2021-10-02 18:35 ` Xinglu Chen @ 2021-10-04 14:04 ` Ludovic Courtès 2021-10-06 8:15 ` [bug#50967] file-like objects instead of gexps Andrew Tropin 0 siblings, 1 reply; 64+ messages in thread From: Ludovic Courtès @ 2021-10-04 14:04 UTC (permalink / raw) To: Xinglu Chen; +Cc: Oleg Pykhalov, 50967 Xinglu Chen <public@yoctocell.xyz> skribis: > On Sat, Oct 02 2021, Oleg Pykhalov wrote: > >> * gnu/home/services/configuration.scm (interpose): Include content of files. >> (string-or-gexp?): Rename to 'file-or-string-or-gexp?' and check for file-like >> object. > > I would call it ‘file-like-or-string-or-gexp?’, just ‘files’ doesn’t > really make it clear that it should be a “file-like object”. As a matter of API, I would make it monomorphic: accept a file-like object, period. This is what’s done for System services (and polymorphic APIs are rare in general in Guix). ‘plain-file’ and ‘scheme-file’ allow users to “convert” a string or a gexp into a file-like object. WDYT? Ludo’. ^ permalink raw reply [flat|nested] 64+ messages in thread
* [bug#50967] file-like objects instead of gexps 2021-10-04 14:04 ` [bug#50967] [PATCH 00/12] Move (gnu home-services XYZ) to (gnu services XYZ) Ludovic Courtès @ 2021-10-06 8:15 ` Andrew Tropin 2021-10-08 7:56 ` Ludovic Courtès 2021-10-08 13:45 ` Xinglu Chen 0 siblings, 2 replies; 64+ messages in thread From: Andrew Tropin @ 2021-10-06 8:15 UTC (permalink / raw) To: Ludovic Courtès, Xinglu Chen; +Cc: Oleg Pykhalov, 50967 [-- Attachment #1: Type: text/plain, Size: 6586 bytes --] On 2021-10-04 16:04, Ludovic Courtès wrote: > Xinglu Chen <public@yoctocell.xyz> skribis: > >> On Sat, Oct 02 2021, Oleg Pykhalov wrote: >> >>> * gnu/home/services/configuration.scm (interpose): Include content of files. >>> (string-or-gexp?): Rename to 'file-or-string-or-gexp?' and check for file-like >>> object. >> >> I would call it ‘file-like-or-string-or-gexp?’, just ‘files’ doesn’t >> really make it clear that it should be a “file-like object”. > > As a matter of API, I would make it monomorphic: accept a file-like > object, period. This is what’s done for System services (and > polymorphic APIs are rare in general in Guix). At least some of system services are far from ideal, recently I tried to add rtmp section to nginx configuration using nginx system service. I had two options and both does look hacky, I could use extra-content starting with closing curly bracket: --8<---------------cut here---------------start------------->8--- (service nginx-service-type (nginx-configuration (modules (list (file-append nginx-rtmp-module "\ /etc/nginx/modules/ngx_rtmp_module.so"))) (extra-content (format #f "\ } rtmp { server { listen 1935; chunk_size 4096; application live { live on; record off; push rtmp://a.rtmp.youtube.com/live2/~a; push rtmp://diode.zone:1935/live/~a; } } " youtube-key peertube-key)) (server-blocks (list (nginx-server-configuration ;; (locations ;; (list ;; (nginx-location-configuration ;; (uri "/stat") ;; (body '("rtmp_stat all;" ;; "rtmp_stat_stylesheet stat.xsl;"))))) (server-name `(,ip)) (listen '("8088")) (root "/var/www/")))))) --8<---------------cut here---------------end--------------->8--- or use file field of nginx-configuration record and generate the whole configuration myself inside computed-file, loosing all the benifits of other nginx-configuration fields. Personally, I don't find both of these approaches appealing and convenient. Maybe it's an issue of exact system service, but the way the configuration for this service is implemented is getting in the way of the user. > > ‘plain-file’ and ‘scheme-file’ allow users to “convert” a string or a > gexp into a file-like object. > > WDYT? > > Ludo’. > > > Imagine the following use case: I want to create a home service, which accepts a package (zsh plugin) and adds a code for loading this package to zshrc, currently it's implemented like that: https://git.sr.ht/~abcdw/rde/tree/69dd2baf0384c899a4a4f97bdac8bf0b6e499b82/item/gnu/home-services/shellutils.scm#L18 Exteding the service above with `(list zsh-autosuggestions)` will add the following line to zshrc: source /gnu/store/w7d43gk1qszplj9i0rkzqvzz6kp88qfm-zsh-autosuggestions-0.7.0/share/zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh Or the same thing can be done manually by user: --8<---------------cut here---------------start------------->8--- (service home-zsh-service-type (home-zsh-configuration (zshrc (list #~(string-append "source " #$zsh-autosuggestions "/share/zs../..ions.zsh") ;; or "source \\" (file-append zsh-autosuggestions "/share/zs../..ions.zsh"))))) --8<---------------cut here---------------end--------------->8--- gexps returns a string, file-like object returns a path to the file in the store, kinda expected behavior. Both implementations looks quite simple. Now I'll try to reimplement it with file-like objects. The code below is a pseudo code, but should demonstrate the overall concerns I have: --8<---------------cut here---------------start------------->8--- ;; Some generic functions (define get-file-like-object-path (file-like) "Because all file-like object get inserted literally by home services, we need a function, which returns a file, which contains a path to the file." (computed-file "tmp-file" #~#$file-like)) (define fl-append-strings (lst) "Accepts a list of strings and file-like object, reads the content of the file-like objects (to be consistent with behavior of home services configuration)." (define file-like->str (mb-file-like) (if (string? mb-file-like) mb-file-like #~(begin (use-modules (ice-9 rdelim)) (with-fluids ((%default-port-encoding "UTF-8")) (with-input-from-file #$mb-file-like read-string))))) (computed-file "tmp-file" #~(apply string-append '#$(map file-like->str lst)))) ;; A home service, declared in home-environment. (service home-zsh-service-type (home-zsh-configuration (zshrc (list (fl-append-strings (list "source " (get-file-like-object-path zsh-autosuggestions) "/share/zs../..ions.zsh")) ;; or "source \\" (get-file-like-object-path (file-append zsh-autosuggestions "/share/zs../..ions.zsh")))))) --8<---------------cut here---------------end--------------->8--- Here we don't use gexps inside configuration and all file-like objects are "expanded" as their content instead of path in the store. It can work, but looks a little strange and hard to copmose. Perhaps, I miss something and doesn't see the whole picture, but for now expanding file-like objects to their content and throwing out gexps doesn't look appealing to me. BTW, I've skimmed through the paper "Code Staging in GNU Guix" and limitations section, still not sure what your concerns are, I'll try to re-read the paper and your message <87pmvqckws.fsf@gnu.org> one more time a few days later to better understand it. If you have a spare time, please make a simple code snippet, which demonstrates the problem you've mentioned in the message, which will hit the users of home services. It will help me to figure out possible shortcommings and better understand the problem. Ludovic, sorry for spending your time on that, but I really need to understand this thing better. Thank you in advance for hepling on that. Oleg, thank you for working on this patch series, much appreciate) -- Best regards, Andrew Tropin [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 832 bytes --] ^ permalink raw reply [flat|nested] 64+ messages in thread
* [bug#50967] file-like objects instead of gexps 2021-10-06 8:15 ` [bug#50967] file-like objects instead of gexps Andrew Tropin @ 2021-10-08 7:56 ` Ludovic Courtès 2021-10-08 10:00 ` Andrew Tropin 2021-10-08 13:45 ` Xinglu Chen 1 sibling, 1 reply; 64+ messages in thread From: Ludovic Courtès @ 2021-10-08 7:56 UTC (permalink / raw) To: Andrew Tropin; +Cc: Oleg Pykhalov, Xinglu Chen, 50967 Hi Andrew, Andrew Tropin <andrew@trop.in> skribis: > On 2021-10-04 16:04, Ludovic Courtès wrote: > >> Xinglu Chen <public@yoctocell.xyz> skribis: >> >>> On Sat, Oct 02 2021, Oleg Pykhalov wrote: >>> >>>> * gnu/home/services/configuration.scm (interpose): Include content of files. >>>> (string-or-gexp?): Rename to 'file-or-string-or-gexp?' and check for file-like >>>> object. >>> >>> I would call it ‘file-like-or-string-or-gexp?’, just ‘files’ doesn’t >>> really make it clear that it should be a “file-like object”. >> >> As a matter of API, I would make it monomorphic: accept a file-like >> object, period. This is what’s done for System services (and >> polymorphic APIs are rare in general in Guix). > > At least some of system services are far from ideal, recently I tried to > add rtmp section to nginx configuration using nginx system service. I agree that nginx config is problematic: https://issues.guix.gnu.org/37388 But IMO that’s off-topic. :-) > Imagine the following use case: I want to create a home service, which > accepts a package (zsh plugin) and adds a code for loading this package > to zshrc, currently it's implemented like that: > > https://git.sr.ht/~abcdw/rde/tree/69dd2baf0384c899a4a4f97bdac8bf0b6e499b82/item/gnu/home-services/shellutils.scm#L18 > > Exteding the service above with `(list zsh-autosuggestions)` will add > the following line to zshrc: > > source /gnu/store/w7d43gk1qszplj9i0rkzqvzz6kp88qfm-zsh-autosuggestions-0.7.0/share/zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh OK. Then that’s fine: you can have special code that emits those “source” lines in .zshrc while still allowing users to provide their own file-like object for .zshrc lines they want to add. Again, see how ‘torrc’ is generated in ‘tor-service-type’. I’m happy to discuss specific service examples in mode details if you want. Overall, I’m confident Home services don’t require any pattern that’s not already found in one of the many System services. :-) HTH, Ludo’. ^ permalink raw reply [flat|nested] 64+ messages in thread
* [bug#50967] file-like objects instead of gexps 2021-10-08 7:56 ` Ludovic Courtès @ 2021-10-08 10:00 ` Andrew Tropin 2021-10-09 13:34 ` Ludovic Courtès 0 siblings, 1 reply; 64+ messages in thread From: Andrew Tropin @ 2021-10-08 10:00 UTC (permalink / raw) To: Ludovic Courtès; +Cc: Oleg Pykhalov, Xinglu Chen, 50967 [-- Attachment #1: Type: text/plain, Size: 4563 bytes --] On 2021-10-08 09:56, Ludovic Courtès wrote: > Hi Andrew, > > Andrew Tropin <andrew@trop.in> skribis: > >> On 2021-10-04 16:04, Ludovic Courtès wrote: >> >>> Xinglu Chen <public@yoctocell.xyz> skribis: >>> >>>> On Sat, Oct 02 2021, Oleg Pykhalov wrote: >>>> >>>>> * gnu/home/services/configuration.scm (interpose): Include content of files. >>>>> (string-or-gexp?): Rename to 'file-or-string-or-gexp?' and check for file-like >>>>> object. >>>> >>>> I would call it ‘file-like-or-string-or-gexp?’, just ‘files’ doesn’t >>>> really make it clear that it should be a “file-like object”. >>> >>> As a matter of API, I would make it monomorphic: accept a file-like >>> object, period. This is what’s done for System services (and >>> polymorphic APIs are rare in general in Guix). >> >> At least some of system services are far from ideal, recently I tried to >> add rtmp section to nginx configuration using nginx system service. > > I agree that nginx config is problematic: > > https://issues.guix.gnu.org/37388 > > But IMO that’s off-topic. :-) > Even not taking into account that ngixn-configuration is not ideally implemented, probably it still relevant: 1. Highlights the problem of current service configuration implementation approach with records: we will need to mimic the whole underlying configuration language with records, for some small languages it's possible, but in general it's very thankless job, which also force use to keep an eye on upstream configuration language, possible extensions to it and keep our implementation in sync. In addition to that in most cases provided set of nested records requires destructuring and custom serialization code. Other system services also affected by this issue. 2. Usage of separate config-file fields with file-like object values is problematic: For nginx service it substitutes the whole file, for tor service it will be inserted at the end of the file for service X it will be inserted at the middle. Using a slightly different approach, implemented in many home services we get ultimate configuration flexibility, we don't need to handle existing file as some special case, create a separate field for it and wonder where it should be inserted, when provided. I'll provide more details in a separate thread, but for now just take a look at too implementations of sway services using both approaches: https://notabug.org/jbranso/guix-config/src/master/sway-service.scm#L110 https://git.sr.ht/~abcdw/rde/tree/master/item/gnu/home-services/wm.scm#L33 >> Imagine the following use case: I want to create a home service, which >> accepts a package (zsh plugin) and adds a code for loading this package >> to zshrc, currently it's implemented like that: >> >> https://git.sr.ht/~abcdw/rde/tree/69dd2baf0384c899a4a4f97bdac8bf0b6e499b82/item/gnu/home-services/shellutils.scm#L18 >> >> Exteding the service above with `(list zsh-autosuggestions)` will add >> the following line to zshrc: >> >> source /gnu/store/w7d43gk1qszplj9i0rkzqvzz6kp88qfm-zsh-autosuggestions-0.7.0/share/zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh > > OK. > > Then that’s fine: you can have special code that emits those “source” > lines in .zshrc while still allowing users to provide their own > file-like object for .zshrc lines they want to add. Again, see how > ‘torrc’ is generated in ‘tor-service-type’. From what I understand you want a separate bashrc-file, bash-profile-file and bash-logout-file fields to be present, but where the content of those files should be inserted? At the beginning/end or instead of the rest of configuration? We already can achieve the same result by providing gexp, which will read the content of the file-like object, a very small helper for that (slurp-file-gexp) makes it even easier to do. Such approach is more flexible and doesn't seem much harder. I remember that you had concerns about slurp-file-gexp, but still don't understand what exactly you are concerned about. > > I’m happy to discuss specific service examples in mode details if you > want. Overall, I’m confident Home services don’t require any pattern > that’s not already found in one of the many System services. :-) > > HTH, > Ludo’. I'll write a few examples of service configurations and rationale behind the design descisions for that next week, to make the discussion more practically oriented. -- Best regards, Andrew Tropin [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 832 bytes --] ^ permalink raw reply [flat|nested] 64+ messages in thread
* [bug#50967] file-like objects instead of gexps 2021-10-08 10:00 ` Andrew Tropin @ 2021-10-09 13:34 ` Ludovic Courtès 2021-10-14 8:32 ` Andrew Tropin 0 siblings, 1 reply; 64+ messages in thread From: Ludovic Courtès @ 2021-10-09 13:34 UTC (permalink / raw) To: Andrew Tropin; +Cc: Oleg Pykhalov, Xinglu Chen, 50967 Hi Andrew, Preamble: Guix Home is now committed and there are bug reports coming in. To me, that means our discussion needs to be focused on addressing specific issues; we’re not going to redesign Guix services in this thread. Andrew Tropin <andrew@trop.in> skribis: [...] >> Then that’s fine: you can have special code that emits those “source” >> lines in .zshrc while still allowing users to provide their own >> file-like object for .zshrc lines they want to add. Again, see how >> ‘torrc’ is generated in ‘tor-service-type’. > > From what I understand you want a separate bashrc-file, > bash-profile-file and bash-logout-file fields to be present, but where > the content of those files should be inserted? At the beginning/end or > instead of the rest of configuration? > > We already can achieve the same result by providing gexp, which will > read the content of the file-like object, a very small helper for that > (slurp-file-gexp) makes it even easier to do. Such approach is more > flexible and doesn't seem much harder. > > I remember that you had concerns about slurp-file-gexp, but still don't > understand what exactly you are concerned about. Let me restate my concerns: 1. Users are unlikely to fathom what this does, given the name. It will end up in user configurations, yet: “slurp”? “gexp”? 2. ‘slurp-file-gexp’ returns code, as a gexp. Depending on the place where that gexp is inserted, it may or may not work. Consider: (define (foo x) #~(frob '(#$x))) (foo (slurp-file-gexp …)) ;d’oh! 3. Use of ‘slurp-file-gexp’ and gexps in configuration records is not consistent with the rest of the service APIs (and I think we can humbly recognize that those APIs have been doing the job for a while already.) Let’s just to the (call-with-input-file file get-string-all) dance in places where it’s needed rather than let users call ‘slurp-file-gexp’. This is roughly what the ‘tor-service-type’ example I gave does. > I'll write a few examples of service configurations and rationale behind > the design descisions for that next week, to make the discussion more > practically oriented. People are starting to use the tool and to report bugs. So, unfortunately, we have to sort out interface issues quickly now. If some of the things being discussed turn out to be too complex to address under those time constraints, we can consider taking them out until we have a better idea on how to address them. How does that sound? Thanks, Ludo’. ^ permalink raw reply [flat|nested] 64+ messages in thread
* [bug#50967] file-like objects instead of gexps 2021-10-09 13:34 ` Ludovic Courtès @ 2021-10-14 8:32 ` Andrew Tropin 0 siblings, 0 replies; 64+ messages in thread From: Andrew Tropin @ 2021-10-14 8:32 UTC (permalink / raw) To: Ludovic Courtès; +Cc: Oleg Pykhalov, Xinglu Chen, 50967 [-- Attachment #1: Type: text/plain, Size: 4399 bytes --] On 2021-10-09 15:34, Ludovic Courtès wrote: > Hi Andrew, > > Preamble: Guix Home is now committed and there are bug reports coming > in. To me, that means our discussion needs to be focused on addressing > specific issues; we’re not going to redesign Guix services in this > thread. > > Andrew Tropin <andrew@trop.in> skribis: > > [...] > >>> Then that’s fine: you can have special code that emits those “source” >>> lines in .zshrc while still allowing users to provide their own >>> file-like object for .zshrc lines they want to add. Again, see how >>> ‘torrc’ is generated in ‘tor-service-type’. >> >> From what I understand you want a separate bashrc-file, >> bash-profile-file and bash-logout-file fields to be present, but where >> the content of those files should be inserted? At the beginning/end or >> instead of the rest of configuration? >> >> We already can achieve the same result by providing gexp, which will >> read the content of the file-like object, a very small helper for that >> (slurp-file-gexp) makes it even easier to do. Such approach is more >> flexible and doesn't seem much harder. >> >> I remember that you had concerns about slurp-file-gexp, but still don't >> understand what exactly you are concerned about. > > Let me restate my concerns: > > 1. Users are unlikely to fathom what this does, given the name. It > will end up in user configurations, yet: “slurp”? “gexp”? Sounds like a naming conecrn, I brought "slurp" word from clojure lang, but we can call it whatever sounds better for guile community generate-read-whole-file-gexp or anything else. Actually, we don't even need to have this wrapper to be present, just allow people to do #~(call-with-input-file file-like-object get-string-all) > > 2. ‘slurp-file-gexp’ returns code, as a gexp. Depending on the place > where that gexp is inserted, it may or may not work. Consider: > > (define (foo x) > #~(frob '(#$x))) > > (foo (slurp-file-gexp …)) ;d’oh! Yep, users can make mistakes, but it's not a technical problem, also, I see it quite unlikely to happen according to my experience supporting Guix Home users. > > 3. Use of ‘slurp-file-gexp’ and gexps in configuration records is not > consistent with the rest of the service APIs (and I think we can > humbly recognize that those APIs have been doing the job for a > while already.) It's not actually true, there are system services, which accept a list of strings/gexps and state it in the documentation, some of them do it in a less exlicit way, but still do, I found that trick looking at system service and made it an explicit pattern for home services. I tried to extract and follow patterns from system services, but found them quite inconsistent, so I took a few of them and wrote a few on my own. To name a few: extra-options @ alsa-configuration extra-config @ nix-configuration extra-config @ xorg-configuration extra-content @ nginx-configuration extra-config @ httpd-config-file contents @ httpd-virtualhost To make guix services configurations consistent (at least new ones) I think it would be cool to have a `Writing Service Configuration Guideline` section. I can share the design descisions I've made for home services configurations and after a discussion it can end up in a manual section giving a clean guideline, reducing subjective preferences and increasing consistency. If you are interested. > > Let’s just to the (call-with-input-file file get-string-all) dance in > places where it’s needed rather than let users call ‘slurp-file-gexp’. > This is roughly what the ‘tor-service-type’ example I gave does. > >> I'll write a few examples of service configurations and rationale behind >> the design descisions for that next week, to make the discussion more >> practically oriented. > > People are starting to use the tool and to report bugs. So, > unfortunately, we have to sort out interface issues quickly now. > > If some of the things being discussed turn out to be too complex to > address under those time constraints, we can consider taking them out > until we have a better idea on how to address them. > > How does that sound? > > Thanks, > Ludo’. -- Best regards, Andrew Tropin [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 832 bytes --] ^ permalink raw reply [flat|nested] 64+ messages in thread
* [bug#50967] file-like objects instead of gexps 2021-10-06 8:15 ` [bug#50967] file-like objects instead of gexps Andrew Tropin 2021-10-08 7:56 ` Ludovic Courtès @ 2021-10-08 13:45 ` Xinglu Chen 2021-10-08 14:34 ` Andrew Tropin 1 sibling, 1 reply; 64+ messages in thread From: Xinglu Chen @ 2021-10-08 13:45 UTC (permalink / raw) To: Andrew Tropin, Ludovic Courtès; +Cc: Oleg Pykhalov, 50967 [-- Attachment #1: Type: text/plain, Size: 3681 bytes --] On Wed, Oct 06 2021, Andrew Tropin wrote: > Imagine the following use case: I want to create a home service, which > accepts a package (zsh plugin) and adds a code for loading this package > to zshrc, currently it's implemented like that: > > https://git.sr.ht/~abcdw/rde/tree/69dd2baf0384c899a4a4f97bdac8bf0b6e499b82/item/gnu/home-services/shellutils.scm#L18 > > Exteding the service above with `(list zsh-autosuggestions)` will add > the following line to zshrc: > > source /gnu/store/w7d43gk1qszplj9i0rkzqvzz6kp88qfm-zsh-autosuggestions-0.7.0/share/zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh > > Or the same thing can be done manually by user: > > --8<---------------cut here---------------start------------->8--- > (service > home-zsh-service-type > (home-zsh-configuration > (zshrc > (list > #~(string-append "source " #$zsh-autosuggestions "/share/zs../..ions.zsh") > ;; or > "source \\" > (file-append zsh-autosuggestions "/share/zs../..ions.zsh"))))) > --8<---------------cut here---------------end--------------->8--- > > gexps returns a string, file-like object returns a path to the file in > the store, kinda expected behavior. Both implementations looks quite > simple. > > > Now I'll try to reimplement it with file-like objects. The code below > is a pseudo code, but should demonstrate the overall concerns I have: > > --8<---------------cut here---------------start------------->8--- > ;; Some generic functions > (define get-file-like-object-path (file-like) > "Because all file-like object get inserted literally by home services, > we need a function, which returns a file, which contains a path to the > file." > (computed-file > "tmp-file" > #~#$file-like)) > > (define fl-append-strings (lst) > "Accepts a list of strings and file-like object, reads the content of > the file-like objects (to be consistent with behavior of home services > configuration)." > (define file-like->str (mb-file-like) > (if (string? mb-file-like) > mb-file-like > #~(begin > (use-modules (ice-9 rdelim)) > (with-fluids ((%default-port-encoding "UTF-8")) > (with-input-from-file #$mb-file-like read-string))))) > (computed-file > "tmp-file" > #~(apply string-append '#$(map file-like->str lst)))) > > > ;; A home service, declared in home-environment. > (service > home-zsh-service-type > (home-zsh-configuration > (zshrc > (list > (fl-append-strings > (list > "source " > (get-file-like-object-path zsh-autosuggestions) > "/share/zs../..ions.zsh")) > ;; or > "source \\" > (get-file-like-object-path > (file-append zsh-autosuggestions "/share/zs../..ions.zsh")))))) > --8<---------------cut here---------------end--------------->8--- Wouldn’t something like the following work --8<---------------cut here---------------start------------->8--- (service home-zsh-service-type (home-zsh-configuration (zshrc (list (mixed-text-file "zshrc" "source " (file-append zsh-autosuggestions "/share/zsh/...")) (local-file "./some-zshrc"))))) --8<---------------cut here---------------end--------------->8--- and since ‘zshrc’ is already a list of file-like objects, we could implement ‘serialize-text-config’ using something like ‘fl-append-strings’, which would read the contents of the two files and append them. That way users don’t have to deal with ‘fl-append-strings’ or ‘slurp-file-gexp’. [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 861 bytes --] ^ permalink raw reply [flat|nested] 64+ messages in thread
* [bug#50967] file-like objects instead of gexps 2021-10-08 13:45 ` Xinglu Chen @ 2021-10-08 14:34 ` Andrew Tropin 0 siblings, 0 replies; 64+ messages in thread From: Andrew Tropin @ 2021-10-08 14:34 UTC (permalink / raw) To: Xinglu Chen, Ludovic Courtès; +Cc: Oleg Pykhalov, 50967 [-- Attachment #1: Type: text/plain, Size: 4149 bytes --] On 2021-10-08 15:45, Xinglu Chen wrote: > On Wed, Oct 06 2021, Andrew Tropin wrote: > >> Imagine the following use case: I want to create a home service, which >> accepts a package (zsh plugin) and adds a code for loading this package >> to zshrc, currently it's implemented like that: >> >> https://git.sr.ht/~abcdw/rde/tree/69dd2baf0384c899a4a4f97bdac8bf0b6e499b82/item/gnu/home-services/shellutils.scm#L18 >> >> Exteding the service above with `(list zsh-autosuggestions)` will add >> the following line to zshrc: >> >> source /gnu/store/w7d43gk1qszplj9i0rkzqvzz6kp88qfm-zsh-autosuggestions-0.7.0/share/zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh >> >> Or the same thing can be done manually by user: >> >> --8<---------------cut here---------------start------------->8--- >> (service >> home-zsh-service-type >> (home-zsh-configuration >> (zshrc >> (list >> #~(string-append "source " #$zsh-autosuggestions "/share/zs../..ions.zsh") >> ;; or >> "source \\" >> (file-append zsh-autosuggestions "/share/zs../..ions.zsh"))))) >> --8<---------------cut here---------------end--------------->8--- >> >> gexps returns a string, file-like object returns a path to the file in >> the store, kinda expected behavior. Both implementations looks quite >> simple. >> >> >> Now I'll try to reimplement it with file-like objects. The code below >> is a pseudo code, but should demonstrate the overall concerns I have: >> >> --8<---------------cut here---------------start------------->8--- >> ;; Some generic functions >> (define get-file-like-object-path (file-like) >> "Because all file-like object get inserted literally by home services, >> we need a function, which returns a file, which contains a path to the >> file." >> (computed-file >> "tmp-file" >> #~#$file-like)) >> >> (define fl-append-strings (lst) >> "Accepts a list of strings and file-like object, reads the content of >> the file-like objects (to be consistent with behavior of home services >> configuration)." >> (define file-like->str (mb-file-like) >> (if (string? mb-file-like) >> mb-file-like >> #~(begin >> (use-modules (ice-9 rdelim)) >> (with-fluids ((%default-port-encoding "UTF-8")) >> (with-input-from-file #$mb-file-like read-string))))) >> (computed-file >> "tmp-file" >> #~(apply string-append '#$(map file-like->str lst)))) >> >> >> ;; A home service, declared in home-environment. >> (service >> home-zsh-service-type >> (home-zsh-configuration >> (zshrc >> (list >> (fl-append-strings >> (list >> "source " >> (get-file-like-object-path zsh-autosuggestions) >> "/share/zs../..ions.zsh")) >> ;; or >> "source \\" >> (get-file-like-object-path >> (file-append zsh-autosuggestions "/share/zs../..ions.zsh")))))) >> --8<---------------cut here---------------end--------------->8--- > > Wouldn’t something like the following work > > --8<---------------cut here---------------start------------->8--- > (service home-zsh-service-type > (home-zsh-configuration > (zshrc > (list (mixed-text-file > "zshrc" > "source " > (file-append zsh-autosuggestions "/share/zsh/...")) ^ place1 > (local-file "./some-zshrc"))))) ^ place2 > --8<---------------cut here---------------end--------------->8--- > > and since ‘zshrc’ is already a list of file-like objects, we could > implement ‘serialize-text-config’ using something like > ‘fl-append-strings’, which would read the contents of the two files and > append them. That way users don’t have to deal with ‘fl-append-strings’ > or ‘slurp-file-gexp’. Yep, it looks much better than what I was trying to prototype. Still feels inconsistent that file-like object in place1 will be evaluated to the path in the store, but in place2 to the content of the file. -- Best regards, Andrew Tropin [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 832 bytes --] ^ permalink raw reply [flat|nested] 64+ messages in thread
* [bug#50967] [PATCH 13/14] home: services: configuration: Support file-like objects. 2021-10-02 16:38 ` [bug#50967] [PATCH 13/14] home: services: configuration: Support file-like objects Oleg Pykhalov 2021-10-02 18:35 ` Xinglu Chen @ 2021-10-08 10:06 ` Andrew Tropin 2021-10-14 7:08 ` Andrew Tropin 2 siblings, 0 replies; 64+ messages in thread From: Andrew Tropin @ 2021-10-08 10:06 UTC (permalink / raw) To: Oleg Pykhalov, 50967; +Cc: Oleg Pykhalov [-- Attachment #1: Type: text/plain, Size: 3532 bytes --] On 2021-10-02 19:38, Oleg Pykhalov wrote: > * gnu/home/services/configuration.scm (interpose): Include content of files. > (string-or-gexp?): Rename to 'file-or-string-or-gexp?' and check for file-like > object. > (serialize-string-or-gexp): Rename to 'serialize-file-or-string-or-gexp'. > (text-config?): Call 'file-or-string-or-gexp?' intead of 'string-or-gexp?'. > * guix/scripts/home/import.scm: > (generate-bash-module+configuration): Don't call slurp-file-gexp. > --- > gnu/home/services/configuration.scm | 14 ++++++++++---- > guix/scripts/home/import.scm | 8 +++----- > 2 files changed, 13 insertions(+), 9 deletions(-) > > diff --git a/gnu/home/services/configuration.scm b/gnu/home/services/configuration.scm > index 5e7743e7d6..39db7a5693 100644 > --- a/gnu/home/services/configuration.scm > +++ b/gnu/home/services/configuration.scm > @@ -59,7 +59,12 @@ DELIMITER interposed LS. Support 'infix and 'suffix GRAMMAR values." > (G_ "The GRAMMAR value must be 'infix or 'suffix, but ~a provided.") > grammar))) > (fold-right (lambda (e acc) > - (cons e > + (cons (if (file-like? e) > + #~(begin > + (use-modules (ice-9 rdelim)) > + (with-fluids ((%default-port-encoding "UTF-8")) > + (with-input-from-file #$e read-string))) > + e) > (if (and (null? acc) (eq? grammar 'infix)) > acc > (cons delimiter acc)))) > @@ -79,11 +84,12 @@ the list result in @code{#t} when applying PRED? on them." > > (define alist? list?) > > -(define (string-or-gexp? sg) (or (string? sg) (gexp? sg))) > -(define (serialize-string-or-gexp field-name val) "") > +(define (file-or-string-or-gexp? fsg) > + (or (string? fsg) (gexp? fsg) (file-like? fsg))) > +(define (serialize-file-or-string-or-gexp field-name val) "") > > (define (text-config? config) > - (and (list? config) (every string-or-gexp? config))) > + (and (list? config) (every file-or-string-or-gexp? config))) > (define (serialize-text-config field-name val) > #~(string-append #$@(interpose val "\n" 'suffix))) > > diff --git a/guix/scripts/home/import.scm b/guix/scripts/home/import.scm > index c977ec3861..611f580e85 100644 > --- a/guix/scripts/home/import.scm > +++ b/guix/scripts/home/import.scm > @@ -46,17 +46,15 @@ > (home-bash-configuration > ,@(if (file-exists? rc) > `((bashrc > - (list (slurp-file-gexp (local-file ,rc))))) > + (list (local-file ,rc)))) > '()) > ,@(if (file-exists? profile) > `((bash-profile > - (list (slurp-file-gexp > - (local-file ,profile))))) > + (list (local-file ,profile)))) > '()) > ,@(if (file-exists? logout) > `((bash-logout > - (list (slurp-file-gexp > - (local-file ,logout))))) > + (list (local-file ,logout)))) > '())))))) I think this patch requires more discussion and better to keep it outside of this patch series. Skimmed throught other patches, overall LGTM. -- Best regards, Andrew Tropin [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 832 bytes --] ^ permalink raw reply [flat|nested] 64+ messages in thread
* [bug#50967] [PATCH 13/14] home: services: configuration: Support file-like objects. 2021-10-02 16:38 ` [bug#50967] [PATCH 13/14] home: services: configuration: Support file-like objects Oleg Pykhalov 2021-10-02 18:35 ` Xinglu Chen 2021-10-08 10:06 ` [bug#50967] [PATCH 13/14] home: services: configuration: Support file-like objects Andrew Tropin @ 2021-10-14 7:08 ` Andrew Tropin 2 siblings, 0 replies; 64+ messages in thread From: Andrew Tropin @ 2021-10-14 7:08 UTC (permalink / raw) To: Oleg Pykhalov, 50967; +Cc: Oleg Pykhalov [-- Attachment #1: Type: text/plain, Size: 3877 bytes --] On 2021-10-02 19:38, Oleg Pykhalov wrote: > * gnu/home/services/configuration.scm (interpose): Include content of files. > (string-or-gexp?): Rename to 'file-or-string-or-gexp?' and check for file-like > object. > (serialize-string-or-gexp): Rename to 'serialize-file-or-string-or-gexp'. > (text-config?): Call 'file-or-string-or-gexp?' intead of 'string-or-gexp?'. > * guix/scripts/home/import.scm: > (generate-bash-module+configuration): Don't call slurp-file-gexp. > --- > gnu/home/services/configuration.scm | 14 ++++++++++---- > guix/scripts/home/import.scm | 8 +++----- > 2 files changed, 13 insertions(+), 9 deletions(-) > > diff --git a/gnu/home/services/configuration.scm b/gnu/home/services/configuration.scm > index 5e7743e7d6..39db7a5693 100644 > --- a/gnu/home/services/configuration.scm > +++ b/gnu/home/services/configuration.scm > @@ -59,7 +59,12 @@ DELIMITER interposed LS. Support 'infix and 'suffix GRAMMAR values." > (G_ "The GRAMMAR value must be 'infix or 'suffix, but ~a provided.") > grammar))) > (fold-right (lambda (e acc) > - (cons e > + (cons (if (file-like? e) > + #~(begin > + (use-modules (ice-9 rdelim)) > + (with-fluids ((%default-port-encoding "UTF-8")) > + (with-input-from-file #$e read-string))) This transformation should not be a part of interpose function, interpose does know nothing about elements type and doesn't have to know. This addition is semantically incorrect and also contradictionary to docstring. It also breaks downstream channels. The version of change in master is different, it doesn't even check element type. I'm strongly against this change. If it necessary to make transformation of elements of the list it should be done outside of interpose. > + e) > (if (and (null? acc) (eq? grammar 'infix)) > acc > (cons delimiter acc)))) > @@ -79,11 +84,12 @@ the list result in @code{#t} when applying PRED? on them." > > (define alist? list?) > > -(define (string-or-gexp? sg) (or (string? sg) (gexp? sg))) > -(define (serialize-string-or-gexp field-name val) "") > +(define (file-or-string-or-gexp? fsg) > + (or (string? fsg) (gexp? fsg) (file-like? fsg))) > +(define (serialize-file-or-string-or-gexp field-name val) "") > > (define (text-config? config) > - (and (list? config) (every string-or-gexp? config))) > + (and (list? config) (every file-or-string-or-gexp? config))) > (define (serialize-text-config field-name val) > #~(string-append #$@(interpose val "\n" 'suffix))) > > diff --git a/guix/scripts/home/import.scm b/guix/scripts/home/import.scm > index c977ec3861..611f580e85 100644 > --- a/guix/scripts/home/import.scm > +++ b/guix/scripts/home/import.scm > @@ -46,17 +46,15 @@ > (home-bash-configuration > ,@(if (file-exists? rc) > `((bashrc > - (list (slurp-file-gexp (local-file ,rc))))) > + (list (local-file ,rc)))) > '()) > ,@(if (file-exists? profile) > `((bash-profile > - (list (slurp-file-gexp > - (local-file ,profile))))) > + (list (local-file ,profile)))) > '()) > ,@(if (file-exists? logout) > `((bash-logout > - (list (slurp-file-gexp > - (local-file ,logout))))) > + (list (local-file ,logout)))) > '())))))) -- Best regards, Andrew Tropin [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 832 bytes --] ^ permalink raw reply [flat|nested] 64+ messages in thread
* [bug#50967] [PATCH 14/14] doc: Document guix home import. 2021-10-02 16:38 ` [bug#50967] [PATCH 01/14] tests: Add tests for guix home cli Oleg Pykhalov ` (11 preceding siblings ...) 2021-10-02 16:38 ` [bug#50967] [PATCH 13/14] home: services: configuration: Support file-like objects Oleg Pykhalov @ 2021-10-02 16:38 ` Oleg Pykhalov 2021-10-02 18:42 ` Xinglu Chen 2021-10-04 13:58 ` [bug#50967] [PATCH 00/12] Move (gnu home-services XYZ) to (gnu services XYZ) Ludovic Courtès 13 siblings, 1 reply; 64+ messages in thread From: Oleg Pykhalov @ 2021-10-02 16:38 UTC (permalink / raw) To: 50967; +Cc: Oleg Pykhalov * doc/guix.texi (Invoking guix home): Document guix home import. --- doc/guix.texi | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/doc/guix.texi b/doc/guix.texi index d641935e0f..2f09f50629 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -36091,6 +36091,10 @@ generations that are up to 10 days old: $ guix home list-generations 10d @end example +@item import +Generate a Scheme code template that could be saved as a file and passed +to @command{guix home reconfigure} command. + @end table @node Documentation -- 2.33.0 ^ permalink raw reply related [flat|nested] 64+ messages in thread
* [bug#50967] [PATCH 14/14] doc: Document guix home import. 2021-10-02 16:38 ` [bug#50967] [PATCH 14/14] doc: Document guix home import Oleg Pykhalov @ 2021-10-02 18:42 ` Xinglu Chen 2021-10-02 19:45 ` Oleg Pykhalov 0 siblings, 1 reply; 64+ messages in thread From: Xinglu Chen @ 2021-10-02 18:42 UTC (permalink / raw) To: Oleg Pykhalov, 50967; +Cc: Oleg Pykhalov [-- Attachment #1: Type: text/plain, Size: 367 bytes --] On Sat, Oct 02 2021, Oleg Pykhalov wrote: > * doc/guix.texi (Invoking guix home): Document guix home import. > --- > doc/guix.texi | 4 ++++ > 1 file changed, 4 insertions(+) I sent a patch that documents ‘guix home import’ in a separate series which also fixes some things about ‘guix home import’[1]. [1]: <https://issues.guix.gnu.org/50873> [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 861 bytes --] ^ permalink raw reply [flat|nested] 64+ messages in thread
* [bug#50967] [PATCH 14/14] doc: Document guix home import. 2021-10-02 18:42 ` Xinglu Chen @ 2021-10-02 19:45 ` Oleg Pykhalov 0 siblings, 0 replies; 64+ messages in thread From: Oleg Pykhalov @ 2021-10-02 19:45 UTC (permalink / raw) To: Xinglu Chen; +Cc: 50967 [-- Attachment #1: Type: text/plain, Size: 465 bytes --] Xinglu Chen <public@yoctocell.xyz> writes: > On Sat, Oct 02 2021, Oleg Pykhalov wrote: > >> * doc/guix.texi (Invoking guix home): Document guix home import. >> --- >> doc/guix.texi | 4 ++++ >> 1 file changed, 4 insertions(+) > > I sent a patch that documents ‘guix home import’ in a separate series > which also fixes some things about ‘guix home import’[1]. > > [1]: <https://issues.guix.gnu.org/50873> OK, then I just remove my commit. [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 861 bytes --] ^ permalink raw reply [flat|nested] 64+ messages in thread
* [bug#50967] [PATCH 00/12] Move (gnu home-services XYZ) to (gnu services XYZ) 2021-10-02 16:38 ` [bug#50967] [PATCH 01/14] tests: Add tests for guix home cli Oleg Pykhalov ` (12 preceding siblings ...) 2021-10-02 16:38 ` [bug#50967] [PATCH 14/14] doc: Document guix home import Oleg Pykhalov @ 2021-10-04 13:58 ` Ludovic Courtès 2021-10-04 23:13 ` [bug#50967] [PATCH 1/3] gnu: Move (gnu home-services) to (gnu home services) Oleg Pykhalov 13 siblings, 1 reply; 64+ messages in thread From: Ludovic Courtès @ 2021-10-04 13:58 UTC (permalink / raw) To: Oleg Pykhalov; +Cc: 50967, Andrew Tropin Hi Oleg, Oleg Pykhalov <go.wigust@gmail.com> skribis: > From: Andrew Tropin <andrew@trop.in> > > * tests/guix-home.sh: New file. > * Makefile.am (SH_TESTS): Add tests/guix-home.sh. > > Signed-off-by: Oleg Pykhalov <go.wigust@gmail.com> [...] > +# Reporting of syntax errors. > + > +cat > "$tmpfile"<<EOF > +;; This is line 1, and the next one is line 2. > + (home-environment > + (packages)) > +;; The 'T' is at column 3. > +EOF This test is more or less copied from guix-system.sh, and I think it’s not that useful because it’s testing the exact same functionality. Would it be possible to have a CLI test that really tests ‘guix home’ functionality? The difficulty is that this would tend to rebuild the world. This can be worked around in one of two ways: 1. Add a ‘--bootstrap’ flag for force the use of the “guile-bootstrap” package instead of “guile”, for instance, as is done for tests/guix-package.sh. 2. Run tests only when a “real” daemon is available, using it instead of the test daemon, as is done in tests/guix-pack-relocatable.sh. 3. Run tests in a VM using the (gnu tests …) infrastructure. I don’t think #1 would work well for Guix Home. #2 is the easiest; the downside is that tests would only be run on developer machines, not in CI. #3 is the most flexible approach, but the downside is that it’s more resource-intensive (needs to build a VM image, etc.). Overall, I’d recommend starting with #2 and eventually add tests as #3, as far as integration tests are concerned. Then again, it’s also possible to have focused unit tests for specific pieces, just like we have tests/union.scm for instance. WDYT? Thanks, Ludo’. ^ permalink raw reply [flat|nested] 64+ messages in thread
* [bug#50967] [PATCH 1/3] gnu: Move (gnu home-services) to (gnu home services). 2021-10-04 13:58 ` [bug#50967] [PATCH 00/12] Move (gnu home-services XYZ) to (gnu services XYZ) Ludovic Courtès @ 2021-10-04 23:13 ` Oleg Pykhalov 2021-10-04 23:13 ` [bug#50967] [PATCH 2/3] home: services: configuration: Support file-like objects Oleg Pykhalov ` (3 more replies) 0 siblings, 4 replies; 64+ messages in thread From: Oleg Pykhalov @ 2021-10-04 23:13 UTC (permalink / raw) To: 50967; +Cc: Oleg Pykhalov, Ludovic Courtès, Xinglu Chen, Andrew Tropin * gnu/home-services/configuration.scm: Move the content ... * gnu/home/services/configuration.scm: ... here. * gnu/local.mk (GNU_SYSTEM_MODULES): Same. * gnu/home-services/shells.scm: Replace (gnu home-services configuration) with (gnu home services configuration). * gnu/home-services/xdg.scm: Same. * gnu/home-services/symlink-manager.scm: Rename to gnu/home/services/symlink-manager.scm. * gnu/local.mk: Same. * gnu/home.scm: Replace (gnu home-services symlink-manager) with (gnu home services symlink-manager). * gnu/home-services/utils.scm: Rename to gnu/home/services/utils.scm. * gnu/local.mk: Same. * gnu/home-services/shells.scm: Replace (gnu home-services utils) with (gnu home services utils). * gnu/home-services/xdg.scm: Same. * gnu/home-services/fontutils.scm: Rename to gnu/services/fontutils.scm. * gnu/local.mk: Same. * gnu/home.scm: Replace (gnu home-services fontutils) with (gnu services fontutils). * gnu/home-services/shells.scm: Rename to gnu/home/services/shells.scm. * gnu/local.mk: Same. * gnu/home.scm: Replace (gnu home-services shells) with (gnu home services shells). * doc/he-config-bare-bones.scm: Same. * gnu/home-services/xdg.scm: Rename to gnu/home/services/xdg.scm. * gnu/local.mk: Same. * gnu/home.scm: Replace (gnu home-services xdg) with (gnu home services xdg). * gnu/home-services/shepherd.scm: Move to gnu/home/services/shepherd.scm. * gnu/local.mk: Same. * gnu/home-services/mcron.scm: Replace (gnu home-services shepherd) with (gnu home services shepherd). * tests/guix-home.sh: Same. * gnu/home-services/mcron.scm: Move to gnu/home/services/mcron.scm. * gnu/local.mk: Same. * doc/guix.texi: Replace (gnu home-services mcron) with (gnu home services mcron). * guix/scripts/home/import.scm: Replace (gnu home-services bash) with (gnu home services bash). * doc/guix.texi: Replace (gnu home-services) with (gnu home services). * gnu/home-services.scm (%service-type-path): Search home services in "gnu/services". * gnu/home-services.scm: Update documentation string. --- doc/guix.texi | 8 ++++---- doc/he-config-bare-bones.scm | 2 +- gnu/home-services.scm | 4 ++-- gnu/home.scm | 8 ++++---- .../services}/configuration.scm | 2 +- .../services}/fontutils.scm | 2 +- gnu/{home-services => home/services}/mcron.scm | 4 ++-- gnu/{home-services => home/services}/shells.scm | 6 +++--- .../services}/shepherd.scm | 2 +- .../services}/symlink-manager.scm | 2 +- gnu/{home-services => home/services}/utils.scm | 2 +- gnu/{home-services => home/services}/xdg.scm | 6 +++--- gnu/local.mk | 16 ++++++++-------- guix/scripts/home/import.scm | 2 +- 14 files changed, 33 insertions(+), 33 deletions(-) rename gnu/{home-services => home/services}/configuration.scm (98%) rename gnu/{home-services => home/services}/fontutils.scm (98%) rename gnu/{home-services => home/services}/mcron.scm (98%) rename gnu/{home-services => home/services}/shells.scm (99%) rename gnu/{home-services => home/services}/shepherd.scm (99%) rename gnu/{home-services => home/services}/symlink-manager.scm (99%) rename gnu/{home-services => home/services}/utils.scm (98%) rename gnu/{home-services => home/services}/xdg.scm (99%) diff --git a/doc/guix.texi b/doc/guix.texi index a72a726b54..d641935e0f 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -35555,9 +35555,9 @@ services)}. @node Essential Home Services @subsection Essential Home Services -There are a few essential services defined in @code{(gnu -home-services)}, they are mostly for internal use and are required to -build a home environment, but some of them will be useful for the end +There are a few essential home services defined in +@code{(gnu services)}, they are mostly for internal use and are required +to build a home environment, but some of them will be useful for the end user. @cindex environment variables @@ -35810,7 +35810,7 @@ for example). @cindex mcron @cindex scheduling jobs -The @code{(gnu home-services mcron)} module provides an interface to +The @code{(gnu home services mcron)} module provides an interface to GNU@tie{}mcron, a daemon to run jobs at scheduled times (@pxref{Top,,, mcron, GNU@tie{}mcron}). The information about system's mcron is applicable here (@pxref{Scheduled Job Execution}), the only difference diff --git a/doc/he-config-bare-bones.scm b/doc/he-config-bare-bones.scm index 01be46a7b0..1faf75b871 100644 --- a/doc/he-config-bare-bones.scm +++ b/doc/he-config-bare-bones.scm @@ -1,6 +1,6 @@ (use-modules (gnu home) (gnu home-services) - (gnu home-services shells) + (gnu home services shells) (gnu services) (gnu packages admin) (guix gexp)) diff --git a/gnu/home-services.scm b/gnu/home-services.scm index 9f1e986616..a244a15511 100644 --- a/gnu/home-services.scm +++ b/gnu/home-services.scm @@ -512,10 +512,10 @@ environment, and its configuration file, when available."))) (define %service-type-path ;; Search path for service types. - (make-parameter `((,%guix-home-root-directory . "gnu/home-services")))) + (make-parameter `((,%guix-home-root-directory . "gnu/home/services")))) (define (all-home-service-modules) - "Return the default set of 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))) diff --git a/gnu/home.scm b/gnu/home.scm index f4c9359e25..5ac382dc5a 100644 --- a/gnu/home.scm +++ b/gnu/home.scm @@ -18,10 +18,10 @@ (define-module (gnu home) #:use-module (gnu home-services) - #:use-module (gnu home-services symlink-manager) - #:use-module (gnu home-services shells) - #:use-module (gnu home-services xdg) - #:use-module (gnu home-services fontutils) + #:use-module (gnu home services symlink-manager) + #:use-module (gnu home services shells) + #:use-module (gnu home services xdg) + #:use-module (gnu home services fontutils) #:use-module (gnu services) #:use-module (guix records) #:use-module (guix diagnostics) diff --git a/gnu/home-services/configuration.scm b/gnu/home/services/configuration.scm similarity index 98% rename from gnu/home-services/configuration.scm rename to gnu/home/services/configuration.scm index e8f4bc77ec..5e7743e7d6 100644 --- a/gnu/home-services/configuration.scm +++ b/gnu/home/services/configuration.scm @@ -17,7 +17,7 @@ ;;; 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 configuration) +(define-module (gnu home services configuration) #:use-module (gnu services configuration) #:use-module (guix gexp) #:use-module (srfi srfi-1) diff --git a/gnu/home-services/fontutils.scm b/gnu/home/services/fontutils.scm similarity index 98% rename from gnu/home-services/fontutils.scm rename to gnu/home/services/fontutils.scm index 28bfc3d3f7..72a84fdecd 100644 --- a/gnu/home-services/fontutils.scm +++ b/gnu/home/services/fontutils.scm @@ -17,7 +17,7 @@ ;;; 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 fontutils) +(define-module (gnu home services fontutils) #:use-module (gnu home-services) #:use-module (gnu packages fontutils) #:use-module (guix gexp) diff --git a/gnu/home-services/mcron.scm b/gnu/home/services/mcron.scm similarity index 98% rename from gnu/home-services/mcron.scm rename to gnu/home/services/mcron.scm index fdfde179a5..cc6faac47f 100644 --- a/gnu/home-services/mcron.scm +++ b/gnu/home/services/mcron.scm @@ -17,11 +17,11 @@ ;;; 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 mcron) +(define-module (gnu home services mcron) #:use-module (gnu packages guile-xyz) #:use-module (gnu home-services) - #:use-module (gnu home-services shepherd) #:use-module (gnu services shepherd) + #:use-module (gnu home services shepherd) #:use-module (guix records) #:use-module (guix gexp) #:use-module (srfi srfi-1) diff --git a/gnu/home-services/shells.scm b/gnu/home/services/shells.scm similarity index 99% rename from gnu/home-services/shells.scm rename to gnu/home/services/shells.scm index ecb02098f7..2308371dd0 100644 --- a/gnu/home-services/shells.scm +++ b/gnu/home/services/shells.scm @@ -17,10 +17,10 @@ ;;; 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 shells) +(define-module (gnu home services shells) #:use-module (gnu services configuration) - #:use-module (gnu home-services configuration) - #:use-module (gnu home-services utils) + #:use-module (gnu home services configuration) + #:use-module (gnu home services utils) #:use-module (gnu home-services) #:use-module (gnu packages shells) #:use-module (gnu packages bash) diff --git a/gnu/home-services/shepherd.scm b/gnu/home/services/shepherd.scm similarity index 99% rename from gnu/home-services/shepherd.scm rename to gnu/home/services/shepherd.scm index 120cfde1a1..1a3e849bb2 100644 --- a/gnu/home-services/shepherd.scm +++ b/gnu/home/services/shepherd.scm @@ -17,7 +17,7 @@ ;;; 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 shepherd) +(define-module (gnu home services shepherd) #:use-module (gnu home-services) #:use-module (gnu packages admin) #:use-module (gnu services shepherd) diff --git a/gnu/home-services/symlink-manager.scm b/gnu/home/services/symlink-manager.scm similarity index 99% rename from gnu/home-services/symlink-manager.scm rename to gnu/home/services/symlink-manager.scm index 11f5d503d4..d53e8f5046 100644 --- a/gnu/home-services/symlink-manager.scm +++ b/gnu/home/services/symlink-manager.scm @@ -17,7 +17,7 @@ ;;; 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 symlink-manager) +(define-module (gnu home services symlink-manager) #:use-module (gnu home-services) #:use-module (guix gexp) diff --git a/gnu/home-services/utils.scm b/gnu/home/services/utils.scm similarity index 98% rename from gnu/home-services/utils.scm rename to gnu/home/services/utils.scm index f13133a7ae..cea75ee896 100644 --- a/gnu/home-services/utils.scm +++ b/gnu/home/services/utils.scm @@ -17,7 +17,7 @@ ;;; 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 utils) +(define-module (gnu home services utils) #:use-module (ice-9 string-fun) #:use-module (srfi srfi-1) #:use-module (srfi srfi-26) diff --git a/gnu/home-services/xdg.scm b/gnu/home/services/xdg.scm similarity index 99% rename from gnu/home-services/xdg.scm rename to gnu/home/services/xdg.scm index 94275f3b65..4aed9a5803 100644 --- a/gnu/home-services/xdg.scm +++ b/gnu/home/services/xdg.scm @@ -17,12 +17,12 @@ ;;; 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 xdg) +(define-module (gnu home services xdg) #:use-module (gnu services configuration) - #:use-module (gnu home-services configuration) + #:use-module (gnu home services configuration) #:use-module (gnu home-services) #:use-module (gnu packages freedesktop) - #:use-module (gnu home-services utils) + #:use-module (gnu home services utils) #:use-module (guix gexp) #:use-module (guix records) #:use-module (guix i18n) diff --git a/gnu/local.mk b/gnu/local.mk index d415b892e9..5e8b769ce9 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -75,14 +75,14 @@ GNU_SYSTEM_MODULES = \ %D%/ci.scm \ %D%/home.scm \ %D%/home-services.scm \ - %D%/home-services/symlink-manager.scm \ - %D%/home-services/fontutils.scm \ - %D%/home-services/configuration.scm \ - %D%/home-services/shells.scm \ - %D%/home-services/shepherd.scm \ - %D%/home-services/mcron.scm \ - %D%/home-services/utils.scm \ - %D%/home-services/xdg.scm \ + %D%/home/services/symlink-manager.scm \ + %D%/home/services/fontutils.scm \ + %D%/home/services/configuration.scm \ + %D%/home/services/shells.scm \ + %D%/home/services/shepherd.scm \ + %D%/home/services/mcron.scm \ + %D%/home/services/utils.scm \ + %D%/home/services/xdg.scm \ %D%/image.scm \ %D%/packages.scm \ %D%/packages/abduco.scm \ diff --git a/guix/scripts/home/import.scm b/guix/scripts/home/import.scm index 79fb23a2fd..c977ec3861 100644 --- a/guix/scripts/home/import.scm +++ b/guix/scripts/home/import.scm @@ -41,7 +41,7 @@ (let ((rc (string-append (getenv "HOME") "/.bashrc")) (profile (string-append (getenv "HOME") "/.bash_profile")) (logout (string-append (getenv "HOME") "/.bash_logout"))) - `((gnu home-services bash) + `((gnu home services bash) (service home-bash-service-type (home-bash-configuration ,@(if (file-exists? rc) -- 2.33.0 ^ permalink raw reply related [flat|nested] 64+ messages in thread
* [bug#50967] [PATCH 2/3] home: services: configuration: Support file-like objects. 2021-10-04 23:13 ` [bug#50967] [PATCH 1/3] gnu: Move (gnu home-services) to (gnu home services) Oleg Pykhalov @ 2021-10-04 23:13 ` Oleg Pykhalov 2021-10-04 23:13 ` [bug#50967] [PATCH 3/3] guix: scripts: Make sure profile directory exists Oleg Pykhalov ` (2 subsequent siblings) 3 siblings, 0 replies; 64+ messages in thread From: Oleg Pykhalov @ 2021-10-04 23:13 UTC (permalink / raw) To: 50967; +Cc: Oleg Pykhalov, Ludovic Courtès, Xinglu Chen, Andrew Tropin * gnu/home/services/configuration.scm (interpose): Operate only with file-like objects. (string-or-gexp?): Delete procedure. (serialize-string-or-gexp): Rename to 'serialize-file-like'. (text-config?): Call 'file-like' intead of 'string-or-gexp?'. * guix/scripts/home/import.scm: (generate-bash-module+configuration): Don't call slurp-file-gexp. * gnu/home/services/configuration.scm: Move content ... * gnu/services/configuration.scm: here. * gnu/home/services/shells.scm: Delete (gnu home services configuration). * gnu/home/services/xdg.scm: Same. * gnu/local.mk: Same. --- gnu/home/services/configuration.scm | 109 ---------------------------- gnu/home/services/shells.scm | 1 - gnu/home/services/xdg.scm | 1 - gnu/local.mk | 1 - gnu/services/configuration.scm | 90 ++++++++++++++++++++++- guix/scripts/home/import.scm | 8 +- 6 files changed, 91 insertions(+), 119 deletions(-) delete mode 100644 gnu/home/services/configuration.scm diff --git a/gnu/home/services/configuration.scm b/gnu/home/services/configuration.scm deleted file mode 100644 index 5e7743e7d6..0000000000 --- a/gnu/home/services/configuration.scm +++ /dev/null @@ -1,109 +0,0 @@ -;;; 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 configuration) - #:use-module (gnu services configuration) - #:use-module (guix gexp) - #:use-module (srfi srfi-1) - #:use-module (ice-9 curried-definitions) - #:use-module (ice-9 match) - #:use-module (guix i18n) - #:use-module (guix diagnostics) - - #:export (filter-configuration-fields - - interpose - list-of - - list-of-strings? - alist? - string-or-gexp? - serialize-string-or-gexp - text-config? - serialize-text-config - generic-serialize-alist-entry - generic-serialize-alist)) - -(define* (filter-configuration-fields configuration-fields fields - #:optional negate?) - "Retrieve the fields listed in FIELDS from CONFIGURATION-FIELDS. -If NEGATE? is @code{#t}, retrieve all fields except FIELDS." - (filter (lambda (field) - (let ((member? (member (configuration-field-name field) fields))) - (if (not negate?) member? (not member?)))) - configuration-fields)) - - -(define* (interpose ls #:optional (delimiter "\n") (grammar 'infix)) - "Same as @code{string-join}, but without join and string, returns an -DELIMITER interposed LS. Support 'infix and 'suffix GRAMMAR values." - (when (not (member grammar '(infix suffix))) - (raise - (formatted-message - (G_ "The GRAMMAR value must be 'infix or 'suffix, but ~a provided.") - grammar))) - (fold-right (lambda (e acc) - (cons e - (if (and (null? acc) (eq? grammar 'infix)) - acc - (cons delimiter acc)))) - '() ls)) - -(define (list-of pred?) - "Return a procedure that takes a list and check if all the elements of -the list result in @code{#t} when applying PRED? on them." - (lambda (x) - (if (list? x) - (every pred? x) - #f))) - - -(define list-of-strings? - (list-of string?)) - -(define alist? list?) - -(define (string-or-gexp? sg) (or (string? sg) (gexp? sg))) -(define (serialize-string-or-gexp field-name val) "") - -(define (text-config? config) - (and (list? config) (every string-or-gexp? config))) -(define (serialize-text-config field-name val) - #~(string-append #$@(interpose val "\n" 'suffix))) - -(define ((generic-serialize-alist-entry serialize-field) entry) - "Apply the SERIALIZE-FIELD procedure on the field and value of ENTRY." - (match entry - ((field . val) (serialize-field field val)))) - -(define (generic-serialize-alist combine serialize-field fields) - "Generate a configuration from an association list FIELDS. - -SERIALIZE-FIELD is a procedure that takes two arguments, it will be -applied on the fields and values of FIELDS using the -@code{generic-serialize-alist-entry} procedure. - -COMBINE is a procedure that takes one or more arguments and combines -all the alist entries into one value, @code{string-append} or -@code{append} are usually good candidates for this. - -See the @code{serialize-alist} procedure in `@code{(gnu home-services -version-control}' for an example usage.)}" - (apply combine - (map (generic-serialize-alist-entry serialize-field) fields))) diff --git a/gnu/home/services/shells.scm b/gnu/home/services/shells.scm index 2308371dd0..4e5825962c 100644 --- a/gnu/home/services/shells.scm +++ b/gnu/home/services/shells.scm @@ -19,7 +19,6 @@ (define-module (gnu home services shells) #:use-module (gnu services configuration) - #:use-module (gnu home services configuration) #:use-module (gnu home services utils) #:use-module (gnu home-services) #:use-module (gnu packages shells) diff --git a/gnu/home/services/xdg.scm b/gnu/home/services/xdg.scm index 4aed9a5803..c285d126dd 100644 --- a/gnu/home/services/xdg.scm +++ b/gnu/home/services/xdg.scm @@ -19,7 +19,6 @@ (define-module (gnu home services xdg) #:use-module (gnu services configuration) - #:use-module (gnu home services configuration) #:use-module (gnu home-services) #:use-module (gnu packages freedesktop) #:use-module (gnu home services utils) diff --git a/gnu/local.mk b/gnu/local.mk index 5e8b769ce9..9c3bf44a2b 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -77,7 +77,6 @@ GNU_SYSTEM_MODULES = \ %D%/home-services.scm \ %D%/home/services/symlink-manager.scm \ %D%/home/services/fontutils.scm \ - %D%/home/services/configuration.scm \ %D%/home/services/shells.scm \ %D%/home/services/shepherd.scm \ %D%/home/services/mcron.scm \ diff --git a/gnu/services/configuration.scm b/gnu/services/configuration.scm index df3d3b6f9b..60ab75b0c1 100644 --- a/gnu/services/configuration.scm +++ b/gnu/services/configuration.scm @@ -4,6 +4,7 @@ ;;; Copyright © 2017, 2018 Clément Lassieur <clement@lassieur.org> ;;; Copyright © 2021 Xinglu Chen <public@yoctocell.xyz> ;;; Copyright © 2021 Maxim Cournoyer <maxim.cournoyer@gmail.com> +;;; Copyright © 2021 Andrew Tropin <andrew@trop.in> ;;; ;;; This file is part of GNU Guix. ;;; @@ -25,10 +26,12 @@ #:use-module (guix records) #:use-module (guix gexp) #:use-module ((guix utils) #:select (source-properties->location)) - #:use-module ((guix diagnostics) #:select (location-file)) + #:use-module ((guix diagnostics) #:select (formatted-message location-file)) #:use-module ((guix modules) #:select (file-name->module-name)) + #:use-module (guix i18n) #:autoload (texinfo) (texi-fragment->stexi) #:autoload (texinfo serialize) (stexi->texi) + #:use-module (ice-9 curried-definitions) #:use-module (ice-9 match) #:use-module (srfi srfi-1) #:use-module (srfi srfi-34) @@ -56,7 +59,20 @@ generate-documentation configuration->documentation empty-serializer - serialize-package)) + serialize-package + + filter-configuration-fields + + interpose + list-of + + list-of-strings? + alist? + serialize-file-like + text-config? + serialize-text-config + generic-serialize-alist-entry + generic-serialize-alist)) ;;; Commentary: ;;; @@ -323,3 +339,73 @@ Texinfo documentation of its fields." '-fields)))) (display (generate-documentation `((,configuration-symbol ,fields-getter)) configuration-symbol)))) + +(define* (filter-configuration-fields configuration-fields fields + #:optional negate?) + "Retrieve the fields listed in FIELDS from CONFIGURATION-FIELDS. +If NEGATE? is @code{#t}, retrieve all fields except FIELDS." + (filter (lambda (field) + (let ((member? (member (configuration-field-name field) fields))) + (if (not negate?) member? (not member?)))) + configuration-fields)) + + +(define* (interpose ls #:optional (delimiter "\n") (grammar 'infix)) + "Same as @code{string-join}, but without join and string, returns an +DELIMITER interposed LS. Support 'infix and 'suffix GRAMMAR values." + (when (not (member grammar '(infix suffix))) + (raise + (formatted-message + (G_ "The GRAMMAR value must be 'infix or 'suffix, but ~a provided.") + grammar))) + (fold-right (lambda (e acc) + (cons #~(begin + (use-modules (ice-9 rdelim)) + (with-fluids ((%default-port-encoding "UTF-8")) + (with-input-from-file #$e read-string))) + (if (and (null? acc) (eq? grammar 'infix)) + acc + (cons delimiter acc)))) + '() ls)) + +(define (list-of pred?) + "Return a procedure that takes a list and check if all the elements of +the list result in @code{#t} when applying PRED? on them." + (lambda (x) + (if (list? x) + (every pred? x) + #f))) + + +(define list-of-strings? + (list-of string?)) + +(define alist? list?) + +(define serialize-file-like empty-serializer) + +(define (text-config? config) + (list-of file-like?)) +(define (serialize-text-config field-name val) + #~(string-append #$@(interpose val "\n" 'suffix))) + +(define ((generic-serialize-alist-entry serialize-field) entry) + "Apply the SERIALIZE-FIELD procedure on the field and value of ENTRY." + (match entry + ((field . val) (serialize-field field val)))) + +(define (generic-serialize-alist combine serialize-field fields) + "Generate a configuration from an association list FIELDS. + +SERIALIZE-FIELD is a procedure that takes two arguments, it will be +applied on the fields and values of FIELDS using the +@code{generic-serialize-alist-entry} procedure. + +COMBINE is a procedure that takes one or more arguments and combines +all the alist entries into one value, @code{string-append} or +@code{append} are usually good candidates for this. + +See the @code{serialize-alist} procedure in `@code{(gnu home-services +version-control}' for an example usage.)}" + (apply combine + (map (generic-serialize-alist-entry serialize-field) fields))) diff --git a/guix/scripts/home/import.scm b/guix/scripts/home/import.scm index c977ec3861..611f580e85 100644 --- a/guix/scripts/home/import.scm +++ b/guix/scripts/home/import.scm @@ -46,17 +46,15 @@ (home-bash-configuration ,@(if (file-exists? rc) `((bashrc - (list (slurp-file-gexp (local-file ,rc))))) + (list (local-file ,rc)))) '()) ,@(if (file-exists? profile) `((bash-profile - (list (slurp-file-gexp - (local-file ,profile))))) + (list (local-file ,profile)))) '()) ,@(if (file-exists? logout) `((bash-logout - (list (slurp-file-gexp - (local-file ,logout))))) + (list (local-file ,logout)))) '())))))) -- 2.33.0 ^ permalink raw reply related [flat|nested] 64+ messages in thread
* [bug#50967] [PATCH 3/3] guix: scripts: Make sure profile directory exists. 2021-10-04 23:13 ` [bug#50967] [PATCH 1/3] gnu: Move (gnu home-services) to (gnu home services) Oleg Pykhalov 2021-10-04 23:13 ` [bug#50967] [PATCH 2/3] home: services: configuration: Support file-like objects Oleg Pykhalov @ 2021-10-04 23:13 ` Oleg Pykhalov 2021-10-05 10:20 ` Oleg Pykhalov 2021-10-06 22:05 ` [bug#50967] [PATCH 3/3] guix: scripts: Make sure profile directory exists Oleg Pykhalov 2021-10-08 12:44 ` [bug#50967] " Oleg Pykhalov 2021-10-08 22:49 ` Ludovic Courtès 3 siblings, 2 replies; 64+ messages in thread From: Oleg Pykhalov @ 2021-10-04 23:13 UTC (permalink / raw) To: 50967; +Cc: Oleg Pykhalov, Ludovic Courtès, Xinglu Chen, Andrew Tropin * guix/scripts/home.scm (process-action): Make sure profile directory exists. * tests/guix-home.sh: New file. * Makefile.am (SH_TESTS): Add this. --- Makefile.am | 1 + guix/scripts/home.scm | 2 ++ tests/guix-home.sh | 73 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 76 insertions(+) create mode 100644 tests/guix-home.sh diff --git a/Makefile.am b/Makefile.am index b66789fa0b..5bf2567dc8 100644 --- a/Makefile.am +++ b/Makefile.am @@ -546,6 +546,7 @@ SH_TESTS = \ tests/guix-package-aliases.sh \ tests/guix-package-net.sh \ tests/guix-system.sh \ + tests/guix-home.sh \ tests/guix-archive.sh \ tests/guix-authenticate.sh \ tests/guix-environment.sh \ diff --git a/guix/scripts/home.scm b/guix/scripts/home.scm index 75df6d707d..115dfadb57 100644 --- a/guix/scripts/home.scm +++ b/guix/scripts/home.scm @@ -1,6 +1,7 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2021 Andrew Tropin <andrew@trop.in> ;;; Copyright © 2021 Xinglu Chen <public@yoctocell.xyz> +;;; Copyright © 2021 Oleg Pykhalov <go.wigust@gmail.com> ;;; ;;; This file is part of GNU Guix. ;;; @@ -179,6 +180,7 @@ ACTION must be one of the sub-commands that takes a home environment declaration as an argument (a file name.) OPTS is the raw alist of options resulting from command-line parsing." (define (ensure-home-environment file-or-exp obj) + (ensure-profile-directory) (unless (home-environment? obj) (leave (G_ "'~a' does not return a home environment ~%") file-or-exp)) diff --git a/tests/guix-home.sh b/tests/guix-home.sh new file mode 100644 index 0000000000..e79982b7f7 --- /dev/null +++ b/tests/guix-home.sh @@ -0,0 +1,73 @@ +#!/bin/sh + +# GNU Guix --- Functional package management for GNU +# Copyright © 2021 Oleg Pykhalov <go.wigust@gmail.com> +# +# 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/>. + +# +# Test the 'guix home' using the external store, if any. +# + +guix home --version + +NIX_STORE_DIR="$(guile -c '(use-modules (guix config))(display %storedir)')" +localstatedir="$(guile -c '(use-modules (guix config))(display %localstatedir)')" +GUIX_DAEMON_SOCKET="$localstatedir/guix/daemon-socket/socket" +export NIX_STORE_DIR GUIX_DAEMON_SOCKET + +# Run tests only when a "real" daemon is available. +if ! guile -c '(use-modules (guix)) (exit (false-if-exception (open-connection)))' +then + exit 77 +fi + +STORE_PARENT="$(dirname "$NIX_STORE_DIR")" +export STORE_PARENT +if test "$STORE_PARENT" = "/"; then exit 77; fi + +test_directory="$(mktemp -d)" +export test_directory +trap 'chmod -Rf +w "$test_directory"; rm -rf "$test_directory"' EXIT + +( + cd "$test_directory" || exit 77 + + cat > "dot-bashrc" <<'EOF' +# dot-bashrc test file for guix home +EOF + + cat > "home.scm" <<'EOF' +(use-modules (gnu home) + (gnu home-services) + (gnu home services shells) + (gnu services) + (guix gexp)) + +(home-environment + (services + (list + (service home-bash-service-type + (home-bash-configuration + (guix-defaults? #t) + (bashrc + (list + (local-file (string-append (dirname (current-filename)) + "/dot-bashrc"))))))))) +EOF +) + +guix home reconfigure "${test_directory}/home.scm" -- 2.33.0 ^ permalink raw reply related [flat|nested] 64+ messages in thread
* [bug#50967] [PATCH 3/3] guix: scripts: Make sure profile directory exists. 2021-10-04 23:13 ` [bug#50967] [PATCH 3/3] guix: scripts: Make sure profile directory exists Oleg Pykhalov @ 2021-10-05 10:20 ` Oleg Pykhalov 2021-10-06 21:22 ` [bug#50967] [PATCH 00/12] Move (gnu home-services XYZ) to (gnu services XYZ) Ludovic Courtès 2021-10-06 22:05 ` [bug#50967] [PATCH 3/3] guix: scripts: Make sure profile directory exists Oleg Pykhalov 1 sibling, 1 reply; 64+ messages in thread From: Oleg Pykhalov @ 2021-10-05 10:20 UTC (permalink / raw) To: 50967; +Cc: Ludovic Courtès, Xinglu Chen, Andrew Tropin [-- Attachment #1: Type: text/plain, Size: 2180 bytes --] Oleg Pykhalov <go.wigust@gmail.com> writes: > * guix/scripts/home.scm (process-action): Make sure profile directory exists. > * tests/guix-home.sh: New file. > * Makefile.am (SH_TESTS): Add this. > --- > Makefile.am | 1 + > guix/scripts/home.scm | 2 ++ > tests/guix-home.sh | 73 +++++++++++++++++++++++++++++++++++++++++++ > 3 files changed, 76 insertions(+) > create mode 100644 tests/guix-home.sh > > diff --git a/Makefile.am b/Makefile.am > index b66789fa0b..5bf2567dc8 100644 > --- a/Makefile.am > +++ b/Makefile.am > @@ -546,6 +546,7 @@ SH_TESTS = \ > tests/guix-package-aliases.sh \ > tests/guix-package-net.sh \ > tests/guix-system.sh \ > + tests/guix-home.sh \ > tests/guix-archive.sh \ > tests/guix-authenticate.sh \ > tests/guix-environment.sh \ > diff --git a/guix/scripts/home.scm b/guix/scripts/home.scm > index 75df6d707d..115dfadb57 100644 > --- a/guix/scripts/home.scm > +++ b/guix/scripts/home.scm > @@ -1,6 +1,7 @@ > ;;; GNU Guix --- Functional package management for GNU > ;;; Copyright © 2021 Andrew Tropin <andrew@trop.in> > ;;; Copyright © 2021 Xinglu Chen <public@yoctocell.xyz> > +;;; Copyright © 2021 Oleg Pykhalov <go.wigust@gmail.com> > ;;; > ;;; This file is part of GNU Guix. > ;;; > @@ -179,6 +180,7 @@ ACTION must be one of the sub-commands that takes a home environment > declaration as an argument (a file name.) OPTS is the raw alist of options > resulting from command-line parsing." > (define (ensure-home-environment file-or-exp obj) > + (ensure-profile-directory) > (unless (home-environment? obj) > (leave (G_ "'~a' does not return a home environment ~%") > file-or-exp)) > diff --git a/tests/guix-home.sh b/tests/guix-home.sh > new file mode 100644 > index 0000000000..e79982b7f7 > --- /dev/null > +++ b/tests/guix-home.sh > @@ -0,0 +1,73 @@ > +#!/bin/sh > + > +# GNU Guix --- Functional package management for GNU > +# Copyright © 2021 Oleg Pykhalov <go.wigust@gmail.com> > +# […] Well, guix home reconfigure will break your ~/.bashrc. Sorry. Don't use this "test". [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 861 bytes --] ^ permalink raw reply [flat|nested] 64+ messages in thread
* [bug#50967] [PATCH 00/12] Move (gnu home-services XYZ) to (gnu services XYZ) 2021-10-05 10:20 ` Oleg Pykhalov @ 2021-10-06 21:22 ` Ludovic Courtès 0 siblings, 0 replies; 64+ messages in thread From: Ludovic Courtès @ 2021-10-06 21:22 UTC (permalink / raw) To: Oleg Pykhalov; +Cc: Xinglu Chen, 50967, Andrew Tropin Hi, Oleg Pykhalov <go.wigust@gmail.com> skribis: > Well, guix home reconfigure will break your ~/.bashrc. Sorry. Ah, thanks for letting us know. :-) Perhaps you need to set HOME before, or is there another way you could achieve that? Thanks, Ludo’. ^ permalink raw reply [flat|nested] 64+ messages in thread
* [bug#50967] [PATCH 3/3] guix: scripts: Make sure profile directory exists. 2021-10-04 23:13 ` [bug#50967] [PATCH 3/3] guix: scripts: Make sure profile directory exists Oleg Pykhalov 2021-10-05 10:20 ` Oleg Pykhalov @ 2021-10-06 22:05 ` Oleg Pykhalov 2021-10-06 22:15 ` [bug#50967] [PATCH 00/12] Move (gnu home-services XYZ) to (gnu services XYZ) Oleg Pykhalov 2021-10-08 22:57 ` Ludovic Courtès 1 sibling, 2 replies; 64+ messages in thread From: Oleg Pykhalov @ 2021-10-06 22:05 UTC (permalink / raw) To: 50967; +Cc: Ludovic Courtès, zimoun, Xinglu Chen, Andrew Tropin [-- Attachment #1.1: Type: text/plain, Size: 108 bytes --] This patch fixes user's files corruption. Also, I applied suggestions about commit message, thanks zimoun! [-- Attachment #1.2: Make sure profile directory exists with fix to not corrupt user's home files --] [-- Type: text/x-patch, Size: 4875 bytes --] From eec2ab5f514ec6e156244898f8a635baf323ab70 Mon Sep 17 00:00:00 2001 From: Oleg Pykhalov <go.wigust@gmail.com> Date: Tue, 5 Oct 2021 02:10:25 +0300 Subject: [PATCH] scripts: home: Make sure profile directory exists. * guix/scripts/home.scm (process-action): Make sure profile directory exists. * tests/guix-home.sh: New file. * Makefile.am (SH_TESTS): Add this. --- Makefile.am | 1 + guix/scripts/home.scm | 2 + tests/guix-home.sh | 86 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 89 insertions(+) create mode 100644 tests/guix-home.sh diff --git a/Makefile.am b/Makefile.am index b66789fa0b..5bf2567dc8 100644 --- a/Makefile.am +++ b/Makefile.am @@ -546,6 +546,7 @@ SH_TESTS = \ tests/guix-package-aliases.sh \ tests/guix-package-net.sh \ tests/guix-system.sh \ + tests/guix-home.sh \ tests/guix-archive.sh \ tests/guix-authenticate.sh \ tests/guix-environment.sh \ diff --git a/guix/scripts/home.scm b/guix/scripts/home.scm index 75df6d707d..115dfadb57 100644 --- a/guix/scripts/home.scm +++ b/guix/scripts/home.scm @@ -1,6 +1,7 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2021 Andrew Tropin <andrew@trop.in> ;;; Copyright © 2021 Xinglu Chen <public@yoctocell.xyz> +;;; Copyright © 2021 Oleg Pykhalov <go.wigust@gmail.com> ;;; ;;; This file is part of GNU Guix. ;;; @@ -179,6 +180,7 @@ ACTION must be one of the sub-commands that takes a home environment declaration as an argument (a file name.) OPTS is the raw alist of options resulting from command-line parsing." (define (ensure-home-environment file-or-exp obj) + (ensure-profile-directory) (unless (home-environment? obj) (leave (G_ "'~a' does not return a home environment ~%") file-or-exp)) diff --git a/tests/guix-home.sh b/tests/guix-home.sh new file mode 100644 index 0000000000..96cbd12857 --- /dev/null +++ b/tests/guix-home.sh @@ -0,0 +1,86 @@ +#!/usr/bin/env bash + +# GNU Guix --- Functional package management for GNU +# Copyright © 2021 Oleg Pykhalov <go.wigust@gmail.com> +# +# 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/>. + +# +# Test the 'guix home' using the external store, if any. +# + +guix home --version + +NIX_STORE_DIR="$(guile -c '(use-modules (guix config))(display %storedir)')" +localstatedir="$(guile -c '(use-modules (guix config))(display %localstatedir)')" +GUIX_DAEMON_SOCKET="$localstatedir/guix/daemon-socket/socket" +export NIX_STORE_DIR GUIX_DAEMON_SOCKET + +# Run tests only when a "real" daemon is available. +if ! guile -c '(use-modules (guix)) (exit (false-if-exception (open-connection)))' +then + exit 77 +fi + +STORE_PARENT="$(dirname "$NIX_STORE_DIR")" +export STORE_PARENT +if test "$STORE_PARENT" = "/"; then exit 77; fi + +run_guix_home_without_home() +{ + ( + # Save current directory (Guix source directory) for later mount + test_directory="$(mktemp -d)" + trap 'umount $test_directory; rmdir $test_directory' EXIT + mount --bind "$PWD" "$test_directory" + + # Make $HOME directory empty to preserve user's files + mount --types tmpfs none "$HOME" + + # Mount Guix source directory in a clean environment + mkdir -p "$PWD" + mount --bind "$test_directory" "$PWD" + cd "$PWD" || exit 77 + + cat > "dot-bashrc" <<'EOF' +# dot-bashrc test file for guix home +EOF + + cat > "home.scm" <<'EOF' +(use-modules (gnu home) + (gnu home-services) + (gnu home services shells) + (gnu services) + (guix gexp)) + +(home-environment + (services + (list + (service home-bash-service-type + (home-bash-configuration + (guix-defaults? #t) + (bashrc + (list + (local-file (string-append (dirname (current-filename)) + "/dot-bashrc"))))))))) +EOF + + guix home reconfigure "${test_directory}/home.scm" + ) +} +export -f run_guix_home_without_home + +unshare -mrf bash -c "run_guix_home_without_home" -- 2.33.0 [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 861 bytes --] ^ permalink raw reply related [flat|nested] 64+ messages in thread
* [bug#50967] [PATCH 00/12] Move (gnu home-services XYZ) to (gnu services XYZ) 2021-10-06 22:05 ` [bug#50967] [PATCH 3/3] guix: scripts: Make sure profile directory exists Oleg Pykhalov @ 2021-10-06 22:15 ` Oleg Pykhalov 2021-10-07 6:37 ` Maxime Devos 2021-10-08 22:57 ` Ludovic Courtès 1 sibling, 1 reply; 64+ messages in thread From: Oleg Pykhalov @ 2021-10-06 22:15 UTC (permalink / raw) To: 50967; +Cc: Ludovic Courtès, Andrew Tropin, Xinglu Chen, zimoun [-- Attachment #1.1: Type: text/plain, Size: 442 bytes --] Oleg Pykhalov <go.wigust@gmail.com> writes: > This patch fixes user's files corruption. Also, I applied suggestions > about commit message, thanks zimoun! Also, in addion I forget to: Replace '#!/usr/bin/env bash' with '#!/bin/bash' Maybe a /bin/sh would be more Guix friendly, but shellcheck warns about export -f does not exist in posix shell. Thoughts are welcome ;-) Remove a unnecessary subshell in run_guix_home_without_home. [-- Attachment #1.2: minor fixes for guix-test.sh --] [-- Type: text/x-patch, Size: 4824 bytes --] From 6351e3f099d3c09143c5f0289216d52ee45664d9 Mon Sep 17 00:00:00 2001 From: Oleg Pykhalov <go.wigust@gmail.com> Date: Tue, 5 Oct 2021 02:10:25 +0300 Subject: [PATCH] scripts: home: Make sure profile directory exists. * guix/scripts/home.scm (process-action): Make sure profile directory exists. * tests/guix-home.sh: New file. * Makefile.am (SH_TESTS): Add this. --- Makefile.am | 1 + guix/scripts/home.scm | 2 ++ tests/guix-home.sh | 84 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 87 insertions(+) create mode 100644 tests/guix-home.sh diff --git a/Makefile.am b/Makefile.am index b66789fa0b..5bf2567dc8 100644 --- a/Makefile.am +++ b/Makefile.am @@ -546,6 +546,7 @@ SH_TESTS = \ tests/guix-package-aliases.sh \ tests/guix-package-net.sh \ tests/guix-system.sh \ + tests/guix-home.sh \ tests/guix-archive.sh \ tests/guix-authenticate.sh \ tests/guix-environment.sh \ diff --git a/guix/scripts/home.scm b/guix/scripts/home.scm index 75df6d707d..115dfadb57 100644 --- a/guix/scripts/home.scm +++ b/guix/scripts/home.scm @@ -1,6 +1,7 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2021 Andrew Tropin <andrew@trop.in> ;;; Copyright © 2021 Xinglu Chen <public@yoctocell.xyz> +;;; Copyright © 2021 Oleg Pykhalov <go.wigust@gmail.com> ;;; ;;; This file is part of GNU Guix. ;;; @@ -179,6 +180,7 @@ ACTION must be one of the sub-commands that takes a home environment declaration as an argument (a file name.) OPTS is the raw alist of options resulting from command-line parsing." (define (ensure-home-environment file-or-exp obj) + (ensure-profile-directory) (unless (home-environment? obj) (leave (G_ "'~a' does not return a home environment ~%") file-or-exp)) diff --git a/tests/guix-home.sh b/tests/guix-home.sh new file mode 100644 index 0000000000..b0b85737b0 --- /dev/null +++ b/tests/guix-home.sh @@ -0,0 +1,84 @@ +#!/bin/bash + +# GNU Guix --- Functional package management for GNU +# Copyright © 2021 Oleg Pykhalov <go.wigust@gmail.com> +# +# 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/>. + +# +# Test the 'guix home' using the external store, if any. +# + +guix home --version + +NIX_STORE_DIR="$(guile -c '(use-modules (guix config))(display %storedir)')" +localstatedir="$(guile -c '(use-modules (guix config))(display %localstatedir)')" +GUIX_DAEMON_SOCKET="$localstatedir/guix/daemon-socket/socket" +export NIX_STORE_DIR GUIX_DAEMON_SOCKET + +# Run tests only when a "real" daemon is available. +if ! guile -c '(use-modules (guix)) (exit (false-if-exception (open-connection)))' +then + exit 77 +fi + +STORE_PARENT="$(dirname "$NIX_STORE_DIR")" +export STORE_PARENT +if test "$STORE_PARENT" = "/"; then exit 77; fi + +run_guix_home_without_home() +{ + # Save current directory (Guix source directory) for later mount + test_directory="$(mktemp -d)" + trap 'umount $test_directory; rmdir $test_directory' EXIT + mount --bind "$PWD" "$test_directory" + + # Make $HOME directory empty to preserve user's files + mount --types tmpfs none "$HOME" + + # Mount Guix source directory in a clean environment + mkdir -p "$PWD" + mount --bind "$test_directory" "$PWD" + cd "$PWD" || exit 77 + + cat > "dot-bashrc" <<'EOF' +# dot-bashrc test file for guix home +EOF + + cat > "home.scm" <<'EOF' +(use-modules (gnu home) + (gnu home-services) + (gnu home services shells) + (gnu services) + (guix gexp)) + +(home-environment + (services + (list + (service home-bash-service-type + (home-bash-configuration + (guix-defaults? #t) + (bashrc + (list + (local-file (string-append (dirname (current-filename)) + "/dot-bashrc"))))))))) +EOF + + guix home reconfigure "${test_directory}/home.scm" +} +export -f run_guix_home_without_home + +unshare --mount --map-root-user --fork sh -c "run_guix_home_without_home" -- 2.33.0 [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 861 bytes --] ^ permalink raw reply related [flat|nested] 64+ messages in thread
* [bug#50967] [PATCH 00/12] Move (gnu home-services XYZ) to (gnu services XYZ) 2021-10-06 22:15 ` [bug#50967] [PATCH 00/12] Move (gnu home-services XYZ) to (gnu services XYZ) Oleg Pykhalov @ 2021-10-07 6:37 ` Maxime Devos 2021-10-07 9:56 ` Oleg Pykhalov 2021-10-08 22:44 ` Ludovic Courtès 0 siblings, 2 replies; 64+ messages in thread From: Maxime Devos @ 2021-10-07 6:37 UTC (permalink / raw) To: Oleg Pykhalov, 50967 Cc: Ludovic Courtès, zimoun, Xinglu Chen, Andrew Tropin [-- Attachment #1: Type: text/plain, Size: 695 bytes --] Oleg Pykhalov schreef op do 07-10-2021 om 01:15 [+0300]: > Oleg Pykhalov <go.wigust@gmail.com> writes: > > > This patch fixes user's files corruption. Also, I applied suggestions > > about commit message, thanks zimoun! > > Also, in addion I forget to: > > Replace '#!/usr/bin/env bash' with '#!/bin/bash' > > Maybe a /bin/sh would be more Guix friendly, but shellcheck warns about > export -f does not exist in posix shell. Thoughts are welcome ;-) /bin/bash doesn't exist on Guix System, so it seems a bit weird to me to use that in Guix. Anyway, I think shellcheck should classify '#!/usr/bin/env bash' as a bash shell instead of a posix shell? Greetings, Maxime. [-- Attachment #2: This is a digitally signed message part --] [-- Type: application/pgp-signature, Size: 260 bytes --] ^ permalink raw reply [flat|nested] 64+ messages in thread
* [bug#50967] [PATCH 00/12] Move (gnu home-services XYZ) to (gnu services XYZ) 2021-10-07 6:37 ` Maxime Devos @ 2021-10-07 9:56 ` Oleg Pykhalov 2021-10-07 16:43 ` Maxime Devos 2021-10-08 22:44 ` Ludovic Courtès 1 sibling, 1 reply; 64+ messages in thread From: Oleg Pykhalov @ 2021-10-07 9:56 UTC (permalink / raw) To: Maxime Devos; +Cc: 50967 [-- Attachment #1: Type: text/plain, Size: 771 bytes --] Maxime Devos <maximedevos@telenet.be> writes: […] >> Replace '#!/usr/bin/env bash' with '#!/bin/bash' >> >> Maybe a /bin/sh would be more Guix friendly, but shellcheck warns about >> export -f does not exist in posix shell. Thoughts are welcome ;-) > > /bin/bash doesn't exist on Guix System, so it seems a bit weird to me > to use that in Guix. Anyway, I think shellcheck should classify > '#!/usr/bin/env bash' as a bash shell instead of a posix shell? Yes, also /usr/bin/env does not exist on Guix as well. So in that sense both /bin/bash and /usr/bin/env bash are equal. I see special-files-service-type has an example about creating /usr/bin/env, so probable should use /usr/bin/env bash in test's shebang line to make shellcheck happy. [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 861 bytes --] ^ permalink raw reply [flat|nested] 64+ messages in thread
* [bug#50967] [PATCH 00/12] Move (gnu home-services XYZ) to (gnu services XYZ) 2021-10-07 9:56 ` Oleg Pykhalov @ 2021-10-07 16:43 ` Maxime Devos 0 siblings, 0 replies; 64+ messages in thread From: Maxime Devos @ 2021-10-07 16:43 UTC (permalink / raw) To: Oleg Pykhalov; +Cc: 50967 [-- Attachment #1: Type: text/plain, Size: 938 bytes --] Oleg Pykhalov schreef op do 07-10-2021 om 12:56 [+0300]: > Maxime Devos <maximedevos@telenet.be> writes: > > […] > > > > Replace '#!/usr/bin/env bash' with '#!/bin/bash' > > > > > > Maybe a /bin/sh would be more Guix friendly, but shellcheck warns about > > > export -f does not exist in posix shell. Thoughts are welcome ;-) > > > > /bin/bash doesn't exist on Guix System, so it seems a bit weird to me > > to use that in Guix. Anyway, I think shellcheck should classify > > '#!/usr/bin/env bash' as a bash shell instead of a posix shell? > > Yes, also /usr/bin/env does not exist on Guix as well. So in that sense > both /bin/bash and /usr/bin/env bash are equal. It does exist: $ ls /usr/bin/env /usr/bin/env It's supposed to be possible to do without on Guix System though, by removing it from %base-services. FWIW, the shell scripts in tests/*.sh do not have a shebang. Greetings, Maxime. [-- Attachment #2: This is a digitally signed message part --] [-- Type: application/pgp-signature, Size: 260 bytes --] ^ permalink raw reply [flat|nested] 64+ messages in thread
* [bug#50967] [PATCH 00/12] Move (gnu home-services XYZ) to (gnu services XYZ) 2021-10-07 6:37 ` Maxime Devos 2021-10-07 9:56 ` Oleg Pykhalov @ 2021-10-08 22:44 ` Ludovic Courtès 1 sibling, 0 replies; 64+ messages in thread From: Ludovic Courtès @ 2021-10-08 22:44 UTC (permalink / raw) To: Maxime Devos; +Cc: Oleg Pykhalov, Andrew Tropin, Xinglu Chen, 50967, zimoun Maxime Devos <maximedevos@telenet.be> skribis: > Oleg Pykhalov schreef op do 07-10-2021 om 01:15 [+0300]: >> Oleg Pykhalov <go.wigust@gmail.com> writes: >> >> > This patch fixes user's files corruption. Also, I applied suggestions >> > about commit message, thanks zimoun! >> >> Also, in addion I forget to: >> >> Replace '#!/usr/bin/env bash' with '#!/bin/bash' >> >> Maybe a /bin/sh would be more Guix friendly, but shellcheck warns about >> export -f does not exist in posix shell. Thoughts are welcome ;-) > > /bin/bash doesn't exist on Guix System, Also, tests/*.sh are not executable and thus have no shebang; you can do the same here. Ludo’. ^ permalink raw reply [flat|nested] 64+ messages in thread
* [bug#50967] [PATCH 00/12] Move (gnu home-services XYZ) to (gnu services XYZ) 2021-10-06 22:05 ` [bug#50967] [PATCH 3/3] guix: scripts: Make sure profile directory exists Oleg Pykhalov 2021-10-06 22:15 ` [bug#50967] [PATCH 00/12] Move (gnu home-services XYZ) to (gnu services XYZ) Oleg Pykhalov @ 2021-10-08 22:57 ` Ludovic Courtès 2021-10-09 12:34 ` Oleg Pykhalov 1 sibling, 1 reply; 64+ messages in thread From: Ludovic Courtès @ 2021-10-08 22:57 UTC (permalink / raw) To: Oleg Pykhalov; +Cc: Andrew Tropin, Xinglu Chen, 50967, zimoun Oleg Pykhalov <go.wigust@gmail.com> skribis: > From eec2ab5f514ec6e156244898f8a635baf323ab70 Mon Sep 17 00:00:00 2001 > From: Oleg Pykhalov <go.wigust@gmail.com> > Date: Tue, 5 Oct 2021 02:10:25 +0300 > Subject: [PATCH] scripts: home: Make sure profile directory exists. > > * guix/scripts/home.scm (process-action): Make sure profile directory exists. > * tests/guix-home.sh: New file. > * Makefile.am (SH_TESTS): Add this. IMO the home.scm change should perhaps be a separate commit because it’s not strictly what the test exercises. > +++ b/tests/guix-home.sh > @@ -0,0 +1,86 @@ > +#!/usr/bin/env bash > + You can remove these two lines. > +run_guix_home_without_home() > +{ > + ( > + # Save current directory (Guix source directory) for later mount > + test_directory="$(mktemp -d)" > + trap 'umount $test_directory; rmdir $test_directory' EXIT > + mount --bind "$PWD" "$test_directory" > + > + # Make $HOME directory empty to preserve user's files > + mount --types tmpfs none "$HOME" > + > + # Mount Guix source directory in a clean environment > + mkdir -p "$PWD" > + mount --bind "$test_directory" "$PWD" > + cd "$PWD" || exit 77 How about ‘set -e’ to make sure we abort as soon as things go wrong? Also, wouldn’t it be easier to set HOME to a new directory? > + guix home reconfigure "${test_directory}/home.scm" Looks like the test is not checking anything after ‘reconfigure’ has completed. Should it check for the presence of certain things in ~/.bashrc, for the presence of ~/.guix-home, the output of ‘guix home describe’ maybe? > +unshare -mrf bash -c "run_guix_home_without_home" If we keep this strategy (rather than setting HOME), we need a check for unprivileged user namespace support. In ‘tests/guix-pack-relocatable.sh’, this is done by invoking “unshare -r true” and checking the return value. Could you send an updated patch? Thanks, Ludo’. ^ permalink raw reply [flat|nested] 64+ messages in thread
* [bug#50967] [PATCH 00/12] Move (gnu home-services XYZ) to (gnu services XYZ) 2021-10-08 22:57 ` Ludovic Courtès @ 2021-10-09 12:34 ` Oleg Pykhalov 2021-10-09 12:45 ` Oleg Pykhalov 2021-10-09 14:34 ` Ludovic Courtès 0 siblings, 2 replies; 64+ messages in thread From: Oleg Pykhalov @ 2021-10-09 12:34 UTC (permalink / raw) To: Ludovic Courtès; +Cc: Andrew Tropin, Xinglu Chen, 50967, zimoun [-- Attachment #1.1: Type: text/plain, Size: 1108 bytes --] Ludovic Courtès <ludo@gnu.org> writes: >> From eec2ab5f514ec6e156244898f8a635baf323ab70 Mon Sep 17 00:00:00 2001 >> From: Oleg Pykhalov <go.wigust@gmail.com> >> Date: Tue, 5 Oct 2021 02:10:25 +0300 >> Subject: [PATCH] scripts: home: Make sure profile directory exists. […] > Also, wouldn’t it be easier to set HOME to a new directory? > >> + guix home reconfigure "${test_directory}/home.scm" We probably should clean temporary $HOME directory with 'rm -rf' or delete each file with 'rm' and then invoke 'rmdir' inside a Bash's 'trap'. I fill worry about removing operations on $HOME directories. Alternative is not to remove $HOME by calling some command and just exit from a namespace, which will remove $HOME mounted as tmpfs after exiting a process running the guix-home.sh test. […] > Could you send an updated patch? Also returned Andrew's 'guix home search' tests. And 'home-bash-service-type' is replaced with 'simple-service' to not to block the guix-home.sh test from merging in master until completion of discussion about file-like objects. [-- Attachment #1.2: scripts: home: Make sure profile directory exists. --] [-- Type: text/x-patch, Size: 1282 bytes --] From 4b29f7f1592f4256c7cd628624d2225e2d427a9d Mon Sep 17 00:00:00 2001 From: Oleg Pykhalov <go.wigust@gmail.com> Date: Sat, 9 Oct 2021 14:52:10 +0300 Subject: [PATCH 1/2] scripts: home: Make sure profile directory exists. * guix/scripts/home.scm (process-action): Make sure profile directory exists. --- guix/scripts/home.scm | 2 ++ 1 file changed, 2 insertions(+) diff --git a/guix/scripts/home.scm b/guix/scripts/home.scm index a4d4aaa562..e6e35513fd 100644 --- a/guix/scripts/home.scm +++ b/guix/scripts/home.scm @@ -2,6 +2,7 @@ ;;; Copyright © 2021 Andrew Tropin <andrew@trop.in> ;;; Copyright © 2021 Xinglu Chen <public@yoctocell.xyz> ;;; Copyright © 2021 Pierre Langlois <pierre.langlois@gmx.com> +;;; Copyright © 2021 Oleg Pykhalov <go.wigust@gmail.com> ;;; ;;; This file is part of GNU Guix. ;;; @@ -189,6 +190,7 @@ ACTION must be one of the sub-commands that takes a home environment declaration as an argument (a file name.) OPTS is the raw alist of options resulting from command-line parsing." (define (ensure-home-environment file-or-exp obj) + (ensure-profile-directory) (unless (home-environment? obj) (leave (G_ "'~a' does not return a home environment ~%") file-or-exp)) -- 2.33.0 [-- Attachment #1.3: tests: Add guix-home.sh. --] [-- Type: text/x-patch, Size: 4837 bytes --] From 5cc0b064af3f4a6238722fbb451a98b499c8d6d2 Mon Sep 17 00:00:00 2001 From: Oleg Pykhalov <go.wigust@gmail.com> Date: Sat, 9 Oct 2021 14:52:13 +0300 Subject: [PATCH 2/2] tests: Add guix-home.sh. * tests/guix-home.sh: New file. * Makefile.am (SH_TESTS): Add this. --- Makefile.am | 1 + tests/guix-home.sh | 122 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 123 insertions(+) create mode 100644 tests/guix-home.sh diff --git a/Makefile.am b/Makefile.am index bb0b5989d2..b341031ec9 100644 --- a/Makefile.am +++ b/Makefile.am @@ -552,6 +552,7 @@ SH_TESTS = \ tests/guix-package-aliases.sh \ tests/guix-package-net.sh \ tests/guix-system.sh \ + tests/guix-home.sh \ tests/guix-archive.sh \ tests/guix-authenticate.sh \ tests/guix-environment.sh \ diff --git a/tests/guix-home.sh b/tests/guix-home.sh new file mode 100644 index 0000000000..f251304083 --- /dev/null +++ b/tests/guix-home.sh @@ -0,0 +1,122 @@ + +# GNU Guix --- Functional package management for GNU +# Copyright © 2021 Andrew Tropin <andrew@trop.in> +# Copyright © 2021 Oleg Pykhalov <go.wigust@gmail.com> +# +# 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/>. + +# +# Test the 'guix home' using the external store, if any. +# + +set -e + +guix home --version + +NIX_STORE_DIR="$(guile -c '(use-modules (guix config))(display %storedir)')" +localstatedir="$(guile -c '(use-modules (guix config))(display %localstatedir)')" +GUIX_DAEMON_SOCKET="$localstatedir/guix/daemon-socket/socket" +export NIX_STORE_DIR GUIX_DAEMON_SOCKET + +# Run tests only when a "real" daemon is available. +if ! guile -c '(use-modules (guix)) (exit (false-if-exception (open-connection)))' +then + exit 77 +fi + +STORE_PARENT="$(dirname "$NIX_STORE_DIR")" +export STORE_PARENT +if test "$STORE_PARENT" = "/"; then exit 77; fi + +run_guix_home_without_home() +{ + set -e + + # Save current directory (Guix source directory) for later mount + test_directory="$(mktemp -d)" + trap 'umount $test_directory; rmdir $test_directory' EXIT + mount --bind "$PWD" "$test_directory" + + # Make $HOME directory empty to preserve user's files + mount --types tmpfs none "$HOME" + + # Mount Guix source directory in a clean environment + mkdir -p "$PWD" + mount --bind "$test_directory" "$PWD" + cd "$PWD" || exit 77 + + # + # Test 'guix home reconfigure'. + # + + cat > "home.scm" <<'EOF' +(use-modules (guix gexp) + (gnu home) + (gnu home-services) + (gnu services)) + +(home-environment + (services + (list + (simple-service 'test-config + home-files-service-type + (list `("config/test.conf" + ,(plain-file + "tmp-file.txt" + "the content of ~/.config/test.conf"))))))) +EOF + + guix home reconfigure "${test_directory}/home.scm" + test -d "${HOME}/.guix-home" + grep -q "the content of ~/.config/test.conf" "${HOME}/.config/test.conf" + + # + # Test 'guix home describe'. + # + + configuration_file() + { + guix home describe \ + | grep 'configuration file:' \ + | cut -d : -f 2 \ + | xargs echo + } + test "$(cat "$(configuration_file)")" == "$(cat home.scm)" + + canonical_file_name() + { + guix home describe \ + | grep 'canonical file name:' \ + | cut -d : -f 2 \ + | xargs echo + } + test "$(canonical_file_name)" == "$(readlink "${HOME}/.guix-home")" + + # + # Test 'guix home search'. + # + + guix home search mcron | grep "^name: home-mcron" + guix home search job manager | grep "^name: home-mcron" +} +export -f run_guix_home_without_home + +if unshare -r true # Are user namespaces supported? +then + unshare --mount --map-root-user --fork sh -c "run_guix_home_without_home" +else + exit 77 +fi -- 2.33.0 [-- Attachment #1.4: Type: text/plain, Size: 7 bytes --] Oleg. [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 861 bytes --] ^ permalink raw reply related [flat|nested] 64+ messages in thread
* [bug#50967] [PATCH 00/12] Move (gnu home-services XYZ) to (gnu services XYZ) 2021-10-09 12:34 ` Oleg Pykhalov @ 2021-10-09 12:45 ` Oleg Pykhalov 2021-10-09 14:34 ` Ludovic Courtès 1 sibling, 0 replies; 64+ messages in thread From: Oleg Pykhalov @ 2021-10-09 12:45 UTC (permalink / raw) To: Ludovic Courtès; +Cc: zimoun, Xinglu Chen, 50967, Andrew Tropin [-- Attachment #1.1: Type: text/plain, Size: 540 bytes --] Oleg Pykhalov <go.wigust@gmail.com> writes: […] > We probably should clean temporary $HOME directory with 'rm -rf' or > delete each file with 'rm' and then invoke 'rmdir' inside a Bash's > 'trap'. I fill worry about removing operations on $HOME directories. > > Alternative is not to remove $HOME by calling some command and just exit > from a namespace, which will remove $HOME mounted as tmpfs after exiting > a process running the guix-home.sh test. Actually, we could just point 'rm -rf' on '$test_directory'. :-) [-- Attachment #1.2: tests: Add guix-home.sh. --] [-- Type: text/x-patch, Size: 4299 bytes --] From 6b0378643df42a963c74cb2a304a0bd369f041cf Mon Sep 17 00:00:00 2001 From: Oleg Pykhalov <go.wigust@gmail.com> Date: Sat, 9 Oct 2021 14:52:13 +0300 Subject: [PATCH] tests: Add guix-home.sh. * tests/guix-home.sh: New file. * Makefile.am (SH_TESTS): Add this. --- Makefile.am | 1 + tests/guix-home.sh | 106 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 107 insertions(+) create mode 100644 tests/guix-home.sh diff --git a/Makefile.am b/Makefile.am index bb0b5989d2..b341031ec9 100644 --- a/Makefile.am +++ b/Makefile.am @@ -552,6 +552,7 @@ SH_TESTS = \ tests/guix-package-aliases.sh \ tests/guix-package-net.sh \ tests/guix-system.sh \ + tests/guix-home.sh \ tests/guix-archive.sh \ tests/guix-authenticate.sh \ tests/guix-environment.sh \ diff --git a/tests/guix-home.sh b/tests/guix-home.sh new file mode 100644 index 0000000000..2104edb41a --- /dev/null +++ b/tests/guix-home.sh @@ -0,0 +1,106 @@ + +# GNU Guix --- Functional package management for GNU +# Copyright © 2021 Andrew Tropin <andrew@trop.in> +# Copyright © 2021 Oleg Pykhalov <go.wigust@gmail.com> +# +# 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/>. + +# +# Test the 'guix home' using the external store, if any. +# + +set -e + +guix home --version + +NIX_STORE_DIR="$(guile -c '(use-modules (guix config))(display %storedir)')" +localstatedir="$(guile -c '(use-modules (guix config))(display %localstatedir)')" +GUIX_DAEMON_SOCKET="$localstatedir/guix/daemon-socket/socket" +export NIX_STORE_DIR GUIX_DAEMON_SOCKET + +# Run tests only when a "real" daemon is available. +if ! guile -c '(use-modules (guix)) (exit (false-if-exception (open-connection)))' +then + exit 77 +fi + +STORE_PARENT="$(dirname "$NIX_STORE_DIR")" +export STORE_PARENT +if test "$STORE_PARENT" = "/"; then exit 77; fi + +test_directory="$(mktemp -d)" +trap 'chmod -Rf +w "$test_directory"; rm -rf "$test_directory"' EXIT + +( + cd "$test_directory" || exit 77 + + HOME="$test_directory" + export HOME + + # + # Test 'guix home reconfigure'. + # + + cat > "home.scm" <<'EOF' +(use-modules (guix gexp) + (gnu home) + (gnu home-services) + (gnu services)) + +(home-environment + (services + (list + (simple-service 'test-config + home-files-service-type + (list `("config/test.conf" + ,(plain-file + "tmp-file.txt" + "the content of ~/.config/test.conf"))))))) +EOF + + guix home reconfigure "${test_directory}/home.scm" + test -d "${HOME}/.guix-home" + grep -q "the content of ~/.config/test.conf" "${HOME}/.config/test.conf" + + # + # Test 'guix home describe'. + # + + configuration_file() + { + guix home describe \ + | grep 'configuration file:' \ + | cut -d : -f 2 \ + | xargs echo + } + test "$(cat "$(configuration_file)")" == "$(cat home.scm)" + + canonical_file_name() + { + guix home describe \ + | grep 'canonical file name:' \ + | cut -d : -f 2 \ + | xargs echo + } + test "$(canonical_file_name)" == "$(readlink "${HOME}/.guix-home")" + + # + # Test 'guix home search'. + # + + guix home search mcron | grep "^name: home-mcron" + guix home search job manager | grep "^name: home-mcron" +) -- 2.33.0 [-- Attachment #1.3: Type: text/plain, Size: 9 bytes --] Oleg. [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 861 bytes --] ^ permalink raw reply related [flat|nested] 64+ messages in thread
* [bug#50967] [PATCH 00/12] Move (gnu home-services XYZ) to (gnu services XYZ) 2021-10-09 12:34 ` Oleg Pykhalov 2021-10-09 12:45 ` Oleg Pykhalov @ 2021-10-09 14:34 ` Ludovic Courtès 2021-10-09 19:39 ` bug#50967: " Oleg Pykhalov 1 sibling, 1 reply; 64+ messages in thread From: Ludovic Courtès @ 2021-10-09 14:34 UTC (permalink / raw) To: Oleg Pykhalov; +Cc: zimoun, Xinglu Chen, 50967, Andrew Tropin Oleg Pykhalov <go.wigust@gmail.com> skribis: > Ludovic Courtès <ludo@gnu.org> writes: > >>> From eec2ab5f514ec6e156244898f8a635baf323ab70 Mon Sep 17 00:00:00 2001 >>> From: Oleg Pykhalov <go.wigust@gmail.com> >>> Date: Tue, 5 Oct 2021 02:10:25 +0300 >>> Subject: [PATCH] scripts: home: Make sure profile directory exists. > > […] > >> Also, wouldn’t it be easier to set HOME to a new directory? >> >>> + guix home reconfigure "${test_directory}/home.scm" > > We probably should clean temporary $HOME directory with 'rm -rf' or > delete each file with 'rm' and then invoke 'rmdir' inside a Bash's > 'trap'. I fill worry about removing operations on $HOME directories. Like you wrote, the trap should “rm -rf $test_directory” rather than “rm -rf $HOME”. It’s safer. :-) > Also returned Andrew's 'guix home search' tests. > > And 'home-bash-service-type' is replaced with 'simple-service' to not to > block the guix-home.sh test from merging in master until completion of > discussion about file-like objects. OK. > From 4b29f7f1592f4256c7cd628624d2225e2d427a9d Mon Sep 17 00:00:00 2001 > From: Oleg Pykhalov <go.wigust@gmail.com> > Date: Sat, 9 Oct 2021 14:52:10 +0300 > Subject: [PATCH 1/2] scripts: home: Make sure profile directory exists. > > * guix/scripts/home.scm (process-action): Make sure profile directory exists. LGTM. > From 5cc0b064af3f4a6238722fbb451a98b499c8d6d2 Mon Sep 17 00:00:00 2001 > From: Oleg Pykhalov <go.wigust@gmail.com> > Date: Sat, 9 Oct 2021 14:52:13 +0300 > Subject: [PATCH 2/2] tests: Add guix-home.sh. > > * tests/guix-home.sh: New file. > * Makefile.am (SH_TESTS): Add this. LGTM, thanks! Ludo’. ^ permalink raw reply [flat|nested] 64+ messages in thread
* bug#50967: [PATCH 00/12] Move (gnu home-services XYZ) to (gnu services XYZ) 2021-10-09 14:34 ` Ludovic Courtès @ 2021-10-09 19:39 ` Oleg Pykhalov 0 siblings, 0 replies; 64+ messages in thread From: Oleg Pykhalov @ 2021-10-09 19:39 UTC (permalink / raw) To: 50967-done; +Cc: Ludovic Courtès, Andrew Tropin, Xinglu Chen, zimoun [-- Attachment #1: Type: text/plain, Size: 175 bytes --] Merged 2 patches from the current issue. Also: - Moved (gnu home-services) to (gnu services). - Added two tests for home-bash-service-type. - Fixed the documentation. Oleg. [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 861 bytes --] ^ permalink raw reply [flat|nested] 64+ messages in thread
* [bug#50967] [PATCH 00/12] Move (gnu home-services XYZ) to (gnu services XYZ) 2021-10-04 23:13 ` [bug#50967] [PATCH 1/3] gnu: Move (gnu home-services) to (gnu home services) Oleg Pykhalov 2021-10-04 23:13 ` [bug#50967] [PATCH 2/3] home: services: configuration: Support file-like objects Oleg Pykhalov 2021-10-04 23:13 ` [bug#50967] [PATCH 3/3] guix: scripts: Make sure profile directory exists Oleg Pykhalov @ 2021-10-08 12:44 ` Oleg Pykhalov 2021-10-08 14:27 ` Andrew Tropin 2021-10-08 22:49 ` Ludovic Courtès 3 siblings, 1 reply; 64+ messages in thread From: Oleg Pykhalov @ 2021-10-08 12:44 UTC (permalink / raw) To: 50967; +Cc: Ludovic Courtès, Xinglu Chen, Andrew Tropin [-- Attachment #1: Type: text/plain, Size: 1064 bytes --] Oleg Pykhalov <go.wigust@gmail.com> writes: > * gnu/home-services/configuration.scm: Move the content ... > ... > * gnu/home-services.scm: Update documentation string. > --- > doc/guix.texi | 8 ++++---- > doc/he-config-bare-bones.scm | 2 +- > gnu/home-services.scm | 4 ++-- > gnu/home.scm | 8 ++++---- > .../services}/configuration.scm | 2 +- > .../services}/fontutils.scm | 2 +- > gnu/{home-services => home/services}/mcron.scm | 4 ++-- > gnu/{home-services => home/services}/shells.scm | 6 +++--- > .../services}/shepherd.scm | 2 +- > .../services}/symlink-manager.scm | 2 +- > gnu/{home-services => home/services}/utils.scm | 2 +- > gnu/{home-services => home/services}/xdg.scm | 6 +++--- > gnu/local.mk | 16 ++++++++-------- […] I pushed only this patch to master. [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 861 bytes --] ^ permalink raw reply [flat|nested] 64+ messages in thread
* [bug#50967] [PATCH 00/12] Move (gnu home-services XYZ) to (gnu services XYZ) 2021-10-08 12:44 ` [bug#50967] " Oleg Pykhalov @ 2021-10-08 14:27 ` Andrew Tropin 2021-10-08 22:46 ` Ludovic Courtès 0 siblings, 1 reply; 64+ messages in thread From: Andrew Tropin @ 2021-10-08 14:27 UTC (permalink / raw) To: Oleg Pykhalov, 50967; +Cc: Ludovic Courtès, Xinglu Chen [-- Attachment #1: Type: text/plain, Size: 1707 bytes --] On 2021-10-08 15:44, Oleg Pykhalov wrote: > Oleg Pykhalov <go.wigust@gmail.com> writes: > >> * gnu/home-services/configuration.scm: Move the content ... >> ... >> * gnu/home-services.scm: Update documentation string. >> --- >> doc/guix.texi | 8 ++++---- >> doc/he-config-bare-bones.scm | 2 +- >> gnu/home-services.scm | 4 ++-- >> gnu/home.scm | 8 ++++---- >> .../services}/configuration.scm | 2 +- >> .../services}/fontutils.scm | 2 +- >> gnu/{home-services => home/services}/mcron.scm | 4 ++-- >> gnu/{home-services => home/services}/shells.scm | 6 +++--- >> .../services}/shepherd.scm | 2 +- >> .../services}/symlink-manager.scm | 2 +- >> gnu/{home-services => home/services}/utils.scm | 2 +- >> gnu/{home-services => home/services}/xdg.scm | 6 +++--- >> gnu/local.mk | 16 ++++++++-------- > > […] > > I pushed only this patch to master. > > Good. I'll update rde home services accordingly next week. It would be cool to notify people about this update, because they probably already have configurations, which will break. etc/news.scm, message in mailing list? What is the best way to do it? Sorry for the late idea, but don't we want gnu/home-services.scm to be gnu/home/services.scm? WDYT? Also, I completely missed this: https://git.savannah.gnu.org/cgit/guix.git/tree/guix/self.scm#n965 It should be updated. Oleg, Thank you for working on this!) -- Best regards, Andrew Tropin [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 832 bytes --] ^ permalink raw reply [flat|nested] 64+ messages in thread
* [bug#50967] [PATCH 00/12] Move (gnu home-services XYZ) to (gnu services XYZ) 2021-10-08 14:27 ` Andrew Tropin @ 2021-10-08 22:46 ` Ludovic Courtès 0 siblings, 0 replies; 64+ messages in thread From: Ludovic Courtès @ 2021-10-08 22:46 UTC (permalink / raw) To: Andrew Tropin; +Cc: Oleg Pykhalov, Xinglu Chen, 50967 Hi, Andrew Tropin <andrew@trop.in> skribis: > It would be cool to notify people about this update, because they > probably already have configurations, which will break. etc/news.scm, > message in mailing list? What is the best way to do it? A message on the mailing list would be nice, but IMO that’s enough. > Sorry for the late idea, but don't we want gnu/home-services.scm to be > gnu/home/services.scm? WDYT? I think so, that’d be consistent. Thanks, Ludo’. ^ permalink raw reply [flat|nested] 64+ messages in thread
* [bug#50967] [PATCH 00/12] Move (gnu home-services XYZ) to (gnu services XYZ) 2021-10-04 23:13 ` [bug#50967] [PATCH 1/3] gnu: Move (gnu home-services) to (gnu home services) Oleg Pykhalov ` (2 preceding siblings ...) 2021-10-08 12:44 ` [bug#50967] " Oleg Pykhalov @ 2021-10-08 22:49 ` Ludovic Courtès 3 siblings, 0 replies; 64+ messages in thread From: Ludovic Courtès @ 2021-10-08 22:49 UTC (permalink / raw) To: Oleg Pykhalov; +Cc: Xinglu Chen, 50967, Andrew Tropin Hi, Oleg Pykhalov <go.wigust@gmail.com> skribis: > * gnu/home-services/configuration.scm: Move the content ... > * gnu/home/services/configuration.scm: ... here. > * gnu/local.mk (GNU_SYSTEM_MODULES): Same. > * gnu/home-services/shells.scm: Replace (gnu home-services configuration) > with (gnu home services configuration). > * gnu/home-services/xdg.scm: Same. > * gnu/home-services/symlink-manager.scm: Rename to > gnu/home/services/symlink-manager.scm. > * gnu/local.mk: Same. > * gnu/home.scm: Replace (gnu home-services symlink-manager) with > (gnu home services symlink-manager). > * gnu/home-services/utils.scm: Rename to gnu/home/services/utils.scm. > * gnu/local.mk: Same. > * gnu/home-services/shells.scm: Replace (gnu home-services utils) with > (gnu home services utils). > * gnu/home-services/xdg.scm: Same. > * gnu/home-services/fontutils.scm: Rename to gnu/services/fontutils.scm. > * gnu/local.mk: Same. > * gnu/home.scm: Replace (gnu home-services fontutils) with > (gnu services fontutils). > * gnu/home-services/shells.scm: Rename to gnu/home/services/shells.scm. > * gnu/local.mk: Same. > * gnu/home.scm: Replace (gnu home-services shells) with (gnu home services shells). > * doc/he-config-bare-bones.scm: Same. > * gnu/home-services/xdg.scm: Rename to gnu/home/services/xdg.scm. > * gnu/local.mk: Same. > * gnu/home.scm: Replace (gnu home-services xdg) with (gnu home services xdg). > * gnu/home-services/shepherd.scm: Move to gnu/home/services/shepherd.scm. > * gnu/local.mk: Same. > * gnu/home-services/mcron.scm: Replace (gnu home-services shepherd) with > (gnu home services shepherd). > * tests/guix-home.sh: Same. > * gnu/home-services/mcron.scm: Move to gnu/home/services/mcron.scm. > * gnu/local.mk: Same. > * doc/guix.texi: Replace (gnu home-services mcron) with > (gnu home services mcron). > * guix/scripts/home/import.scm: Replace (gnu home-services bash) with > (gnu home services bash). > * doc/guix.texi: Replace (gnu home-services) with (gnu home services). > * gnu/home-services.scm > (%service-type-path): Search home services in "gnu/services". > * gnu/home-services.scm: Update documentation string. This part LGTM, though as Andrew suggested, I’d also rename gnu/home-services.scm to gnu/home/services.scm. Thanks, Ludo’. ^ permalink raw reply [flat|nested] 64+ messages in thread
* [bug#50967] [PATCH] home: services: configuration: Move and refactor content. 2021-10-02 13:43 [bug#50967] [PATCH 00/12] Move (gnu home-services XYZ) to (gnu services XYZ) Oleg Pykhalov 2021-10-02 13:45 ` [bug#50967] [PATCH 01/12] tests: Add tests for guix home cli Oleg Pykhalov 2021-10-02 16:38 ` [bug#50967] [PATCH 01/14] tests: Add tests for guix home cli Oleg Pykhalov @ 2021-10-02 20:13 ` Oleg Pykhalov 2 siblings, 0 replies; 64+ messages in thread From: Oleg Pykhalov @ 2021-10-02 20:13 UTC (permalink / raw) To: 50967; +Cc: Oleg Pykhalov * gnu/home/services/configuration.scm: Move content ... * gnu/services/configuration.scm: here. * gnu/home/services/shells.scm: Delete (gnu home services configuration). * gnu/home/services/xdg.scm: Same. * gnu/local.mk: Same. --- gnu/home/services/configuration.scm | 115 ---------------------------- gnu/home/services/shells.scm | 1 - gnu/home/services/xdg.scm | 1 - gnu/local.mk | 1 - gnu/services/configuration.scm | 95 ++++++++++++++++++++++- 5 files changed, 93 insertions(+), 120 deletions(-) delete mode 100644 gnu/home/services/configuration.scm diff --git a/gnu/home/services/configuration.scm b/gnu/home/services/configuration.scm deleted file mode 100644 index 39db7a5693..0000000000 --- a/gnu/home/services/configuration.scm +++ /dev/null @@ -1,115 +0,0 @@ -;;; 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 configuration) - #:use-module (gnu services configuration) - #:use-module (guix gexp) - #:use-module (srfi srfi-1) - #:use-module (ice-9 curried-definitions) - #:use-module (ice-9 match) - #:use-module (guix i18n) - #:use-module (guix diagnostics) - - #:export (filter-configuration-fields - - interpose - list-of - - list-of-strings? - alist? - string-or-gexp? - serialize-string-or-gexp - text-config? - serialize-text-config - generic-serialize-alist-entry - generic-serialize-alist)) - -(define* (filter-configuration-fields configuration-fields fields - #:optional negate?) - "Retrieve the fields listed in FIELDS from CONFIGURATION-FIELDS. -If NEGATE? is @code{#t}, retrieve all fields except FIELDS." - (filter (lambda (field) - (let ((member? (member (configuration-field-name field) fields))) - (if (not negate?) member? (not member?)))) - configuration-fields)) - - -(define* (interpose ls #:optional (delimiter "\n") (grammar 'infix)) - "Same as @code{string-join}, but without join and string, returns an -DELIMITER interposed LS. Support 'infix and 'suffix GRAMMAR values." - (when (not (member grammar '(infix suffix))) - (raise - (formatted-message - (G_ "The GRAMMAR value must be 'infix or 'suffix, but ~a provided.") - grammar))) - (fold-right (lambda (e acc) - (cons (if (file-like? e) - #~(begin - (use-modules (ice-9 rdelim)) - (with-fluids ((%default-port-encoding "UTF-8")) - (with-input-from-file #$e read-string))) - e) - (if (and (null? acc) (eq? grammar 'infix)) - acc - (cons delimiter acc)))) - '() ls)) - -(define (list-of pred?) - "Return a procedure that takes a list and check if all the elements of -the list result in @code{#t} when applying PRED? on them." - (lambda (x) - (if (list? x) - (every pred? x) - #f))) - - -(define list-of-strings? - (list-of string?)) - -(define alist? list?) - -(define (file-or-string-or-gexp? fsg) - (or (string? fsg) (gexp? fsg) (file-like? fsg))) -(define (serialize-file-or-string-or-gexp field-name val) "") - -(define (text-config? config) - (and (list? config) (every file-or-string-or-gexp? config))) -(define (serialize-text-config field-name val) - #~(string-append #$@(interpose val "\n" 'suffix))) - -(define ((generic-serialize-alist-entry serialize-field) entry) - "Apply the SERIALIZE-FIELD procedure on the field and value of ENTRY." - (match entry - ((field . val) (serialize-field field val)))) - -(define (generic-serialize-alist combine serialize-field fields) - "Generate a configuration from an association list FIELDS. - -SERIALIZE-FIELD is a procedure that takes two arguments, it will be -applied on the fields and values of FIELDS using the -@code{generic-serialize-alist-entry} procedure. - -COMBINE is a procedure that takes one or more arguments and combines -all the alist entries into one value, @code{string-append} or -@code{append} are usually good candidates for this. - -See the @code{serialize-alist} procedure in `@code{(gnu home-services -version-control}' for an example usage.)}" - (apply combine - (map (generic-serialize-alist-entry serialize-field) fields))) diff --git a/gnu/home/services/shells.scm b/gnu/home/services/shells.scm index 2308371dd0..4e5825962c 100644 --- a/gnu/home/services/shells.scm +++ b/gnu/home/services/shells.scm @@ -19,7 +19,6 @@ (define-module (gnu home services shells) #:use-module (gnu services configuration) - #:use-module (gnu home services configuration) #:use-module (gnu home services utils) #:use-module (gnu home-services) #:use-module (gnu packages shells) diff --git a/gnu/home/services/xdg.scm b/gnu/home/services/xdg.scm index 4aed9a5803..c285d126dd 100644 --- a/gnu/home/services/xdg.scm +++ b/gnu/home/services/xdg.scm @@ -19,7 +19,6 @@ (define-module (gnu home services xdg) #:use-module (gnu services configuration) - #:use-module (gnu home services configuration) #:use-module (gnu home-services) #:use-module (gnu packages freedesktop) #:use-module (gnu home services utils) diff --git a/gnu/local.mk b/gnu/local.mk index 5e8b769ce9..9c3bf44a2b 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -77,7 +77,6 @@ GNU_SYSTEM_MODULES = \ %D%/home-services.scm \ %D%/home/services/symlink-manager.scm \ %D%/home/services/fontutils.scm \ - %D%/home/services/configuration.scm \ %D%/home/services/shells.scm \ %D%/home/services/shepherd.scm \ %D%/home/services/mcron.scm \ diff --git a/gnu/services/configuration.scm b/gnu/services/configuration.scm index df3d3b6f9b..1829dbd2bf 100644 --- a/gnu/services/configuration.scm +++ b/gnu/services/configuration.scm @@ -4,6 +4,7 @@ ;;; Copyright © 2017, 2018 Clément Lassieur <clement@lassieur.org> ;;; Copyright © 2021 Xinglu Chen <public@yoctocell.xyz> ;;; Copyright © 2021 Maxim Cournoyer <maxim.cournoyer@gmail.com> +;;; Copyright © 2021 Andrew Tropin <andrew@trop.in> ;;; ;;; This file is part of GNU Guix. ;;; @@ -25,10 +26,12 @@ #:use-module (guix records) #:use-module (guix gexp) #:use-module ((guix utils) #:select (source-properties->location)) - #:use-module ((guix diagnostics) #:select (location-file)) + #:use-module ((guix diagnostics) #:select (formatted-message location-file)) #:use-module ((guix modules) #:select (file-name->module-name)) + #:use-module (guix i18n) #:autoload (texinfo) (texi-fragment->stexi) #:autoload (texinfo serialize) (stexi->texi) + #:use-module (ice-9 curried-definitions) #:use-module (ice-9 match) #:use-module (srfi srfi-1) #:use-module (srfi srfi-34) @@ -56,7 +59,21 @@ generate-documentation configuration->documentation empty-serializer - serialize-package)) + serialize-package + + filter-configuration-fields + + interpose + list-of + + list-of-strings? + alist? + string-or-gexp? + serialize-string-or-gexp + text-config? + serialize-text-config + generic-serialize-alist-entry + generic-serialize-alist)) ;;; Commentary: ;;; @@ -323,3 +340,77 @@ Texinfo documentation of its fields." '-fields)))) (display (generate-documentation `((,configuration-symbol ,fields-getter)) configuration-symbol)))) + +(define* (filter-configuration-fields configuration-fields fields + #:optional negate?) + "Retrieve the fields listed in FIELDS from CONFIGURATION-FIELDS. +If NEGATE? is @code{#t}, retrieve all fields except FIELDS." + (filter (lambda (field) + (let ((member? (member (configuration-field-name field) fields))) + (if (not negate?) member? (not member?)))) + configuration-fields)) + + +(define* (interpose ls #:optional (delimiter "\n") (grammar 'infix)) + "Same as @code{string-join}, but without join and string, returns an +DELIMITER interposed LS. Support 'infix and 'suffix GRAMMAR values." + (when (not (member grammar '(infix suffix))) + (raise + (formatted-message + (G_ "The GRAMMAR value must be 'infix or 'suffix, but ~a provided.") + grammar))) + (fold-right (lambda (e acc) + (cons (if (file-like? e) + #~(begin + (use-modules (ice-9 rdelim)) + (with-fluids ((%default-port-encoding "UTF-8")) + (with-input-from-file #$e read-string))) + e) + (if (and (null? acc) (eq? grammar 'infix)) + acc + (cons delimiter acc)))) + '() ls)) + +(define (list-of pred?) + "Return a procedure that takes a list and check if all the elements of +the list result in @code{#t} when applying PRED? on them." + (lambda (x) + (if (list? x) + (every pred? x) + #f))) + + +(define list-of-strings? + (list-of string?)) + +(define alist? list?) + +(define (file-like-or-string-or-gexp? fsg) + (or (string? fsg) (gexp? fsg) (file-like? fsg))) +(define serialize-file-like-or-string-or-gexp empty-serializer) + +(define (text-config? config) + (list-of file-like-or-string-or-gexp?)) +(define (serialize-text-config field-name val) + #~(string-append #$@(interpose val "\n" 'suffix))) + +(define ((generic-serialize-alist-entry serialize-field) entry) + "Apply the SERIALIZE-FIELD procedure on the field and value of ENTRY." + (match entry + ((field . val) (serialize-field field val)))) + +(define (generic-serialize-alist combine serialize-field fields) + "Generate a configuration from an association list FIELDS. + +SERIALIZE-FIELD is a procedure that takes two arguments, it will be +applied on the fields and values of FIELDS using the +@code{generic-serialize-alist-entry} procedure. + +COMBINE is a procedure that takes one or more arguments and combines +all the alist entries into one value, @code{string-append} or +@code{append} are usually good candidates for this. + +See the @code{serialize-alist} procedure in `@code{(gnu home-services +version-control}' for an example usage.)}" + (apply combine + (map (generic-serialize-alist-entry serialize-field) fields))) -- 2.33.0 ^ permalink raw reply related [flat|nested] 64+ messages in thread
end of thread, other threads:[~2021-10-14 15:23 UTC | newest] Thread overview: 64+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2021-10-02 13:43 [bug#50967] [PATCH 00/12] Move (gnu home-services XYZ) to (gnu services XYZ) Oleg Pykhalov 2021-10-02 13:45 ` [bug#50967] [PATCH 01/12] tests: Add tests for guix home cli Oleg Pykhalov 2021-10-02 13:45 ` [bug#50967] [PATCH 02/12] gnu: home-services: Move configuration to (gnu services) Oleg Pykhalov 2021-10-02 13:45 ` [bug#50967] [PATCH 03/12] gnu: home-services: Move symlink-manager " Oleg Pykhalov 2021-10-02 13:45 ` [bug#50967] [PATCH 04/12] gnu: home-services: Move utils " Oleg Pykhalov 2021-10-02 13:45 ` [bug#50967] [PATCH 05/12] gnu: home-services: Move fontutils " Oleg Pykhalov 2021-10-02 13:45 ` [bug#50967] [PATCH 06/12] gnu: home-services: Move shells " Oleg Pykhalov 2021-10-02 13:45 ` [bug#50967] [PATCH 07/12] gnu: home-services: Move xdg " Oleg Pykhalov 2021-10-02 13:45 ` [bug#50967] [PATCH 08/12] gnu: home-services: Move shepherd " Oleg Pykhalov 2021-10-02 13:46 ` [bug#50967] [PATCH 09/12] gnu: home-services: Move mcron " Oleg Pykhalov 2021-10-02 13:46 ` [bug#50967] [PATCH 10/12] gnu: home-services: Change %service-type-path and filter services Oleg Pykhalov 2021-10-02 13:46 ` [bug#50967] [PATCH 11/12] scripts: home: (gnu home-services bash) -> (gnu services bash) Oleg Pykhalov 2021-10-02 13:46 ` [bug#50967] [PATCH 12/12] doc: (gnu home-services) -> (gnu services) Oleg Pykhalov 2021-10-02 16:38 ` [bug#50967] [PATCH 01/14] tests: Add tests for guix home cli Oleg Pykhalov 2021-10-02 16:38 ` [bug#50967] [PATCH 02/14] gnu: home-services: Move configuration to (gnu home services) Oleg Pykhalov 2021-10-02 18:37 ` Xinglu Chen 2021-10-02 16:38 ` [bug#50967] [PATCH 03/14] gnu: home-services: Move symlink-manager " Oleg Pykhalov 2021-10-02 16:38 ` [bug#50967] [PATCH 04/14] gnu: home-services: Move utils " Oleg Pykhalov 2021-10-02 16:38 ` [bug#50967] [PATCH 05/14] gnu: home-services: Move fontutils to (gnu services) Oleg Pykhalov 2021-10-02 16:38 ` [bug#50967] [PATCH 06/14] gnu: home-services: Move shells to (gnu home services) Oleg Pykhalov 2021-10-02 16:38 ` [bug#50967] [PATCH 07/14] gnu: home-services: Move xdg " Oleg Pykhalov 2021-10-02 16:38 ` [bug#50967] [PATCH 08/14] gnu: home-services: Move shepherd " Oleg Pykhalov 2021-10-02 16:38 ` [bug#50967] [PATCH 09/14] gnu: home-services: Move mcron " Oleg Pykhalov 2021-10-02 16:38 ` [bug#50967] [PATCH 10/14] scripts: home: (gnu home-services bash) -> (gnu home services bash) Oleg Pykhalov 2021-10-02 16:38 ` [bug#50967] [PATCH 11/14] doc: (gnu home-services) -> (gnu home services) Oleg Pykhalov 2021-10-02 16:38 ` [bug#50967] [PATCH 12/14] gnu: home-services: Update %service-type-path Oleg Pykhalov 2021-10-04 14:01 ` [bug#50967] [PATCH 00/12] Move (gnu home-services XYZ) to (gnu services XYZ) Ludovic Courtès 2021-10-02 16:38 ` [bug#50967] [PATCH 13/14] home: services: configuration: Support file-like objects Oleg Pykhalov 2021-10-02 18:35 ` Xinglu Chen 2021-10-04 14:04 ` [bug#50967] [PATCH 00/12] Move (gnu home-services XYZ) to (gnu services XYZ) Ludovic Courtès 2021-10-06 8:15 ` [bug#50967] file-like objects instead of gexps Andrew Tropin 2021-10-08 7:56 ` Ludovic Courtès 2021-10-08 10:00 ` Andrew Tropin 2021-10-09 13:34 ` Ludovic Courtès 2021-10-14 8:32 ` Andrew Tropin 2021-10-08 13:45 ` Xinglu Chen 2021-10-08 14:34 ` Andrew Tropin 2021-10-08 10:06 ` [bug#50967] [PATCH 13/14] home: services: configuration: Support file-like objects Andrew Tropin 2021-10-14 7:08 ` Andrew Tropin 2021-10-02 16:38 ` [bug#50967] [PATCH 14/14] doc: Document guix home import Oleg Pykhalov 2021-10-02 18:42 ` Xinglu Chen 2021-10-02 19:45 ` Oleg Pykhalov 2021-10-04 13:58 ` [bug#50967] [PATCH 00/12] Move (gnu home-services XYZ) to (gnu services XYZ) Ludovic Courtès 2021-10-04 23:13 ` [bug#50967] [PATCH 1/3] gnu: Move (gnu home-services) to (gnu home services) Oleg Pykhalov 2021-10-04 23:13 ` [bug#50967] [PATCH 2/3] home: services: configuration: Support file-like objects Oleg Pykhalov 2021-10-04 23:13 ` [bug#50967] [PATCH 3/3] guix: scripts: Make sure profile directory exists Oleg Pykhalov 2021-10-05 10:20 ` Oleg Pykhalov 2021-10-06 21:22 ` [bug#50967] [PATCH 00/12] Move (gnu home-services XYZ) to (gnu services XYZ) Ludovic Courtès 2021-10-06 22:05 ` [bug#50967] [PATCH 3/3] guix: scripts: Make sure profile directory exists Oleg Pykhalov 2021-10-06 22:15 ` [bug#50967] [PATCH 00/12] Move (gnu home-services XYZ) to (gnu services XYZ) Oleg Pykhalov 2021-10-07 6:37 ` Maxime Devos 2021-10-07 9:56 ` Oleg Pykhalov 2021-10-07 16:43 ` Maxime Devos 2021-10-08 22:44 ` Ludovic Courtès 2021-10-08 22:57 ` Ludovic Courtès 2021-10-09 12:34 ` Oleg Pykhalov 2021-10-09 12:45 ` Oleg Pykhalov 2021-10-09 14:34 ` Ludovic Courtès 2021-10-09 19:39 ` bug#50967: " Oleg Pykhalov 2021-10-08 12:44 ` [bug#50967] " Oleg Pykhalov 2021-10-08 14:27 ` Andrew Tropin 2021-10-08 22:46 ` Ludovic Courtès 2021-10-08 22:49 ` Ludovic Courtès 2021-10-02 20:13 ` [bug#50967] [PATCH] home: services: configuration: Move and refactor content Oleg Pykhalov
Code repositories for project(s) associated with this external index https://git.savannah.gnu.org/cgit/guix.git This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.