services: configuration: Add some commonly used predicates.

* 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.

Signed-off-by: Maxim Cournoyer <maxim.cournoyer@gmail.com>
This commit is contained in:
Bruno Victal 2023-10-07 16:59:09 +01:00 committed by Maxim Cournoyer
parent 3872ecf274
commit 00a28bc435
No known key found for this signature in database
GPG Key ID: 1260E46482E63562
4 changed files with 29 additions and 21 deletions

View File

@ -28188,7 +28188,7 @@ to maintain communication between devices on such network even when the
connection to the Internet has been lost. When left unspecified, connection to the Internet has been lost. When left unspecified,
the value from the account archive prevails. 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 A list of hostnames or IPs pointing to OpenDHT nodes, that should be
used to initially join the OpenDHT network. When left unspecified, the used to initially join the OpenDHT network. When left unspecified, the
value from the account archive prevails. value from the account archive prevails.
@ -34509,7 +34509,7 @@ The group to run mpd as.
The default @code{%mpd-group} is a system group with name ``mpd''. 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 A list of symbols naming Shepherd services that this service
will depend on. will depend on.
@ -34759,7 +34759,7 @@ Available @code{mympd-configuration} fields are:
@item @code{package} (default: @code{mympd}) (type: file-like) @item @code{package} (default: @code{mympd}) (type: file-like)
The package object of the myMPD server. 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 This is a list of symbols naming Shepherd services that this service
will depend on. will depend on.

View File

@ -138,9 +138,6 @@
str) str)
#\-) "_"))) #\-) "_")))
(define list-of-symbol?
(list-of symbol?))
;; Helpers for deprecated field types, to be removed later. ;; Helpers for deprecated field types, to be removed later.
(define %lazy-group (make-symbol "%lazy-group")) (define %lazy-group (make-symbol "%lazy-group"))
@ -428,7 +425,7 @@ to be appended to the audio output configuration.")
(sanitizer mpd-group-sanitizer)) (sanitizer mpd-group-sanitizer))
(shepherd-requirement (shepherd-requirement
(list-of-symbol '()) (list-of-symbols '())
"This is a list of symbols naming Shepherd services that this service "This is a list of symbols naming Shepherd services that this service
will depend on." will depend on."
empty-serializer) empty-serializer)
@ -763,7 +760,7 @@ user-group instead~%"))
empty-serializer) empty-serializer)
(shepherd-requirement (shepherd-requirement
(list-of-symbol '()) (list-of-symbols '())
"This is a list of symbols naming Shepherd services that this service "This is a list of symbols naming Shepherd services that this service
will depend on." will depend on."
empty-serializer) empty-serializer)

View File

@ -80,7 +80,9 @@
interpose interpose
list-of list-of
list-of-packages?
list-of-strings? list-of-strings?
list-of-symbols?
alist? alist?
serialize-file-like serialize-file-like
text-config? text-config?
@ -500,6 +502,11 @@ DELIMITER interposed LS. Support 'infix and 'suffix GRAMMAR values."
(cons delimiter acc)))) (cons delimiter acc))))
'() ls)) '() ls))
;;;
;;; Commonly used predicates
;;;
(define (list-of pred?) (define (list-of pred?)
"Return a procedure that takes a list and check if all the elements of "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." the list result in @code{#t} when applying PRED? on them."
@ -508,10 +515,20 @@ the list result in @code{#t} when applying PRED? on them."
(every pred? x) (every pred? x)
#f))) #f)))
(define list-of-packages?
(list-of package?))
(define list-of-strings? (define list-of-strings?
(list-of string?)) (list-of string?))
(define list-of-symbols?
(list-of symbol?))
;;;
;;; Special serializers
;;;
(define alist? (define alist?
(list-of pair?)) (list-of pair?))

View File

@ -117,15 +117,10 @@
(or (string? val) (or (string? val)
(computed-file? val))) (computed-file? val)))
(define (string-list? val) (define account-fingerprint-list?
(and (list? val) (list-of account-fingerprint?))
(and-map string? val)))
(define (account-fingerprint-list? val) (define-maybe list-of-strings)
(and (list? val)
(and-map account-fingerprint? val)))
(define-maybe string-list)
(define-maybe/no-serialization account-fingerprint-list) (define-maybe/no-serialization account-fingerprint-list)
@ -135,7 +130,7 @@
;;; The following serializers are used to derive an account details alist from ;;; The following serializers are used to derive an account details alist from
;;; a <jami-account> record. ;;; a <jami-account> record.
(define (serialize-string-list _ val) (define (serialize-list-of-strings _ val)
(string-join val ";")) (string-join val ";"))
(define (serialize-boolean _ val) (define (serialize-boolean _ val)
@ -188,7 +183,7 @@ maintain communication between devices on such network even when the
connection to the the Internet has been lost. When left unspecified, the connection to the the Internet has been lost. When left unspecified, the
value from the account archive prevails.") value from the account archive prevails.")
(bootstrap-hostnames (bootstrap-hostnames
maybe-string-list maybe-list-of-strings
"A list of hostnames or IPs pointing to OpenDHT nodes, that should be used "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 to initially join the OpenDHT network. When left unspecified, the value from
the account archive prevails.") the account archive prevails.")
@ -220,9 +215,8 @@ SET-ACCOUNT-DETAILS."
(list-transduce jami-account-transducer rcons jami-account-fields)) (list-transduce jami-account-transducer rcons jami-account-fields))
(define (jami-account-list? val) (define jami-account-list?
(and (list? val) (list-of jami-account?))
(and-map jami-account? val)))
(define-maybe/no-serialization jami-account-list) (define-maybe/no-serialization jami-account-list)