unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: Oleg Pykhalov <go.wigust@gmail.com>
To: 50967@debbugs.gnu.org
Cc: Oleg Pykhalov <go.wigust@gmail.com>
Subject: [bug#50967] [PATCH 02/12] gnu: home-services: Move configuration to (gnu services).
Date: Sat,  2 Oct 2021 16:45:53 +0300	[thread overview]
Message-ID: <20211002134603.6229-2-go.wigust@gmail.com> (raw)
In-Reply-To: <20211002134603.6229-1-go.wigust@gmail.com>

* 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





  reply	other threads:[~2021-10-02 13:49 UTC|newest]

Thread overview: 64+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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   ` Oleg Pykhalov [this message]
2021-10-02 13:45   ` [bug#50967] [PATCH 03/12] gnu: home-services: Move symlink-manager to (gnu services) 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211002134603.6229-2-go.wigust@gmail.com \
    --to=go.wigust@gmail.com \
    --cc=50967@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).