From: Attila Lendvai <attila@lendvai.name>
To: 56799@debbugs.gnu.org
Cc: Attila Lendvai <attila@lendvai.name>
Subject: bug#56799: [PATCH 4/5] services: Use the new maybe/unset API.
Date: Wed, 24 Aug 2022 14:40:41 +0200 [thread overview]
Message-ID: <20220824124042.10959-4-attila@lendvai.name> (raw)
In-Reply-To: <20220824124042.10959-1-attila@lendvai.name>
* gnu/home/services/ssh.scm (serialize-address-family): Use the public API of
the maybe infrastructure.
* gnu/services/file-sharing.scm (serialize-maybe-string): Use maybe-value.
(serialize-maybe-file-object): Use maybe-value-set?.
* gnu/services/getmail.scm (getmail-retriever-configuration): Don't use
internals in unset field declarations.
(getmail-destination-configuration): Ditto.
* gnu/services/messaging.scm (raw-content?): Use maybe-value-set?.
(prosody-configuration): Use %unset-value.
* gnu/services/telephony.scm (jami-shepherd-services): Use maybe-value-set?.
(archive-name->username): Use maybe-value-set?.
* tests/services/configuration.scm ("maybe type, no default"): Use
%unset-value.
---
gnu/home/services/ssh.scm | 12 +++++++-----
gnu/services/file-sharing.scm | 11 ++++-------
gnu/services/getmail.scm | 6 +++---
gnu/services/kerberos.scm | 1 +
gnu/services/messaging.scm | 15 ++++++++++-----
gnu/services/networking.scm | 2 +-
gnu/services/telephony.scm | 6 +++---
tests/services/configuration.scm | 2 +-
8 files changed, 30 insertions(+), 25 deletions(-)
diff --git a/gnu/home/services/ssh.scm b/gnu/home/services/ssh.scm
index f0987aee23..d15f5ee912 100644
--- a/gnu/home/services/ssh.scm
+++ b/gnu/home/services/ssh.scm
@@ -69,17 +69,19 @@ (define (serialize-string field value)
" " value "\n"))
(define (address-family? obj)
- (memv obj (list 'unset AF_INET AF_INET6)))
+ (memv obj (list AF_INET AF_INET6)))
+
+(define-maybe address-family)
(define (serialize-address-family field family)
- (if (eq? 'unset family)
- ""
+ (if (maybe-value-set? family)
(string-append " " (serialize-field-name field) " "
(cond ((= family AF_INET) "inet")
((= family AF_INET6) "inet6")
;; The 'else' branch is unreachable.
(else (raise (condition (&error)))))
- "\n")))
+ "\n")
+ ""))
(define (natural-number? obj)
(and (integer? obj) (exact? obj) (> obj 0)))
@@ -115,7 +117,7 @@ (define-configuration openssh-host
maybe-string
"Host name---e.g., @code{\"foo.example.org\"} or @code{\"192.168.1.2\"}.")
(address-family
- address-family
+ maybe-address-family
"Address family to use when connecting to this host: one of
@code{AF_INET} (for IPv4 only), @code{AF_INET6} (for IPv6 only).
Additionally, the field can be left unset to allow any address family.")
diff --git a/gnu/services/file-sharing.scm b/gnu/services/file-sharing.scm
index 5df8b0d597..75e99f20b7 100644
--- a/gnu/services/file-sharing.scm
+++ b/gnu/services/file-sharing.scm
@@ -114,10 +114,7 @@ (define-maybe string)
;; name-value pair for the JSON builder.
(set! serialize-maybe-string
(lambda (field-name val)
- (serialize-string field-name
- (if (eq? val 'unset)
- ""
- val))))
+ (serialize-string field-name (maybe-value val ""))))
(define (string-list? val)
(and (list? val)
@@ -180,9 +177,9 @@ (define (serialize-file-object field-name val)
(define-maybe file-object)
(set! serialize-maybe-file-object
(lambda (field-name val)
- (if (eq? val 'unset)
- (serialize-string field-name "")
- (serialize-file-object field-name val))))
+ (if (maybe-value-set? val)
+ (serialize-file-object field-name val)
+ (serialize-string field-name ""))))
(define (file-object-list? val)
(and (list? val)
diff --git a/gnu/services/getmail.scm b/gnu/services/getmail.scm
index ce124f6b11..0a1c34cfd3 100644
--- a/gnu/services/getmail.scm
+++ b/gnu/services/getmail.scm
@@ -111,10 +111,10 @@ (define-configuration getmail-retriever-configuration
"The type of mail retriever to use. Valid values include
@samp{passwd} and @samp{static}.")
(server
- (string 'unset)
+ string
"Name or IP address of the server to retrieve mail from.")
(username
- (string 'unset)
+ string
"Username to login to the mail server with.")
(port
(non-negative-integer #f)
@@ -143,7 +143,7 @@ (define (serialize-getmail-destination-configuration field-name val)
(define-configuration getmail-destination-configuration
(type
- (string 'unset)
+ string
"The type of mail destination. Valid values include @samp{Maildir},
@samp{Mboxrd} and @samp{MDA_external}.")
(path
diff --git a/gnu/services/kerberos.scm b/gnu/services/kerberos.scm
index f845c1bd89..c3c7872734 100644
--- a/gnu/services/kerberos.scm
+++ b/gnu/services/kerberos.scm
@@ -39,6 +39,7 @@ (define-module (gnu services kerberos)
\f
+;; TODO Use %unset-value and the define-maybe infrastructure.
(define unset-field (list 'unset-field))
(define (predicate/unset pred)
diff --git a/gnu/services/messaging.scm b/gnu/services/messaging.scm
index 00a1c80a14..59cb486778 100644
--- a/gnu/services/messaging.scm
+++ b/gnu/services/messaging.scm
@@ -90,6 +90,11 @@ (define (make-pred arg)
((new-def ...)
(map (lambda (def target)
(if (eq? 'common (syntax->datum target))
+ ;; TODO Use the %unset-value variable, or
+ ;; even better just simplify this so that it
+ ;; doesn't interfere with
+ ;; define-configuration and define-maybe
+ ;; internals.
#''unset def))
#'(def ...) #'(target ...)))
((new-doc ...)
@@ -200,7 +205,7 @@ (define (serialize-file-object-list field-name val)
(define-maybe file-object-list)
(define (raw-content? val)
- (not (eq? val 'unset)))
+ (maybe-value-set? val))
(define (serialize-raw-content field-name val)
val)
(define-maybe raw-content)
@@ -474,12 +479,12 @@ (define-all-configurations prosody-configuration
global)
(http-max-content-size
- (maybe-non-negative-integer 'unset)
+ (maybe-non-negative-integer %unset-value)
"Maximum allowed size of the HTTP body (in bytes)."
common)
(http-external-url
- (maybe-string 'unset)
+ (maybe-string %unset-value)
"Some modules expose their own URL in various ways. This URL is built
from the protocol, host and port used. If Prosody sits behind a proxy, the
public URL will be @code{http-external-url} instead. See
@@ -556,7 +561,7 @@ (define-all-configurations prosody-configuration
int-component)
(mod-muc
- (maybe-mod-muc-configuration 'unset)
+ (maybe-mod-muc-configuration %unset-value)
"Multi-user chat (MUC) is Prosody's module for allowing you to create
hosted chatrooms/conferences for XMPP users.
@@ -573,7 +578,7 @@ (define-all-configurations prosody-configuration
ext-component)
(raw-content
- (maybe-raw-content 'unset)
+ (maybe-raw-content %unset-value)
"Raw content that will be added to the configuration file."
common)))
diff --git a/gnu/services/networking.scm b/gnu/services/networking.scm
index 3c6395b6ca..9d85728371 100644
--- a/gnu/services/networking.scm
+++ b/gnu/services/networking.scm
@@ -772,7 +772,7 @@ (define-configuration/no-serialization opendht-configuration
network. A specific port value can be provided by appending the @code{:PORT}
suffix. By default, it uses the Jami bootstrap nodes, but any host can be
specified here. It's also possible to disable bootstrapping by explicitly
-setting this field to the @code{'unset} value.")
+setting this field to @code{%unset-value}.")
(port
(maybe-number 4222)
"The UDP port to bind to. When left unspecified, an available port is
diff --git a/gnu/services/telephony.scm b/gnu/services/telephony.scm
index 7152f3b38d..624b30116d 100644
--- a/gnu/services/telephony.scm
+++ b/gnu/services/telephony.scm
@@ -307,7 +307,7 @@ (define (jami-shepherd-services config)
(dbus (jami-configuration-dbus config))
(dbus-daemon (file-append dbus "/bin/dbus-daemon"))
(accounts (jami-configuration-accounts config))
- (declarative-mode? (not (eq? 'unset accounts))))
+ (declarative-mode? (maybe-value-set? accounts)))
(with-extensions (list guile-packrat ;used by guile-ac-d-bus
guile-ac-d-bus
@@ -649,7 +649,7 @@ (define (archive-name->username archive)
account-details)
(let ((username (archive-name->username
archive)))
- (when (not (eq? 'unset allowed-contacts))
+ (when (maybe-value-set? allowed-contacts)
;; Reject calls from unknown contacts.
(set-account-details
'(("DHT.PublicInCalls" . "false")) username)
@@ -659,7 +659,7 @@ (define (archive-name->username archive)
;; Add allowed ones.
(for-each (cut add-contact <> username)
allowed-contacts))
- (when (not (eq? 'unset moderators))
+ (when (maybe-value-set? moderators)
;; Disable the 'AllModerators' property.
(set-all-moderators #f username)
;; Remove all moderators.
diff --git a/tests/services/configuration.scm b/tests/services/configuration.scm
index 649dad26e8..8ed4ed4b66 100644
--- a/tests/services/configuration.scm
+++ b/tests/services/configuration.scm
@@ -169,7 +169,7 @@ (define-configuration config-with-maybe-string/no-serialization
(not (defined? 'serialize-maybe-string)))
(test-assert "maybe type, no default"
- (eq? 'unset
+ (eq? %unset-value
(config-with-maybe-string/no-serialization-name
(config-with-maybe-string/no-serialization))))
--
2.35.1
next prev parent reply other threads:[~2022-08-24 13:28 UTC|newest]
Thread overview: 47+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-27 16:23 bug#56799: (gnu services configuration) usage of *unspecified* is problematic Maxim Cournoyer
2022-07-27 16:43 ` Tobias Geerinckx-Rice via Bug reports for GNU Guix
2022-07-27 18:27 ` Attila Lendvai
2022-07-28 15:15 ` Maxim Cournoyer
2022-07-27 18:31 ` Maxim Cournoyer
2022-07-27 18:45 ` Tobias Geerinckx-Rice via Bug reports for GNU Guix
2022-07-27 19:09 ` Maxim Cournoyer
2022-07-27 19:45 ` bug#56799: [PATCH] services: configuration: Step back from *unspecified* Maxim Cournoyer
2022-07-27 19:46 ` bug#56799: (gnu services configuration) usage of *unspecified* is problematic Maxim Cournoyer
2022-07-27 20:20 ` bug#56799: [PATCH v2] gexp: Handle *unspecified* as a gexp input Maxim Cournoyer
2022-07-27 21:43 ` Maxime Devos
2022-07-28 14:58 ` Maxim Cournoyer
2022-07-28 4:41 ` bug#56799: [PATCH v3] " Maxim Cournoyer
2022-08-01 5:08 ` bug#56799: (gnu services configuration) usage of *unspecified* is problematic Maxim Cournoyer
2022-08-01 10:00 ` Maxime Devos
2022-08-01 12:46 ` Maxim Cournoyer
2022-08-01 13:44 ` Ludovic Courtès
2022-08-01 16:55 ` Maxim Cournoyer
2022-07-28 4:55 ` bokr
2022-07-28 10:26 ` Maxime Devos
2022-07-28 15:09 ` Maxim Cournoyer
2022-08-01 13:49 ` Ludovic Courtès
2022-08-01 15:55 ` Maxim Cournoyer
2022-08-02 7:31 ` Ludovic Courtès
2022-08-02 8:45 ` bokr
2022-08-02 15:06 ` Maxim Cournoyer
2022-08-04 12:19 ` Ludovic Courtès
2022-08-07 22:44 ` Ludovic Courtès
2022-08-08 22:27 ` Attila Lendvai
2022-08-08 23:35 ` Attila Lendvai
2022-08-10 2:17 ` Maxim Cournoyer
2022-08-10 3:26 ` Maxim Cournoyer
2022-08-11 10:15 ` Attila Lendvai
2022-08-13 6:31 ` Maxim Cournoyer
2022-08-13 16:47 ` Attila Lendvai
2022-08-14 2:57 ` Maxim Cournoyer
2022-08-16 14:00 ` Attila Lendvai
2022-08-17 13:16 ` Maxim Cournoyer
2022-08-17 16:00 ` paren--- via Bug reports for GNU Guix
2022-08-10 0:43 ` Maxim Cournoyer
2022-08-24 12:40 ` bug#56799: [PATCH 1/5] services: configuration: Add a 'maybe-value-set?' procedure Attila Lendvai
2022-08-24 12:40 ` bug#56799: [PATCH 2/5] services: configuration: Add %unset-value exported variable Attila Lendvai
2022-08-24 12:40 ` bug#56799: [PATCH 3/5] services: configuration: Add maybe-value exported procedure Attila Lendvai
2022-08-24 12:40 ` Attila Lendvai [this message]
2022-08-25 4:18 ` bug#56799: (gnu services configuration) usage of *unspecified* is problematic Maxim Cournoyer
2022-08-24 12:40 ` bug#56799: [PATCH 5/5] services: configuration: Change the value of the unset marker Attila Lendvai
2022-08-25 4:14 ` bug#56799: (gnu services configuration) usage of *unspecified* is problematic Maxim Cournoyer
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220824124042.10959-4-attila@lendvai.name \
--to=attila@lendvai.name \
--cc=56799@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 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.