From patchwork Sat Oct 7 15:59:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bruno Victal X-Patchwork-Id: 54584 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 5D64227BBE2; Sat, 7 Oct 2023 17:00:03 +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=unavailable 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 B2F9827BBE9 for ; Sat, 7 Oct 2023 17:00:01 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qp9iU-0008A2-Uo; Sat, 07 Oct 2023 11:59:46 -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 1qp9iS-00089X-SC for guix-patches@gnu.org; Sat, 07 Oct 2023 11:59:44 -0400 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qp9iS-00019N-KG for guix-patches@gnu.org; Sat, 07 Oct 2023 11:59:44 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qp9im-0002WI-1R; Sat, 07 Oct 2023 12:00:04 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#63985] [PATCH v4 5/5] services: configuration: Add some commonly used predicates. Resent-From: Bruno Victal Original-Sender: "Debbugs-submit" Resent-CC: maxim.cournoyer@gmail.com, guix-patches@gnu.org Resent-Date: Sat, 07 Oct 2023 16:00: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 , Maxim Cournoyer X-Debbugs-Original-Xcc: Maxim Cournoyer Received: via spool by 63985-submit@debbugs.gnu.org id=B63985.16966943999514 (code B ref 63985); Sat, 07 Oct 2023 16:00:03 +0000 Received: (at 63985) by debbugs.gnu.org; 7 Oct 2023 15:59:59 +0000 Received: from localhost ([127.0.0.1]:55740 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qp9ig-0002TN-Ix for submit@debbugs.gnu.org; Sat, 07 Oct 2023 11:59:59 -0400 Received: from smtpmciv1.myservices.hosting ([185.26.107.237]:51240) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qp9ie-0002TC-2M for 63985@debbugs.gnu.org; Sat, 07 Oct 2023 11:59:56 -0400 Received: from mail1.netim.hosting (unknown [185.26.106.173]) by smtpmciv1.myservices.hosting (Postfix) with ESMTP id D521D20CEC for <63985@debbugs.gnu.org>; Sat, 7 Oct 2023 17:59:30 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by mail1.netim.hosting (Postfix) with ESMTP id 4FA1F80095; Sat, 7 Oct 2023 17:59:25 +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 PHHlMCHOxgxL; Sat, 7 Oct 2023 17:59:24 +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 A9C598009B; Sat, 7 Oct 2023 17:59:24 +0200 (CEST) From: Bruno Victal Date: Sat, 7 Oct 2023 16:59:09 +0100 Message-ID: X-Mailer: git-send-email 2.41.0 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 | 6 +++--- gnu/services/audio.scm | 7 ++----- gnu/services/configuration.scm | 17 +++++++++++++++++ gnu/services/telephony.scm | 20 +++++++------------- 4 files changed, 29 insertions(+), 21 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index e4a1523dfb..1deb784f56 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -28188,7 +28188,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. @@ -34509,7 +34509,7 @@ Audio Services 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. @@ -34759,7 +34759,7 @@ Audio Services @item @code{package} (default: @code{mympd}) (type: file-like) The package object of the myMPD server. -@item @code{shepherd-requirement} (default: @code{'()}) (type: list-of-symbol) +@item @code{shepherd-requirement} (default: @code{'()}) (type: list-of-symbols) This is 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 260abdefed..ae991ced4d 100644 --- a/gnu/services/audio.scm +++ b/gnu/services/audio.scm @@ -138,9 +138,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")) @@ -428,7 +425,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) @@ -763,7 +760,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 aa5fb832d5..d2b1687496 100644 --- a/gnu/services/configuration.scm +++ b/gnu/services/configuration.scm @@ -80,7 +80,9 @@ (define-module (gnu services configuration) interpose list-of + list-of-packages? list-of-strings? + list-of-symbols? alist? serialize-file-like text-config? @@ -500,6 +502,11 @@ (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." @@ -508,10 +515,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)