From patchwork Mon Jun 26 21:59:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bruno Victal X-Patchwork-Id: 51377 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 31EB427BBEA; Mon, 26 Jun 2023 23:03:20 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI, SPF_HELO_PASS autolearn=ham autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 1DBAF27BBE2 for ; Mon, 26 Jun 2023 23:03:19 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qDuGn-0005E9-LU; Mon, 26 Jun 2023 18:01:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qDuGi-00051q-8y for guix-patches@gnu.org; Mon, 26 Jun 2023 18:01:10 -0400 Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qDuGd-0005X8-Fo for guix-patches@gnu.org; Mon, 26 Jun 2023 18:01:05 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qDuGd-0008Sg-7K for guix-patches@gnu.org; Mon, 26 Jun 2023 18:01:03 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#63985] [PATCH v3 07/11] services: configuration: Add some commonly used predicates. Resent-From: Bruno Victal Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Mon, 26 Jun 2023 22:01:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 63985 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 63985@debbugs.gnu.org Cc: Bruno Victal Received: via spool by 63985-submit@debbugs.gnu.org id=B63985.168781682932386 (code B ref 63985); Mon, 26 Jun 2023 22:01:03 +0000 Received: (at 63985) by debbugs.gnu.org; 26 Jun 2023 22:00:29 +0000 Received: from localhost ([127.0.0.1]:47177 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qDuG4-0008QH-IL for submit@debbugs.gnu.org; Mon, 26 Jun 2023 18:00:29 -0400 Received: from smtpm1.myservices.hosting ([185.26.105.232]:58444) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qDuFx-0008Pt-7k for 63985@debbugs.gnu.org; Mon, 26 Jun 2023 18:00:22 -0400 Received: from mail1.netim.hosting (unknown [185.26.106.173]) by smtpm1.myservices.hosting (Postfix) with ESMTP id A97D520512 for <63985@debbugs.gnu.org>; Tue, 27 Jun 2023 00:00:20 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by mail1.netim.hosting (Postfix) with ESMTP id 0CCB88009B; Tue, 27 Jun 2023 00:00:20 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at mail1.netim.hosting Received: from mail1.netim.hosting ([127.0.0.1]) by localhost (mail1-2.netim.hosting [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id 2l1PFbt-_Fo0; Tue, 27 Jun 2023 00:00:19 +0200 (CEST) Received: from guix-nuc.home.arpa (unknown [10.192.1.83]) (Authenticated sender: lumen@makinata.eu) by mail1.netim.hosting (Postfix) with ESMTPSA id 3BF1D8009A; Tue, 27 Jun 2023 00:00:19 +0200 (CEST) From: Bruno Victal Date: Mon, 26 Jun 2023 22:59:33 +0100 Message-Id: X-Mailer: git-send-email 2.39.2 In-Reply-To: References: MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches * gnu/services/configuration.scm (list-of-packages?, list-of-symbols?): New predicate. * gnu/services/audio.scm (list-of-symbol?): Remove. * gnu/services/telephony.scm (string-list?): Remove. (serialize-string-list): Rename to … (serialize-list-of-strings): … this. (account-fingerprint-list?, jami-account-list?): Use list-of. * doc/guix.texi: Update it. --- doc/guix.texi | 4 ++-- gnu/services/audio.scm | 7 ++----- gnu/services/configuration.scm | 16 ++++++++++++++++ gnu/services/telephony.scm | 20 +++++++------------- 4 files changed, 27 insertions(+), 20 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index 14802e9366..2f7e734874 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -27850,7 +27850,7 @@ Telephony Services connection to the Internet has been lost. When left unspecified, the value from the account archive prevails. -@item @code{bootstrap-hostnames} (type: maybe-string-list) +@item @code{bootstrap-hostnames} (type: maybe-list-of-strings) A list of hostnames or IPs pointing to OpenDHT nodes, that should be used to initially join the OpenDHT network. When left unspecified, the value from the account archive prevails. @@ -34244,7 +34244,7 @@ Audio Services The group to run mpd as. The default @code{%mpd-group} is a system group with name ``mpd''. -@item @code{shepherd-requirement} (default: @code{'()}) (type: list-of-symbol) +@item @code{shepherd-requirement} (default: @code{'()}) (type: list-of-symbols) A list of symbols naming Shepherd services that this service will depend on. diff --git a/gnu/services/audio.scm b/gnu/services/audio.scm index 690409b7a1..89ab9c51c6 100644 --- a/gnu/services/audio.scm +++ b/gnu/services/audio.scm @@ -137,9 +137,6 @@ (define (uglify-field-name field-name) str) #\-) "_"))) -(define list-of-symbol? - (list-of symbol?)) - ;; Helpers for deprecated field types, to be removed later. (define %lazy-group (make-symbol "%lazy-group")) @@ -413,7 +410,7 @@ (define-configuration mpd-configuration (sanitizer mpd-group-sanitizer)) (shepherd-requirement - (list-of-symbol '()) + (list-of-symbols '()) "This is a list of symbols naming Shepherd services that this service will depend on." empty-serializer) @@ -711,7 +708,7 @@ (define-configuration/no-serialization mympd-configuration empty-serializer) (shepherd-requirement - (list-of-symbol '()) + (list-of-symbols '()) "This is a list of symbols naming Shepherd services that this service will depend on." empty-serializer) diff --git a/gnu/services/configuration.scm b/gnu/services/configuration.scm index 4eee5a26c2..fd9130b1ea 100644 --- a/gnu/services/configuration.scm +++ b/gnu/services/configuration.scm @@ -81,7 +81,9 @@ (define-module (gnu services configuration) interpose list-of + list-of-packages? list-of-strings? + list-of-symbols? alist? serialize-file-like text-config? @@ -508,6 +510,10 @@ (define* (interpose ls #:optional (delimiter "\n") (grammar 'infix)) (cons delimiter acc)))) '() ls)) + +;;; +;;; Commonly used predicates + (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." @@ -516,10 +522,20 @@ (define (list-of pred?) (every pred? x) #f))) +(define list-of-packages? + (list-of package?)) (define list-of-strings? (list-of string?)) +(define list-of-symbols? + (list-of symbol?)) + + +;;; +;;; Special serializers +;;; + (define alist? (list-of pair?)) diff --git a/gnu/services/telephony.scm b/gnu/services/telephony.scm index 56b7772f58..c9b5d6cd99 100644 --- a/gnu/services/telephony.scm +++ b/gnu/services/telephony.scm @@ -117,15 +117,10 @@ (define (string-or-computed-file? val) (or (string? val) (computed-file? val))) -(define (string-list? val) - (and (list? val) - (and-map string? val))) +(define account-fingerprint-list? + (list-of account-fingerprint?)) -(define (account-fingerprint-list? val) - (and (list? val) - (and-map account-fingerprint? val))) - -(define-maybe string-list) +(define-maybe list-of-strings) (define-maybe/no-serialization account-fingerprint-list) @@ -135,7 +130,7 @@ (define-maybe string) ;;; The following serializers are used to derive an account details alist from ;;; a record. -(define (serialize-string-list _ val) +(define (serialize-list-of-strings _ val) (string-join val ";")) (define (serialize-boolean _ val) @@ -188,7 +183,7 @@ (define-configuration jami-account connection to the the Internet has been lost. When left unspecified, the value from the account archive prevails.") (bootstrap-hostnames - maybe-string-list + maybe-list-of-strings "A list of hostnames or IPs pointing to OpenDHT nodes, that should be used to initially join the OpenDHT network. When left unspecified, the value from the account archive prevails.") @@ -220,9 +215,8 @@ (define (jami-account->alist jami-account-object) (list-transduce jami-account-transducer rcons jami-account-fields)) -(define (jami-account-list? val) - (and (list? val) - (and-map jami-account? val))) +(define jami-account-list? + (list-of jami-account?)) (define-maybe/no-serialization jami-account-list)