[PATCH] services: configuration: Use *unspecified* instead of 'disabled.

  • Done
  • quality assurance status badge
Details
3 participants
  • Attila Lendvai
  • Ludovic Courtès
  • Maxime Devos
Owner
unassigned
Submitted by
Attila Lendvai
Severity
normal
A
A
Attila Lendvai wrote on 1 Apr 2022 21:19
(address . guix-patches@gnu.org)(name . Attila Lendvai)(address . attila@lendvai.name)
20220401191957.16624-1-attila@lendvai.name
...as a marker for field values that have not been set. Rationale: 'disabled
may easily clash with user values for boolean fields, is confusing (i.e. its
meaning is *not* boolean false, bug unspecified) and it also passes through
silently the symbol? predicate of a field of type symbol.

Relax the syntax to accept (field1 (maybe-string) "") forms, in which case it
uses *unspecified* as default value.

Possible future improvement: also accept (field1 maybe-string "") forms,
i.e. without the extra parens around maybe types without defaults.

* gnu/services/configuration.scm (configuration-missing-default-value):
Renamed from configuration-no-default-value.
* gnu/services/configuration.scm (define-maybe-helper): Use *unspecified*
instead of 'disabled, and make the default value optional.
---

i could not test every service that uses define-configuration, but i did
reconfigure my server with this commit, and i have adapted and tested my
swarm service code with it, too.

take it as a request for comments, but it may very well be of good
enough quality for inclusion.

the reason i didn't do the (field1 maybe-string "") syntax *i.e. no
parens around maybe-string), is that i couldn't convince the hygienic
macro system about it.

gnu/home/services/desktop.scm | 12 ++---
gnu/services/authentication.scm | 82 ++++++++++++++++----------------
gnu/services/cgit.scm | 12 ++---
gnu/services/configuration.scm | 16 +++----
gnu/services/file-sharing.scm | 24 +++++-----
gnu/services/messaging.scm | 37 +++++++-------
gnu/services/networking.scm | 12 ++---
gnu/services/pm.scm | 54 ++++++++++-----------
gnu/services/telephony.scm | 14 +++---
gnu/services/vpn.scm | 2 +-
tests/services/configuration.scm | 12 +++++
11 files changed, 143 insertions(+), 134 deletions(-)

Toggle diff (442 lines)
diff --git a/gnu/home/services/desktop.scm b/gnu/home/services/desktop.scm
index cbb9cf76da..a54ad0d115 100644
--- a/gnu/home/services/desktop.scm
+++ b/gnu/home/services/desktop.scm
@@ -91,26 +91,26 @@ (define-configuration home-redshift-configuration
"Nighttime color temperature (kelvins).")
(daytime-brightness
- (maybe-inexact-number 'disabled)
+ (maybe-inexact-number)
"Daytime screen brightness, between 0.1 and 1.0.")
(nighttime-brightness
- (maybe-inexact-number 'disabled)
+ (maybe-inexact-number)
"Nighttime screen brightness, between 0.1 and 1.0.")
(latitude
- (maybe-inexact-number 'disabled)
+ (maybe-inexact-number)
"Latitude, when @code{location-provider} is @code{'manual}.")
(longitude
- (maybe-inexact-number 'disabled)
+ (maybe-inexact-number)
"Longitude, when @code{location-provider} is @code{'manual}.")
(dawn-time
- (maybe-string 'disabled)
+ (maybe-string)
"Custom time for the transition from night to day in the
morning---@code{\"HH:MM\"} format. When specified, solar elevation is not
used to determine the daytime/nighttime period.")
(dusk-time
- (maybe-string 'disabled)
+ (maybe-string)
"Likewise, custom time for the transition from day to night in the
evening.")
diff --git a/gnu/services/authentication.scm b/gnu/services/authentication.scm
index cb0ef6d85a..1c4800bfbd 100644
--- a/gnu/services/authentication.scm
+++ b/gnu/services/authentication.scm
@@ -218,7 +218,7 @@ (define-configuration nslcd-configuration
;; Runtime options
(threads
- (maybe-number 'disabled)
+ (maybe-number)
"The number of threads to start that can handle requests and perform LDAP
queries. Each thread opens a separate connection to the LDAP server. The
default is to start 5 threads.")
@@ -243,45 +243,45 @@ (define-configuration nslcd-configuration
"The list of LDAP server URIs. Normally, only the first server will be
used with the following servers as fall-back.")
(ldap-version
- (maybe-string 'disabled)
+ (maybe-string)
"The version of the LDAP protocol to use. The default is to use the
maximum version supported by the LDAP library.")
(binddn
- (maybe-string 'disabled)
+ (maybe-string)
"Specifies the distinguished name with which to bind to the directory
server for lookups. The default is to bind anonymously.")
(bindpw
- (maybe-string 'disabled)
+ (maybe-string)
"Specifies the credentials with which to bind. This option is only
applicable when used with binddn.")
(rootpwmoddn
- (maybe-string 'disabled)
+ (maybe-string)
"Specifies the distinguished name to use when the root user tries to modify
a user's password using the PAM module.")
(rootpwmodpw
- (maybe-string 'disabled)
+ (maybe-string)
"Specifies the credentials with which to bind if the root user tries to
change a user's password. This option is only applicable when used with
rootpwmoddn")
;; SASL authentication options
(sasl-mech
- (maybe-string 'disabled)
+ (maybe-string)
"Specifies the SASL mechanism to be used when performing SASL
authentication.")
(sasl-realm
- (maybe-string 'disabled)
+ (maybe-string)
"Specifies the SASL realm to be used when performing SASL authentication.")
(sasl-authcid
- (maybe-string 'disabled)
+ (maybe-string)
"Specifies the authentication identity to be used when performing SASL
authentication.")
(sasl-authzid
- (maybe-string 'disabled)
+ (maybe-string)
"Specifies the authorization identity to be used when performing SASL
authentication.")
(sasl-canonicalize?
- (maybe-boolean 'disabled)
+ (maybe-boolean)
"Determines whether the LDAP server host name should be canonicalised. If
this is enabled the LDAP library will do a reverse host name lookup. By
default, it is left up to the LDAP library whether this check is performed or
@@ -289,7 +289,7 @@ (define-configuration nslcd-configuration
;; Kerberos authentication options
(krb5-ccname
- (maybe-string 'disabled)
+ (maybe-string)
"Set the name for the GSS-API Kerberos credentials cache.")
;; Search / mapping options
@@ -302,11 +302,11 @@ (define-configuration nslcd-configuration
default scope is subtree; base scope is almost never useful for name service
lookups; children scope is not supported on all servers.")
(deref
- (maybe-deref-option 'disabled)
+ (maybe-deref-option)
"Specifies the policy for dereferencing aliases. The default policy is to
never dereference aliases.")
(referrals
- (maybe-boolean 'disabled)
+ (maybe-boolean)
"Specifies whether automatic referral chasing should be enabled. The
default behaviour is to chase referrals.")
(maps
@@ -322,132 +322,132 @@ (define-configuration nslcd-configuration
;; Timing / reconnect options
(bind-timelimit
- (maybe-number 'disabled)
+ (maybe-number)
"Specifies the time limit in seconds to use when connecting to the
directory server. The default value is 10 seconds.")
(timelimit
- (maybe-number 'disabled)
+ (maybe-number)
"Specifies the time limit (in seconds) to wait for a response from the LDAP
server. A value of zero, which is the default, is to wait indefinitely for
searches to be completed.")
(idle-timelimit
- (maybe-number 'disabled)
+ (maybe-number)
"Specifies the period if inactivity (in seconds) after which the con?
nection to the LDAP server will be closed. The default is not to time out
connections.")
(reconnect-sleeptime
- (maybe-number 'disabled)
+ (maybe-number)
"Specifies the number of seconds to sleep when connecting to all LDAP
servers fails. By default one second is waited between the first failure and
the first retry.")
(reconnect-retrytime
- (maybe-number 'disabled)
+ (maybe-number)
"Specifies the time after which the LDAP server is considered to be
permanently unavailable. Once this time is reached retries will be done only
once per this time period. The default value is 10 seconds.")
;; TLS options
(ssl
- (maybe-ssl-option 'disabled)
+ (maybe-ssl-option)
"Specifies whether to use SSL/TLS or not (the default is not to). If
'start-tls is specified then StartTLS is used rather than raw LDAP over SSL.")
(tls-reqcert
- (maybe-tls-reqcert-option 'disabled)
+ (maybe-tls-reqcert-option)
"Specifies what checks to perform on a server-supplied certificate.
The meaning of the values is described in the ldap.conf(5) manual page.")
(tls-cacertdir
- (maybe-string 'disabled)
+ (maybe-string)
"Specifies the directory containing X.509 certificates for peer authen?
tication. This parameter is ignored when using GnuTLS.")
(tls-cacertfile
- (maybe-string 'disabled)
+ (maybe-string)
"Specifies the path to the X.509 certificate for peer authentication.")
(tls-randfile
- (maybe-string 'disabled)
+ (maybe-string)
"Specifies the path to an entropy source. This parameter is ignored when
using GnuTLS.")
(tls-ciphers
- (maybe-string 'disabled)
+ (maybe-string)
"Specifies the ciphers to use for TLS as a string.")
(tls-cert
- (maybe-string 'disabled)
+ (maybe-string)
"Specifies the path to the file containing the local certificate for client
TLS authentication.")
(tls-key
- (maybe-string 'disabled)
+ (maybe-string)
"Specifies the path to the file containing the private key for client TLS
authentication.")
;; Other options
(pagesize
- (maybe-number 'disabled)
+ (maybe-number)
"Set this to a number greater than 0 to request paged results from the LDAP
server in accordance with RFC2696. The default (0) is to not request paged
results.")
(nss-initgroups-ignoreusers
- (maybe-ignore-users-option 'disabled)
+ (maybe-ignore-users-option)
"This option prevents group membership lookups through LDAP for the
specified users. Alternatively, the value 'all-local may be used. With that
value nslcd builds a full list of non-LDAP users on startup.")
(nss-min-uid
- (maybe-number 'disabled)
+ (maybe-number)
"This option ensures that LDAP users with a numeric user id lower than the
specified value are ignored.")
(nss-uid-offset
- (maybe-number 'disabled)
+ (maybe-number)
"This option specifies an offset that is added to all LDAP numeric user
ids. This can be used to avoid user id collisions with local users.")
(nss-gid-offset
- (maybe-number 'disabled)
+ (maybe-number)
"This option specifies an offset that is added to all LDAP numeric group
ids. This can be used to avoid user id collisions with local groups.")
(nss-nested-groups
- (maybe-boolean 'disabled)
+ (maybe-boolean)
"If this option is set, the member attribute of a group may point to
another group. Members of nested groups are also returned in the higher level
group and parent groups are returned when finding groups for a specific user.
The default is not to perform extra searches for nested groups.")
(nss-getgrent-skipmembers
- (maybe-boolean 'disabled)
+ (maybe-boolean)
"If this option is set, the group member list is not retrieved when looking
up groups. Lookups for finding which groups a user belongs to will remain
functional so the user will likely still get the correct groups assigned on
login.")
(nss-disable-enumeration
- (maybe-boolean 'disabled)
+ (maybe-boolean)
"If this option is set, functions which cause all user/group entries to be
loaded from the directory will not succeed in doing so. This can dramatically
reduce LDAP server load in situations where there are a great number of users
and/or groups. This option is not recommended for most configurations.")
(validnames
- (maybe-string 'disabled)
+ (maybe-string)
"This option can be used to specify how user and group names are verified
within the system. This pattern is used to check all user and group names
that are requested and returned from LDAP.")
(ignorecase
- (maybe-boolean 'disabled)
+ (maybe-boolean)
"This specifies whether or not to perform searches using case-insensitive
matching. Enabling this could open up the system to authorization bypass
vulnerabilities and introduce nscd cache poisoning vulnerabilities which allow
denial of service.")
(pam-authc-ppolicy
- (maybe-boolean 'disabled)
+ (maybe-boolean)
"This option specifies whether password policy controls are requested and
handled from the LDAP server when performing user authentication.")
(pam-authc-search
- (maybe-string 'disabled)
+ (maybe-string)
"By default nslcd performs an LDAP search with the user's credentials after
BIND (authentication) to ensure that the BIND operation was successful. The
default search is a simple check to see if the user's DN exists. A search
filter can be specified that will be used instead. It should return at least
one entry.")
(pam-authz-search
- (maybe-string 'disabled)
+ (maybe-string)
"This option allows flexible fine tuning of the authorisation check that
should be performed. The search filter specified is executed and if any
entries match, access is granted, otherwise access is denied.")
(pam-password-prohibit-message
- (maybe-string 'disabled)
+ (maybe-string)
"If this option is set password modification using pam_ldap will be denied
and the specified message will be presented to the user instead. The message
can be used to direct the user to an alternative means of changing their
diff --git a/gnu/services/cgit.scm b/gnu/services/cgit.scm
index bfc89a40a4..bcb3e1a796 100644
--- a/gnu/services/cgit.scm
+++ b/gnu/services/cgit.scm
@@ -241,27 +241,27 @@ (define-configuration repository-cgit-configuration
(repo-file-object "")
"Override the default @code{email-filter}.")
(enable-commit-graph?
- (maybe-repo-boolean 'disabled)
+ (maybe-repo-boolean)
"A flag which can be used to disable the global setting
@code{enable-commit-graph?}.")
(enable-log-filecount?
- (maybe-repo-boolean 'disabled)
+ (maybe-repo-boolean)
"A flag which can be used to disable the global setting
@code{enable-log-filecount?}.")
(enable-log-linecount?
- (maybe-repo-boolean 'disabled)
+ (maybe-repo-boolean)
"A flag which can be used to disable the global setting
@code{enable-log-linecount?}.")
(enable-remote-branches?
- (maybe-repo-boolean 'disabled)
+ (maybe-repo-boolean)
"Flag which, when set to @code{#t}, will make cgit display remote
branches in the summary and refs views.")
(enable-subject-links?
- (maybe-repo-boolean 'disabled)
+ (maybe-repo-boolean)
"A flag which can be used to override the global setting
@code{enable-subject-links?}.")
(enable-html-serving?
- (maybe-repo-boolean 'disabled)
+ (maybe-repo-boolean)
"A flag which can be used to override the global setting
@code{enable-html-serving?}.")
(hide?
diff --git a/gnu/services/configuration.scm b/gnu/services/configuration.scm
index 0de350a4df..325ef6e0ac 100644
--- a/gnu/services/configuration.scm
+++ b/gnu/services/configuration.scm
@@ -92,7 +92,7 @@ (define (configuration-field-error field val)
(define (configuration-missing-field kind field)
(configuration-error
(format #f "~a configuration missing required field ~a" kind field)))
-(define (configuration-no-default-value kind field)
+(define (configuration-missing-default-value kind field)
(configuration-error
(format #f "The field `~a' of the `~a' configuration record \
does not have a default value" field kind)))
@@ -141,7 +141,8 @@ (define (define-maybe-helper serialize? prefix syn)
(id #'stem #'serialize-maybe- #'stem))))
#`(begin
(define (maybe-stem? val)
- (or (eq? val 'disabled) (stem? val)))
+ (or (unspecified? val)
+ (stem? val)))
#,@(if serialize?
(list #'(define (serialize-maybe-stem field-name val)
(if (stem? val)
@@ -178,9 +179,7 @@ (define (define-configuration-helper serialize? serializer-prefix syn)
((field-type default-value)
default-value)
((field-type)
- ;; Quote `undefined' to prevent a possibly
- ;; unbound warning.
- (syntax 'undefined)))
+ (syntax *unspecified*)))
#'((field-type def ...) ...)))
((field-serializer ...)
(map (lambda (type custom-serializer)
@@ -206,7 +205,7 @@ (define-record-type* #,(id #'stem #'< #'stem #'>)
source-properties->location))
(innate))
#,@(map (lambda (name getter def)
- (if (eq? (syntax->datum def) (quote 'undefined))
+ (if (unspecified? (syntax->datum def))
#`(#,name #,getter)
#`(#,name #,getter (default #,def))))
#'(field ...)
@@ -222,9 +221,8 @@ (define #,(id #'stem #'stem #'-fields)
(default-value-thunk
(lambda ()
(display '#,(id #'stem #'% #'stem))
- (if (eq? (syntax->datum field-default)
- 'undefined)
- (configuration-no-default-value
+ (if (unspecified? (syntax->datum field-default))
+ (configuration-missing-default-value
'#,(id #'stem #'% #'stem) 'field)
field-default)))
(documentation doc))
diff --git a/gnu/services/file-sharing.scm b/gnu/services/file-sharing.scm
index e3d681b08f..6e71fa9154 100644
--- a/gnu/services/file-sharing.scm
+++ b/gnu/services/file-sharing.scm
@@ -115,8 +115,7 @@ (define-maybe string)
(set! serialize-maybe-string
(lambda (field-name val)
(serialize-string field-name
- (if (and (symbol? val)
- (eq? val 'disabled))
+ (if (unspecified? val)
""
val))))
@@ -181,8 +180,7 @@ (define (serialize-file-object field-name val)
(define-maybe file-object)
(set! serialize-maybe-file-object
(lambda (field-name val)
- (if (and (symbol? val)
- (eq? val 'disabled))
+ (if (unspecified? val)
(serialize-string field-name "")
(serialize-file-object field-name val))))
@@ -281,7 +279,7 @@ (define-configuration transmission-daemon-configuration
torrent is complete. Otherwise, files for all torrents (including those still
being downloaded) will be placed in @code{download-dir}.")
(incomplete-dir
- (maybe-string 'disabled)
+ (maybe-string)
"The directory in which files from incompletely downloaded torrents will be
held when @code{incomplete-dir-enabled?} is @code{#t}.")
(umask
@@ -305,7 +303,7 @@ (define-configuration transmission-daemon-configuration
automatically (and the original files removed, if
@code{trash-original-torrent-files?} is @code{#t}).")
(watch-dir
- (maybe-string 'disabled)
+ (maybe-string)
"The directory to be watched for @file{.torrent} files indicating new
torrents to be added, when @code{watch-dir-enabled} is @code{#t}.")
(trash-original-torrent-files?
@@ -401,11 +399,11 @@ (define-configuration transmission-daemon-configuration
@code{prefer-unencrypted-connections}, @code{prefer-encrypted-connections} or
@code{require-encrypted-connections}.")
(peer-congestion-algorithm
- (maybe-string 'disabled)
+ (maybe-string)
"The TCP congestion-control algorithm to use for peer connections,
specified using a string recognized by the operating system in calls to
-@code{setsockopt} (or set to @code{disabled}, in which case the
-operating-system default is used).
+@code{setsockopt} (or leave it unset, in which case the operating-system
+default is used).
Note that on GNU/Linux systems, the kernel must be configured to allow
processes to use a congestion-control algorithm not in the default set;
@@ -465,7 +463,7 @@ (define-configuration transmission-daemon-configuration
"When @code{#t}, the daemon will ignore peers mentioned in the blocklist it
has most
This message was truncated. Download the full message here.
M
M
Maxime Devos wrote on 1 Apr 2022 21:46
e6f7ab11fb77a06c9b5139cd8068734af4d48fab.camel@telenet.be
Attila Lendvai schreef op vr 01-04-2022 om 21:19 [+0200]:
Toggle quote (3 lines)
> ...as a marker for field values that have not been set. Rationale: 'disabled
> may easily [...], is confusing

Exactly, example:

Toggle quote (12 lines)
> --- a/gnu/services/authentication.scm
> +++ b/gnu/services/authentication.scm
> @@ -218,7 +218,7 @@ (define-configuration nslcd-configuration
>  
>    ;; Runtime options
>    (threads
> -   (maybe-number 'disabled)
> +   (maybe-number)
>     "The number of threads to start that can handle requests and perform LDAP
>  queries.  Each thread opens a separate connection to the LDAP server.  The
>  default is to start 5 threads.")

(threads 'disabled) did not actually disable multi-threading.
FWIW, in this particular case, it could be (threads (number 5) ...)
instead (not using 'disabled' or *unspecified*), but that seems
somewhat a separate matter to me.

Greetings,
Maxime.
-----BEGIN PGP SIGNATURE-----

iI0EABYKADUWIQTB8z7iDFKP233XAR9J4+4iGRcl7gUCYkdWnRccbWF4aW1lZGV2
b3NAdGVsZW5ldC5iZQAKCRBJ4+4iGRcl7s00AP42ASOIOhCuGAWIiiVEy3KCOTPz
n5CDAWoME+pAUua/rwD/dNU8/58YsSjx0aleSNOcAMe8Kfl423cogn5THlfqiw8=
=xddh
-----END PGP SIGNATURE-----


M
M
Maxime Devos wrote on 1 Apr 2022 21:56
0be3a60eb95672b6dc5101b966c85f2f3c810224.camel@telenet.be
Attila Lendvai schreef op vr 01-04-2022 om 21:19 [+0200]:
+            (if (unspecified? (syntax->datum def))
         #`(#,name #,getter)
         #`(#,name #,getter (default #,def))))

I'm not sure this does what you want it to do:

(define-syntax foo
(lambda (s)
(syntax-case s ()
((_ bar)
(pk (syntax->datum #'bar) (unspecified? (syntax->datum #'bar)))))))
(foo *unspecified*)
;;; (*unspecified* #f)

The problem is that, from the macro systems POV, *unspecified* is just
a variable reference to the global *unspecified* --- *unspecified*
isn't magic to the reader, the reader just interprets it as a symbol.

Suggestion:

(define-syntax foo2
(lambda (s)
(syntax-case s ()
((_ bar)
(pk (syntax->datum #'bar)
(and (identifier? #'bar)
(free-identifier=? #'*unspecified* #'bar)))))))
(foo2 *unspecified*)
;;; (*unspecified* #t)

Greetings,
Maxime.
-----BEGIN PGP SIGNATURE-----

iI0EABYKADUWIQTB8z7iDFKP233XAR9J4+4iGRcl7gUCYkdZChccbWF4aW1lZGV2
b3NAdGVsZW5ldC5iZQAKCRBJ4+4iGRcl7jpoAQCp1WOmWX1IIoj6rGCArnUDXe3Z
1OiZRD5BL4ZPBJluSwEAo907Qp37c+mZn6Rs7BzHLkhNu3UjJYC+VfFAyBz2nQg=
=Kajf
-----END PGP SIGNATURE-----


M
M
Maxime Devos wrote on 1 Apr 2022 21:58
2f39bf8cd56b3019026e43532b2f7b937de99b7e.camel@telenet.be
Attila Lendvai schreef op vr 01-04-2022 om 21:19 [+0200]:
Toggle quote (4 lines)
> the reason i didn't do the (field1 maybe-string "") syntax *i.e. no
> parens around maybe-string), is that i couldn't convince the hygienic
> macro system about it.

Do you have some non-working code? Maybe I can make it work ...

Greetings,
Maxime.
-----BEGIN PGP SIGNATURE-----

iI0EABYKADUWIQTB8z7iDFKP233XAR9J4+4iGRcl7gUCYkdZbhccbWF4aW1lZGV2
b3NAdGVsZW5ldC5iZQAKCRBJ4+4iGRcl7qQZAP9aNuXzu2epA5qurspUl3EZMilp
aCqXbGReM9qNIqR+LQEAlzCsmYkFuCHQENgX/yw3+GSAyuCszvPLuZs1g9fLgQE=
=TZnz
-----END PGP SIGNATURE-----


A
A
Attila Lendvai wrote on 4 Apr 2022 09:46
(name . Maxime Devos)(address . maximedevos@telenet.be)(address . 54674@debbugs.gnu.org)
RyjP_EnJExOZtmPhVCyaItCm7UL0vmEX6dksmALrBGXALN_VruCqiFyWM0MqmBflw_zwb1ZJ97WO4SjbAY_Hn97vgotOpY3bwntDDxkAov0=@lendvai.name
Toggle quote (6 lines)
> > the reason i didn't do the (field1 maybe-string "") syntax *i.e. no
> > parens around maybe-string), is that i couldn't convince the hygienic
> > macro system about it.
>
> Do you have some non-working code? Maybe I can make it work ...

thank you for your kind offer Maxime! i have attached a half-baked patch.

it should also resolve your other nice catch of my mistaken use of UNSPECIFIED? on syntax objects.

in this change i try to introduce a codepath for a canonical form for DEFINE-CONFIGURATION fields, but it won't work this way, because this way the SYNTAX-CASE forms will only match when *every* field is of the specified shape.

the solution is probably in the direction of introducing a new DEFINE-CONFIGURATION-HELPER/FIELD somehow, but hygienic macros are a rather new territory for me...

as for the (threads (number 5)) change: i'd rather not do it in this commit to try to keep it as much idempotent wrt behavior as possible.

--
• attila lendvai
• PGP: 963F 5D5F 45C7 DFCD 0A39
--
“The important thing is to not stop questioning. Curiosity has its own reason for existing.”
— Albert Einstein (1879–1955)
Toggle diff (78 lines)
diff --git a/gnu/services/configuration.scm b/gnu/services/configuration.scm
index 325ef6e0ac..28dc314301 100644
--- a/gnu/services/configuration.scm
+++ b/gnu/services/configuration.scm
@@ -165,7 +165,7 @@ (define-maybe stem (no-serialization)))
(define (define-configuration-helper serialize? serializer-prefix syn)
(syntax-case syn ()
- ((_ stem (field (field-type def ...) doc custom-serializer ...) ...)
+ ((_ stem (field (field-type def) doc custom-serializer ...) ...)
(with-syntax (((field-getter ...)
(map (lambda (field)
(id #'stem #'stem #'- field))
@@ -205,9 +205,7 @@ (define-record-type* #,(id #'stem #'< #'stem #'>)
source-properties->location))
(innate))
#,@(map (lambda (name getter def)
- (if (unspecified? (syntax->datum def))
- #`(#,name #,getter)
- #`(#,name #,getter (default #,def))))
+ #`(#,name #,getter (default #,def)))
#'(field ...)
#'(field-getter ...)
#'(field-default ...)))
@@ -231,7 +229,13 @@ (define-syntax-rule (stem arg (... ...))
(let ((conf (#,(id #'stem #'% #'stem) arg (... ...))))
(validate-configuration conf
#,(id #'stem #'stem #'-fields))
- conf)))))))
+ conf)))))
+ ;; TODO This does not work, because it matches when *every* field is of
+ ;; this form.
+ ((_ stem (field (field-type) doc custom-serializer ...) ...)
+ (stem (field (field-type *unspecified*) doc custom-serializer ...) ...))
+ ((_ stem (field field-type doc custom-serializer ...) ...)
+ (stem (field (field-type *unspecified*) doc custom-serializer ...) ...))))
(define no-serialization ;syntactic keyword for 'define-configuration'
'(no serialization))
@@ -239,27 +243,19 @@ (define no-serialization ;syntactic keyword for 'define-configuration'
(define-syntax define-configuration
(lambda (s)
(syntax-case s (no-serialization prefix)
- ((_ stem (field (field-type def ...) doc custom-serializer ...) ...
- (no-serialization))
- (define-configuration-helper
- #f #f #'(_ stem (field (field-type def ...) doc custom-serializer ...)
- ...)))
- ((_ stem (field (field-type def ...) doc custom-serializer ...) ...
- (prefix serializer-prefix))
- (define-configuration-helper
- #t #'serializer-prefix #'(_ stem (field (field-type def ...)
- doc custom-serializer ...)
- ...)))
- ((_ stem (field (field-type def ...) doc custom-serializer ...) ...)
- (define-configuration-helper
- #t #f #'(_ stem (field (field-type def ...) doc custom-serializer ...)
- ...))))))
+ ((_ stem fields ... (no-serialization))
+ (define-configuration-helper #f #f
+ #'(_ stem fields ...)))
+ ((_ stem fields ... (prefix serializer-prefix))
+ (define-configuration-helper #t #'serializer-prefix
+ #'(_ stem fields ...)))
+ ((_ stem fields ...)
+ (define-configuration-helper #t #f
+ #'(_ stem fields ...))))))
(define-syntax-rule (define-configuration/no-serialization
- stem (field (field-type def ...)
- doc custom-serializer ...) ...)
- (define-configuration stem (field (field-type def ...)
- doc custom-serializer ...) ...
+ stem (field type-and-def doc custom-serializer ...) ...)
+ (define-configuration stem (field type-and-def doc custom-serializer ...) ...
(no-serialization)))
(define (empty-serializer field-name val) "")
M
M
Maxime Devos wrote on 4 Apr 2022 13:25
(name . Attila Lendvai)(address . attila@lendvai.name)(address . 54674@debbugs.gnu.org)
bcaab1bbb79a6cd3d4503f5f57f4ef7eb20cb52f.camel@telenet.be
Attila Lendvai schreef op ma 04-04-2022 om 07:46 [+0000]:
Toggle quote (5 lines)
> in this change i try to introduce a codepath for a canonical form for
> DEFINE-CONFIGURATION fields, but it won't work this way, because this
> way the SYNTAX-CASE forms will only match when *every* field is of
> the specified shape.

See attachement for poposed solution. (Not done: *unspecified* instead
of the symbol 'disabled' as default).

Greetings,
Maxime.
Toggle diff (78 lines)
diff --git a/gnu/services/configuration.scm b/gnu/services/configuration.scm
index 0de350a4df..06bb73c9fa 100644
--- a/gnu/services/configuration.scm
+++ b/gnu/services/configuration.scm
@@ -5,6 +5,7 @@
;;; Copyright © 2021 Xinglu Chen <public@yoctocell.xyz>
;;; Copyright © 2021 Maxim Cournoyer <maxim.cournoyer@gmail.com>
;;; Copyright © 2021 Andrew Tropin <andrew@trop.in>
+;;; Copyright © 2022 Maxime Devos <maximedevos@telenet.be>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -162,9 +163,21 @@ does not have a default value" field kind)))
(define-syntax-rule (define-maybe/no-serialization stem)
(define-maybe stem (no-serialization)))
+(define (analyse-field-type+def s)
+ (syntax-case s ()
+ ((field-type def ...)
+ (identifier? #'field-type)
+ (values #'(field-type def ...)))
+ (field-type
+ (identifier? #'field-type)
+ (values #'(field-type)))))
+
(define (define-configuration-helper serialize? serializer-prefix syn)
(syntax-case syn ()
- ((_ stem (field (field-type def ...) doc custom-serializer ...) ...)
+ ((_ stem (field field-type+def doc custom-serializer ...) ...)
+ ;; TODO: fix indentation, maybe with-syntax*?
+ (with-syntax ((((field-type def ...) ...)
+ (map analyse-field-type+def #'(field-type+def ...))))
(with-syntax (((field-getter ...)
(map (lambda (field)
(id #'stem #'stem #'- field))
@@ -233,7 +246,7 @@ does not have a default value" field kind)))
(let ((conf (#,(id #'stem #'% #'stem) arg (... ...))))
(validate-configuration conf
#,(id #'stem #'stem #'-fields))
- conf)))))))
+ conf))))))))
(define no-serialization ;syntactic keyword for 'define-configuration'
'(no serialization))
@@ -241,26 +254,26 @@ does not have a default value" field kind)))
(define-syntax define-configuration
(lambda (s)
(syntax-case s (no-serialization prefix)
- ((_ stem (field (field-type def ...) doc custom-serializer ...) ...
+ ((_ stem (field field-type+def doc custom-serializer ...) ...
(no-serialization))
(define-configuration-helper
- #f #f #'(_ stem (field (field-type def ...) doc custom-serializer ...)
+ #f #f #'(_ stem (field field-type+def doc custom-serializer ...)
...)))
- ((_ stem (field (field-type def ...) doc custom-serializer ...) ...
+ ((_ stem (field field-type+def doc custom-serializer ...) ...
(prefix serializer-prefix))
(define-configuration-helper
- #t #'serializer-prefix #'(_ stem (field (field-type def ...)
+ #t #'serializer-prefix #'(_ stem (field field-type+def
doc custom-serializer ...)
...)))
- ((_ stem (field (field-type def ...) doc custom-serializer ...) ...)
+ ((_ stem (field field-type+def doc custom-serializer ...) ...)
(define-configuration-helper
- #t #f #'(_ stem (field (field-type def ...) doc custom-serializer ...)
+ #t #f #'(_ stem (field field-type+def doc custom-serializer ...)
...))))))
(define-syntax-rule (define-configuration/no-serialization
- stem (field (field-type def ...)
+ stem (field field-type+def
doc custom-serializer ...) ...)
- (define-configuration stem (field (field-type def ...)
+ (define-configuration stem (field field-type+def
doc custom-serializer ...) ...
(no-serialization)))
-----BEGIN PGP SIGNATURE-----

iI0EABYKADUWIQTB8z7iDFKP233XAR9J4+4iGRcl7gUCYkrVlxccbWF4aW1lZGV2
b3NAdGVsZW5ldC5iZQAKCRBJ4+4iGRcl7taNAP0UtsD5oguueo+SRMddpyGU4qm/
Z2b6ndulZ73sbgQp0QD+MSUW2i0wzuxe11cxgt+UZCns7yyJiVymo63YOXP/Agg=
=eSmH
-----END PGP SIGNATURE-----


A
A
Attila Lendvai wrote on 7 Apr 2022 15:52
[PATCH v2 1/2] services: configuration: Support (field1 maybe-number "") format.
(address . 54674@debbugs.gnu.org)(name . Attila Lendvai)(address . attila@lendvai.name)
20220407135213.17193-1-attila@lendvai.name
As opposed to explicitly using 'disabled as value, or using the
(field1 (maybe-number) "") format.

It's mostly the work of Maxime Devos <maximedevos@telenet.be>, with some
modifications by me.

* gnu/services/configuration.scm (normalize-field-type+def): New function.
(define-configuration-helper) (define-configuration): Support new field
format.
* tests/services/configuration.scm (config-with-maybe-number->string): New
function.
("maybe value serialization of the instance"): New test.
("maybe value serialization of the instance, unspecified"): New test.
---
gnu/services/configuration.scm | 169 +++++++++++++++++--------------
tests/services/configuration.scm | 28 ++++-
2 files changed, 114 insertions(+), 83 deletions(-)

Toggle diff (268 lines)
diff --git a/gnu/services/configuration.scm b/gnu/services/configuration.scm
index 0de350a4df..bdca33ed68 100644
--- a/gnu/services/configuration.scm
+++ b/gnu/services/configuration.scm
@@ -5,6 +5,7 @@
;;; Copyright © 2021 Xinglu Chen <public@yoctocell.xyz>
;;; Copyright © 2021 Maxim Cournoyer <maxim.cournoyer@gmail.com>
;;; Copyright © 2021 Andrew Tropin <andrew@trop.in>
+;;; Copyright © 2022 Maxime Devos <maximedevos@telenet.be>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -162,78 +163,90 @@ (define-maybe-helper #t #f #'(_ stem))))))
(define-syntax-rule (define-maybe/no-serialization stem)
(define-maybe stem (no-serialization)))
+(define (normalize-field-type+def s)
+ (syntax-case s ()
+ ((field-type def)
+ (identifier? #'field-type)
+ (values #'(field-type def)))
+ ((field-type)
+ (identifier? #'field-type)
+ (values #'(field-type 'disabled)))
+ (field-type
+ (identifier? #'field-type)
+ (values #'(field-type 'disabled)))))
+
(define (define-configuration-helper serialize? serializer-prefix syn)
(syntax-case syn ()
- ((_ stem (field (field-type def ...) doc custom-serializer ...) ...)
- (with-syntax (((field-getter ...)
- (map (lambda (field)
- (id #'stem #'stem #'- field))
- #'(field ...)))
- ((field-predicate ...)
- (map (lambda (type)
- (id #'stem type #'?))
- #'(field-type ...)))
- ((field-default ...)
- (map (match-lambda
- ((field-type default-value)
- default-value)
- ((field-type)
- ;; Quote `undefined' to prevent a possibly
- ;; unbound warning.
- (syntax 'undefined)))
- #'((field-type def ...) ...)))
- ((field-serializer ...)
- (map (lambda (type custom-serializer)
- (and serialize?
- (match custom-serializer
- ((serializer)
- serializer)
- (()
- (if serializer-prefix
- (id #'stem
- serializer-prefix
- #'serialize- type)
- (id #'stem #'serialize- type))))))
- #'(field-type ...)
- #'((custom-serializer ...) ...))))
- #`(begin
- (define-record-type* #,(id #'stem #'< #'stem #'>)
- #,(id #'stem #'% #'stem)
- #,(id #'stem #'make- #'stem)
- #,(id #'stem #'stem #'?)
- (%location #,(id #'stem #'stem #'-location)
- (default (and=> (current-source-location)
- source-properties->location))
- (innate))
- #,@(map (lambda (name getter def)
- (if (eq? (syntax->datum def) (quote 'undefined))
- #`(#,name #,getter)
- #`(#,name #,getter (default #,def))))
- #'(field ...)
- #'(field-getter ...)
- #'(field-default ...)))
- (define #,(id #'stem #'stem #'-fields)
- (list (configuration-field
- (name 'field)
- (type 'field-type)
- (getter field-getter)
- (predicate field-predicate)
- (serializer field-serializer)
- (default-value-thunk
- (lambda ()
- (display '#,(id #'stem #'% #'stem))
- (if (eq? (syntax->datum field-default)
- 'undefined)
- (configuration-no-default-value
- '#,(id #'stem #'% #'stem) 'field)
- field-default)))
- (documentation doc))
- ...))
- (define-syntax-rule (stem arg (... ...))
- (let ((conf (#,(id #'stem #'% #'stem) arg (... ...))))
- (validate-configuration conf
- #,(id #'stem #'stem #'-fields))
- conf)))))))
+ ((_ stem (field field-type+def doc custom-serializer ...) ...)
+ (with-syntax
+ ((((field-type def) ...)
+ (map normalize-field-type+def #'(field-type+def ...))))
+ (with-syntax
+ (((field-getter ...)
+ (map (lambda (field)
+ (id #'stem #'stem #'- field))
+ #'(field ...)))
+ ((field-predicate ...)
+ (map (lambda (type)
+ (id #'stem type #'?))
+ #'(field-type ...)))
+ ((field-default ...)
+ (map (match-lambda
+ ((field-type default-value)
+ default-value))
+ #'((field-type def) ...)))
+ ((field-serializer ...)
+ (map (lambda (type custom-serializer)
+ (and serialize?
+ (match custom-serializer
+ ((serializer)
+ serializer)
+ (()
+ (if serializer-prefix
+ (id #'stem
+ serializer-prefix
+ #'serialize- type)
+ (id #'stem #'serialize- type))))))
+ #'(field-type ...)
+ #'((custom-serializer ...) ...))))
+ #`(begin
+ (define-record-type* #,(id #'stem #'< #'stem #'>)
+ #,(id #'stem #'% #'stem)
+ #,(id #'stem #'make- #'stem)
+ #,(id #'stem #'stem #'?)
+ (%location #,(id #'stem #'stem #'-location)
+ (default (and=> (current-source-location)
+ source-properties->location))
+ (innate))
+ #,@(map (lambda (name getter def)
+ (if (eq? (syntax->datum def) (quote 'undefined))
+ #`(#,name #,getter)
+ #`(#,name #,getter (default #,def))))
+ #'(field ...)
+ #'(field-getter ...)
+ #'(field-default ...)))
+ (define #,(id #'stem #'stem #'-fields)
+ (list (configuration-field
+ (name 'field)
+ (type 'field-type)
+ (getter field-getter)
+ (predicate field-predicate)
+ (serializer field-serializer)
+ (default-value-thunk
+ (lambda ()
+ (display '#,(id #'stem #'% #'stem))
+ (if (eq? (syntax->datum field-default)
+ 'undefined)
+ (configuration-no-default-value
+ '#,(id #'stem #'% #'stem) 'field)
+ field-default)))
+ (documentation doc))
+ ...))
+ (define-syntax-rule (stem arg (... ...))
+ (let ((conf (#,(id #'stem #'% #'stem) arg (... ...))))
+ (validate-configuration conf
+ #,(id #'stem #'stem #'-fields))
+ conf))))))))
(define no-serialization ;syntactic keyword for 'define-configuration'
'(no serialization))
@@ -241,26 +254,26 @@ (define no-serialization ;syntactic keyword for 'define-configuration'
(define-syntax define-configuration
(lambda (s)
(syntax-case s (no-serialization prefix)
- ((_ stem (field (field-type def ...) doc custom-serializer ...) ...
+ ((_ stem (field field-type+def doc custom-serializer ...) ...
(no-serialization))
(define-configuration-helper
- #f #f #'(_ stem (field (field-type def ...) doc custom-serializer ...)
+ #f #f #'(_ stem (field field-type+def doc custom-serializer ...)
...)))
- ((_ stem (field (field-type def ...) doc custom-serializer ...) ...
+ ((_ stem (field field-type+def doc custom-serializer ...) ...
(prefix serializer-prefix))
(define-configuration-helper
- #t #'serializer-prefix #'(_ stem (field (field-type def ...)
+ #t #'serializer-prefix #'(_ stem (field field-type+def
doc custom-serializer ...)
...)))
- ((_ stem (field (field-type def ...) doc custom-serializer ...) ...)
+ ((_ stem (field field-type+def doc custom-serializer ...) ...)
(define-configuration-helper
- #t #f #'(_ stem (field (field-type def ...) doc custom-serializer ...)
+ #t #f #'(_ stem (field field-type+def doc custom-serializer ...)
...))))))
(define-syntax-rule (define-configuration/no-serialization
- stem (field (field-type def ...)
+ stem (field field-type+def
doc custom-serializer ...) ...)
- (define-configuration stem (field (field-type def ...)
+ (define-configuration stem (field field-type+def
doc custom-serializer ...) ...
(no-serialization)))
diff --git a/tests/services/configuration.scm b/tests/services/configuration.scm
index 86a36a388d..0debf8095b 100644
--- a/tests/services/configuration.scm
+++ b/tests/services/configuration.scm
@@ -27,6 +27,9 @@ (define-module (tests services configuration)
(test-begin "services-configuration")
+(define (serialize-number field value)
+ (format #f "~a=~a" field value))
+
;;;
;;; define-configuration macro.
@@ -47,7 +50,6 @@ (define-configuration port-configuration-cs
80
(port-configuration-cs-port (port-configuration-cs)))
-(define serialize-number "")
(define-configuration port-configuration-ndv
(port (number) "The port number."))
@@ -101,15 +103,31 @@ (define-configuration configuration-with-prefix
(define-maybe number)
(define-configuration config-with-maybe-number
- (port (maybe-number 80) "The port number."))
-
-(define (serialize-number field value)
- (format #f "~a=~a" field value))
+ (port (maybe-number 80) "")
+ (count maybe-number ""))
(test-equal "maybe value serialization"
"port=80"
(serialize-maybe-number "port" 80))
+(define (config-with-maybe-number->string x)
+ (eval (gexp->approximate-sexp
+ (serialize-configuration x config-with-maybe-number-fields))
+ (current-module)))
+
+(test-equal "maybe value serialization of the instance"
+ "port=42count=43"
+ (config-with-maybe-number->string
+ (config-with-maybe-number
+ (port 42)
+ (count 43))))
+
+(test-equal "maybe value serialization of the instance, unspecified"
+ "port=42"
+ (config-with-maybe-number->string
+ (config-with-maybe-number
+ (port 42))))
+
(define-maybe/no-serialization string)
(define-configuration config-with-maybe-string/no-serialization
--
2.34.0
A
A
Attila Lendvai wrote on 7 Apr 2022 15:52
[PATCH v2 2/2] services: configuration: Use *unspecified* instead of 'disabled.
(address . 54674@debbugs.gnu.org)(name . Attila Lendvai)(address . attila@lendvai.name)
20220407135213.17193-2-attila@lendvai.name
...as a marker for field values that have not been set. Rationale: 'disabled
may easily clash with user values for boolean fields, is confusing (i.e. its
meaning is *not* boolean false, bug unspecified) and it also passes through
silently the symbol? predicate of a field of type symbol.

Relax the syntax to accept (field1 (maybe-string) "") forms, in which case it
uses *unspecified* as default value.

Possible future improvement: also accept (field1 maybe-string "") forms,
i.e. without the extra parens around maybe types without defaults.

* gnu/services/configuration.scm (configuration-missing-default-value):
Renamed from configuration-no-default-value.
* gnu/services/configuration.scm (define-maybe-helper): Use *unspecified*
instead of 'disabled, and make the default value optional.
---

i haven't tested every service that got touched by this change. consider
it as a slightly tested proposal, that may very well end up being useful
as it is.

i have my service code on my server running on top of this, though. it
exercises serialization, and some nontrivial defaulting and
instantiations.

gnu/home/services/desktop.scm | 12 ++---
gnu/services/authentication.scm | 82 ++++++++++++++++----------------
gnu/services/cgit.scm | 12 ++---
gnu/services/configuration.scm | 17 ++++---
gnu/services/file-sharing.scm | 24 +++++-----
gnu/services/messaging.scm | 37 +++++++-------
gnu/services/networking.scm | 12 ++---
gnu/services/pm.scm | 54 ++++++++++-----------
gnu/services/telephony.scm | 14 +++---
gnu/services/vpn.scm | 2 +-
tests/services/configuration.scm | 12 +++++
11 files changed, 144 insertions(+), 134 deletions(-)

Toggle diff (443 lines)
diff --git a/gnu/home/services/desktop.scm b/gnu/home/services/desktop.scm
index cbb9cf76da..a54ad0d115 100644
--- a/gnu/home/services/desktop.scm
+++ b/gnu/home/services/desktop.scm
@@ -91,26 +91,26 @@ (define-configuration home-redshift-configuration
"Nighttime color temperature (kelvins).")
(daytime-brightness
- (maybe-inexact-number 'disabled)
+ (maybe-inexact-number)
"Daytime screen brightness, between 0.1 and 1.0.")
(nighttime-brightness
- (maybe-inexact-number 'disabled)
+ (maybe-inexact-number)
"Nighttime screen brightness, between 0.1 and 1.0.")
(latitude
- (maybe-inexact-number 'disabled)
+ (maybe-inexact-number)
"Latitude, when @code{location-provider} is @code{'manual}.")
(longitude
- (maybe-inexact-number 'disabled)
+ (maybe-inexact-number)
"Longitude, when @code{location-provider} is @code{'manual}.")
(dawn-time
- (maybe-string 'disabled)
+ (maybe-string)
"Custom time for the transition from night to day in the
morning---@code{\"HH:MM\"} format. When specified, solar elevation is not
used to determine the daytime/nighttime period.")
(dusk-time
- (maybe-string 'disabled)
+ (maybe-string)
"Likewise, custom time for the transition from day to night in the
evening.")
diff --git a/gnu/services/authentication.scm b/gnu/services/authentication.scm
index cb0ef6d85a..1c4800bfbd 100644
--- a/gnu/services/authentication.scm
+++ b/gnu/services/authentication.scm
@@ -218,7 +218,7 @@ (define-configuration nslcd-configuration
;; Runtime options
(threads
- (maybe-number 'disabled)
+ (maybe-number)
"The number of threads to start that can handle requests and perform LDAP
queries. Each thread opens a separate connection to the LDAP server. The
default is to start 5 threads.")
@@ -243,45 +243,45 @@ (define-configuration nslcd-configuration
"The list of LDAP server URIs. Normally, only the first server will be
used with the following servers as fall-back.")
(ldap-version
- (maybe-string 'disabled)
+ (maybe-string)
"The version of the LDAP protocol to use. The default is to use the
maximum version supported by the LDAP library.")
(binddn
- (maybe-string 'disabled)
+ (maybe-string)
"Specifies the distinguished name with which to bind to the directory
server for lookups. The default is to bind anonymously.")
(bindpw
- (maybe-string 'disabled)
+ (maybe-string)
"Specifies the credentials with which to bind. This option is only
applicable when used with binddn.")
(rootpwmoddn
- (maybe-string 'disabled)
+ (maybe-string)
"Specifies the distinguished name to use when the root user tries to modify
a user's password using the PAM module.")
(rootpwmodpw
- (maybe-string 'disabled)
+ (maybe-string)
"Specifies the credentials with which to bind if the root user tries to
change a user's password. This option is only applicable when used with
rootpwmoddn")
;; SASL authentication options
(sasl-mech
- (maybe-string 'disabled)
+ (maybe-string)
"Specifies the SASL mechanism to be used when performing SASL
authentication.")
(sasl-realm
- (maybe-string 'disabled)
+ (maybe-string)
"Specifies the SASL realm to be used when performing SASL authentication.")
(sasl-authcid
- (maybe-string 'disabled)
+ (maybe-string)
"Specifies the authentication identity to be used when performing SASL
authentication.")
(sasl-authzid
- (maybe-string 'disabled)
+ (maybe-string)
"Specifies the authorization identity to be used when performing SASL
authentication.")
(sasl-canonicalize?
- (maybe-boolean 'disabled)
+ (maybe-boolean)
"Determines whether the LDAP server host name should be canonicalised. If
this is enabled the LDAP library will do a reverse host name lookup. By
default, it is left up to the LDAP library whether this check is performed or
@@ -289,7 +289,7 @@ (define-configuration nslcd-configuration
;; Kerberos authentication options
(krb5-ccname
- (maybe-string 'disabled)
+ (maybe-string)
"Set the name for the GSS-API Kerberos credentials cache.")
;; Search / mapping options
@@ -302,11 +302,11 @@ (define-configuration nslcd-configuration
default scope is subtree; base scope is almost never useful for name service
lookups; children scope is not supported on all servers.")
(deref
- (maybe-deref-option 'disabled)
+ (maybe-deref-option)
"Specifies the policy for dereferencing aliases. The default policy is to
never dereference aliases.")
(referrals
- (maybe-boolean 'disabled)
+ (maybe-boolean)
"Specifies whether automatic referral chasing should be enabled. The
default behaviour is to chase referrals.")
(maps
@@ -322,132 +322,132 @@ (define-configuration nslcd-configuration
;; Timing / reconnect options
(bind-timelimit
- (maybe-number 'disabled)
+ (maybe-number)
"Specifies the time limit in seconds to use when connecting to the
directory server. The default value is 10 seconds.")
(timelimit
- (maybe-number 'disabled)
+ (maybe-number)
"Specifies the time limit (in seconds) to wait for a response from the LDAP
server. A value of zero, which is the default, is to wait indefinitely for
searches to be completed.")
(idle-timelimit
- (maybe-number 'disabled)
+ (maybe-number)
"Specifies the period if inactivity (in seconds) after which the con?
nection to the LDAP server will be closed. The default is not to time out
connections.")
(reconnect-sleeptime
- (maybe-number 'disabled)
+ (maybe-number)
"Specifies the number of seconds to sleep when connecting to all LDAP
servers fails. By default one second is waited between the first failure and
the first retry.")
(reconnect-retrytime
- (maybe-number 'disabled)
+ (maybe-number)
"Specifies the time after which the LDAP server is considered to be
permanently unavailable. Once this time is reached retries will be done only
once per this time period. The default value is 10 seconds.")
;; TLS options
(ssl
- (maybe-ssl-option 'disabled)
+ (maybe-ssl-option)
"Specifies whether to use SSL/TLS or not (the default is not to). If
'start-tls is specified then StartTLS is used rather than raw LDAP over SSL.")
(tls-reqcert
- (maybe-tls-reqcert-option 'disabled)
+ (maybe-tls-reqcert-option)
"Specifies what checks to perform on a server-supplied certificate.
The meaning of the values is described in the ldap.conf(5) manual page.")
(tls-cacertdir
- (maybe-string 'disabled)
+ (maybe-string)
"Specifies the directory containing X.509 certificates for peer authen?
tication. This parameter is ignored when using GnuTLS.")
(tls-cacertfile
- (maybe-string 'disabled)
+ (maybe-string)
"Specifies the path to the X.509 certificate for peer authentication.")
(tls-randfile
- (maybe-string 'disabled)
+ (maybe-string)
"Specifies the path to an entropy source. This parameter is ignored when
using GnuTLS.")
(tls-ciphers
- (maybe-string 'disabled)
+ (maybe-string)
"Specifies the ciphers to use for TLS as a string.")
(tls-cert
- (maybe-string 'disabled)
+ (maybe-string)
"Specifies the path to the file containing the local certificate for client
TLS authentication.")
(tls-key
- (maybe-string 'disabled)
+ (maybe-string)
"Specifies the path to the file containing the private key for client TLS
authentication.")
;; Other options
(pagesize
- (maybe-number 'disabled)
+ (maybe-number)
"Set this to a number greater than 0 to request paged results from the LDAP
server in accordance with RFC2696. The default (0) is to not request paged
results.")
(nss-initgroups-ignoreusers
- (maybe-ignore-users-option 'disabled)
+ (maybe-ignore-users-option)
"This option prevents group membership lookups through LDAP for the
specified users. Alternatively, the value 'all-local may be used. With that
value nslcd builds a full list of non-LDAP users on startup.")
(nss-min-uid
- (maybe-number 'disabled)
+ (maybe-number)
"This option ensures that LDAP users with a numeric user id lower than the
specified value are ignored.")
(nss-uid-offset
- (maybe-number 'disabled)
+ (maybe-number)
"This option specifies an offset that is added to all LDAP numeric user
ids. This can be used to avoid user id collisions with local users.")
(nss-gid-offset
- (maybe-number 'disabled)
+ (maybe-number)
"This option specifies an offset that is added to all LDAP numeric group
ids. This can be used to avoid user id collisions with local groups.")
(nss-nested-groups
- (maybe-boolean 'disabled)
+ (maybe-boolean)
"If this option is set, the member attribute of a group may point to
another group. Members of nested groups are also returned in the higher level
group and parent groups are returned when finding groups for a specific user.
The default is not to perform extra searches for nested groups.")
(nss-getgrent-skipmembers
- (maybe-boolean 'disabled)
+ (maybe-boolean)
"If this option is set, the group member list is not retrieved when looking
up groups. Lookups for finding which groups a user belongs to will remain
functional so the user will likely still get the correct groups assigned on
login.")
(nss-disable-enumeration
- (maybe-boolean 'disabled)
+ (maybe-boolean)
"If this option is set, functions which cause all user/group entries to be
loaded from the directory will not succeed in doing so. This can dramatically
reduce LDAP server load in situations where there are a great number of users
and/or groups. This option is not recommended for most configurations.")
(validnames
- (maybe-string 'disabled)
+ (maybe-string)
"This option can be used to specify how user and group names are verified
within the system. This pattern is used to check all user and group names
that are requested and returned from LDAP.")
(ignorecase
- (maybe-boolean 'disabled)
+ (maybe-boolean)
"This specifies whether or not to perform searches using case-insensitive
matching. Enabling this could open up the system to authorization bypass
vulnerabilities and introduce nscd cache poisoning vulnerabilities which allow
denial of service.")
(pam-authc-ppolicy
- (maybe-boolean 'disabled)
+ (maybe-boolean)
"This option specifies whether password policy controls are requested and
handled from the LDAP server when performing user authentication.")
(pam-authc-search
- (maybe-string 'disabled)
+ (maybe-string)
"By default nslcd performs an LDAP search with the user's credentials after
BIND (authentication) to ensure that the BIND operation was successful. The
default search is a simple check to see if the user's DN exists. A search
filter can be specified that will be used instead. It should return at least
one entry.")
(pam-authz-search
- (maybe-string 'disabled)
+ (maybe-string)
"This option allows flexible fine tuning of the authorisation check that
should be performed. The search filter specified is executed and if any
entries match, access is granted, otherwise access is denied.")
(pam-password-prohibit-message
- (maybe-string 'disabled)
+ (maybe-string)
"If this option is set password modification using pam_ldap will be denied
and the specified message will be presented to the user instead. The message
can be used to direct the user to an alternative means of changing their
diff --git a/gnu/services/cgit.scm b/gnu/services/cgit.scm
index bfc89a40a4..bcb3e1a796 100644
--- a/gnu/services/cgit.scm
+++ b/gnu/services/cgit.scm
@@ -241,27 +241,27 @@ (define-configuration repository-cgit-configuration
(repo-file-object "")
"Override the default @code{email-filter}.")
(enable-commit-graph?
- (maybe-repo-boolean 'disabled)
+ (maybe-repo-boolean)
"A flag which can be used to disable the global setting
@code{enable-commit-graph?}.")
(enable-log-filecount?
- (maybe-repo-boolean 'disabled)
+ (maybe-repo-boolean)
"A flag which can be used to disable the global setting
@code{enable-log-filecount?}.")
(enable-log-linecount?
- (maybe-repo-boolean 'disabled)
+ (maybe-repo-boolean)
"A flag which can be used to disable the global setting
@code{enable-log-linecount?}.")
(enable-remote-branches?
- (maybe-repo-boolean 'disabled)
+ (maybe-repo-boolean)
"Flag which, when set to @code{#t}, will make cgit display remote
branches in the summary and refs views.")
(enable-subject-links?
- (maybe-repo-boolean 'disabled)
+ (maybe-repo-boolean)
"A flag which can be used to override the global setting
@code{enable-subject-links?}.")
(enable-html-serving?
- (maybe-repo-boolean 'disabled)
+ (maybe-repo-boolean)
"A flag which can be used to override the global setting
@code{enable-html-serving?}.")
(hide?
diff --git a/gnu/services/configuration.scm b/gnu/services/configuration.scm
index bdca33ed68..f6b20fb82b 100644
--- a/gnu/services/configuration.scm
+++ b/gnu/services/configuration.scm
@@ -93,7 +93,7 @@ (define (configuration-field-error field val)
(define (configuration-missing-field kind field)
(configuration-error
(format #f "~a configuration missing required field ~a" kind field)))
-(define (configuration-no-default-value kind field)
+(define (configuration-missing-default-value kind field)
(configuration-error
(format #f "The field `~a' of the `~a' configuration record \
does not have a default value" field kind)))
@@ -142,7 +142,8 @@ (define (define-maybe-helper serialize? prefix syn)
(id #'stem #'serialize-maybe- #'stem))))
#`(begin
(define (maybe-stem? val)
- (or (eq? val 'disabled) (stem? val)))
+ (or (unspecified? val)
+ (stem? val)))
#,@(if serialize?
(list #'(define (serialize-maybe-stem field-name val)
(if (stem? val)
@@ -170,10 +171,10 @@ (define (normalize-field-type+def s)
(values #'(field-type def)))
((field-type)
(identifier? #'field-type)
- (values #'(field-type 'disabled)))
+ (values #'(field-type *unspecified*)))
(field-type
(identifier? #'field-type)
- (values #'(field-type 'disabled)))))
+ (values #'(field-type *unspecified*)))))
(define (define-configuration-helper serialize? serializer-prefix syn)
(syntax-case syn ()
@@ -219,9 +220,7 @@ (define-record-type* #,(id #'stem #'< #'stem #'>)
source-properties->location))
(innate))
#,@(map (lambda (name getter def)
- (if (eq? (syntax->datum def) (quote 'undefined))
- #`(#,name #,getter)
- #`(#,name #,getter (default #,def))))
+ #`(#,name #,getter (default #,def)))
#'(field ...)
#'(field-getter ...)
#'(field-default ...)))
@@ -236,8 +235,8 @@ (define #,(id #'stem #'stem #'-fields)
(lambda ()
(display '#,(id #'stem #'% #'stem))
(if (eq? (syntax->datum field-default)
- 'undefined)
- (configuration-no-default-value
+ '*unspecified*)
+ (configuration-missing-default-value
'#,(id #'stem #'% #'stem) 'field)
field-default)))
(documentation doc))
diff --git a/gnu/services/file-sharing.scm b/gnu/services/file-sharing.scm
index e3d681b08f..6e71fa9154 100644
--- a/gnu/services/file-sharing.scm
+++ b/gnu/services/file-sharing.scm
@@ -115,8 +115,7 @@ (define-maybe string)
(set! serialize-maybe-string
(lambda (field-name val)
(serialize-string field-name
- (if (and (symbol? val)
- (eq? val 'disabled))
+ (if (unspecified? val)
""
val))))
@@ -181,8 +180,7 @@ (define (serialize-file-object field-name val)
(define-maybe file-object)
(set! serialize-maybe-file-object
(lambda (field-name val)
- (if (and (symbol? val)
- (eq? val 'disabled))
+ (if (unspecified? val)
(serialize-string field-name "")
(serialize-file-object field-name val))))
@@ -281,7 +279,7 @@ (define-configuration transmission-daemon-configuration
torrent is complete. Otherwise, files for all torrents (including those still
being downloaded) will be placed in @code{download-dir}.")
(incomplete-dir
- (maybe-string 'disabled)
+ (maybe-string)
"The directory in which files from incompletely downloaded torrents will be
held when @code{incomplete-dir-enabled?} is @code{#t}.")
(umask
@@ -305,7 +303,7 @@ (define-configuration transmission-daemon-configuration
automatically (and the original files removed, if
@code{trash-original-torrent-files?} is @code{#t}).")
(watch-dir
- (maybe-string 'disabled)
+ (maybe-string)
"The directory to be watched for @file{.torrent} files indicating new
torrents to be added, when @code{watch-dir-enabled} is @code{#t}.")
(trash-original-torrent-files?
@@ -401,11 +399,11 @@ (define-configuration transmission-daemon-configuration
@code{prefer-unencrypted-connections}, @code{prefer-encrypted-connections} or
@code{require-encrypted-connections}.")
(peer-congestion-algorithm
- (maybe-string 'disabled)
+ (maybe-string)
"The TCP congestion-control algorithm to use for peer connections,
specified using a string recognized by the operating system in calls to
-@code{setsockopt} (or set to @code{disabled}, in which case the
-operating-system default is used).
+@code{setsockopt} (or leave it unset, in which case the operating-system
+default is used).
Note that on GNU/Linux systems, the kernel must be configured to allow
processes to use a congestion-control algorithm not in the default set;
@@ -465,7 +463,7 @@ (define-configuration transmiss
This message was truncated. Download the full message here.
A
A
Attila Lendvai wrote on 7 Apr 2022 17:01
[PATCH v3 1/2] services: configuration: Support (field1 maybe-number "") format.
(address . 54674@debbugs.gnu.org)(name . Attila Lendvai)(address . attila@lendvai.name)
20220407150140.32738-1-attila@lendvai.name
As opposed to explicitly using 'disabled as value, or using the
(field1 (maybe-number) "") format.

It's mostly the work of Maxime Devos shared under #54674, with some
modifications by Attila Lendvai.

* gnu/services/configuration.scm (normalize-field-type+def): New function.
(define-configuration-helper) (define-configuration): Support new field
format.
* tests/services/configuration.scm (config-with-maybe-number->string): New
function.
("maybe value serialization of the instance"): New test.
("maybe value serialization of the instance, unspecified"): New test.
---

v3: clean up the commit message. the code was not changed.

note that a large part of the diff is whitespace only.

gnu/services/configuration.scm | 169 +++++++++++++++++--------------
tests/services/configuration.scm | 28 ++++-
2 files changed, 114 insertions(+), 83 deletions(-)

Toggle diff (268 lines)
diff --git a/gnu/services/configuration.scm b/gnu/services/configuration.scm
index 0de350a4df..bdca33ed68 100644
--- a/gnu/services/configuration.scm
+++ b/gnu/services/configuration.scm
@@ -5,6 +5,7 @@
;;; Copyright © 2021 Xinglu Chen <public@yoctocell.xyz>
;;; Copyright © 2021 Maxim Cournoyer <maxim.cournoyer@gmail.com>
;;; Copyright © 2021 Andrew Tropin <andrew@trop.in>
+;;; Copyright © 2022 Maxime Devos <maximedevos@telenet.be>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -162,78 +163,90 @@ (define-maybe-helper #t #f #'(_ stem))))))
(define-syntax-rule (define-maybe/no-serialization stem)
(define-maybe stem (no-serialization)))
+(define (normalize-field-type+def s)
+ (syntax-case s ()
+ ((field-type def)
+ (identifier? #'field-type)
+ (values #'(field-type def)))
+ ((field-type)
+ (identifier? #'field-type)
+ (values #'(field-type 'disabled)))
+ (field-type
+ (identifier? #'field-type)
+ (values #'(field-type 'disabled)))))
+
(define (define-configuration-helper serialize? serializer-prefix syn)
(syntax-case syn ()
- ((_ stem (field (field-type def ...) doc custom-serializer ...) ...)
- (with-syntax (((field-getter ...)
- (map (lambda (field)
- (id #'stem #'stem #'- field))
- #'(field ...)))
- ((field-predicate ...)
- (map (lambda (type)
- (id #'stem type #'?))
- #'(field-type ...)))
- ((field-default ...)
- (map (match-lambda
- ((field-type default-value)
- default-value)
- ((field-type)
- ;; Quote `undefined' to prevent a possibly
- ;; unbound warning.
- (syntax 'undefined)))
- #'((field-type def ...) ...)))
- ((field-serializer ...)
- (map (lambda (type custom-serializer)
- (and serialize?
- (match custom-serializer
- ((serializer)
- serializer)
- (()
- (if serializer-prefix
- (id #'stem
- serializer-prefix
- #'serialize- type)
- (id #'stem #'serialize- type))))))
- #'(field-type ...)
- #'((custom-serializer ...) ...))))
- #`(begin
- (define-record-type* #,(id #'stem #'< #'stem #'>)
- #,(id #'stem #'% #'stem)
- #,(id #'stem #'make- #'stem)
- #,(id #'stem #'stem #'?)
- (%location #,(id #'stem #'stem #'-location)
- (default (and=> (current-source-location)
- source-properties->location))
- (innate))
- #,@(map (lambda (name getter def)
- (if (eq? (syntax->datum def) (quote 'undefined))
- #`(#,name #,getter)
- #`(#,name #,getter (default #,def))))
- #'(field ...)
- #'(field-getter ...)
- #'(field-default ...)))
- (define #,(id #'stem #'stem #'-fields)
- (list (configuration-field
- (name 'field)
- (type 'field-type)
- (getter field-getter)
- (predicate field-predicate)
- (serializer field-serializer)
- (default-value-thunk
- (lambda ()
- (display '#,(id #'stem #'% #'stem))
- (if (eq? (syntax->datum field-default)
- 'undefined)
- (configuration-no-default-value
- '#,(id #'stem #'% #'stem) 'field)
- field-default)))
- (documentation doc))
- ...))
- (define-syntax-rule (stem arg (... ...))
- (let ((conf (#,(id #'stem #'% #'stem) arg (... ...))))
- (validate-configuration conf
- #,(id #'stem #'stem #'-fields))
- conf)))))))
+ ((_ stem (field field-type+def doc custom-serializer ...) ...)
+ (with-syntax
+ ((((field-type def) ...)
+ (map normalize-field-type+def #'(field-type+def ...))))
+ (with-syntax
+ (((field-getter ...)
+ (map (lambda (field)
+ (id #'stem #'stem #'- field))
+ #'(field ...)))
+ ((field-predicate ...)
+ (map (lambda (type)
+ (id #'stem type #'?))
+ #'(field-type ...)))
+ ((field-default ...)
+ (map (match-lambda
+ ((field-type default-value)
+ default-value))
+ #'((field-type def) ...)))
+ ((field-serializer ...)
+ (map (lambda (type custom-serializer)
+ (and serialize?
+ (match custom-serializer
+ ((serializer)
+ serializer)
+ (()
+ (if serializer-prefix
+ (id #'stem
+ serializer-prefix
+ #'serialize- type)
+ (id #'stem #'serialize- type))))))
+ #'(field-type ...)
+ #'((custom-serializer ...) ...))))
+ #`(begin
+ (define-record-type* #,(id #'stem #'< #'stem #'>)
+ #,(id #'stem #'% #'stem)
+ #,(id #'stem #'make- #'stem)
+ #,(id #'stem #'stem #'?)
+ (%location #,(id #'stem #'stem #'-location)
+ (default (and=> (current-source-location)
+ source-properties->location))
+ (innate))
+ #,@(map (lambda (name getter def)
+ (if (eq? (syntax->datum def) (quote 'undefined))
+ #`(#,name #,getter)
+ #`(#,name #,getter (default #,def))))
+ #'(field ...)
+ #'(field-getter ...)
+ #'(field-default ...)))
+ (define #,(id #'stem #'stem #'-fields)
+ (list (configuration-field
+ (name 'field)
+ (type 'field-type)
+ (getter field-getter)
+ (predicate field-predicate)
+ (serializer field-serializer)
+ (default-value-thunk
+ (lambda ()
+ (display '#,(id #'stem #'% #'stem))
+ (if (eq? (syntax->datum field-default)
+ 'undefined)
+ (configuration-no-default-value
+ '#,(id #'stem #'% #'stem) 'field)
+ field-default)))
+ (documentation doc))
+ ...))
+ (define-syntax-rule (stem arg (... ...))
+ (let ((conf (#,(id #'stem #'% #'stem) arg (... ...))))
+ (validate-configuration conf
+ #,(id #'stem #'stem #'-fields))
+ conf))))))))
(define no-serialization ;syntactic keyword for 'define-configuration'
'(no serialization))
@@ -241,26 +254,26 @@ (define no-serialization ;syntactic keyword for 'define-configuration'
(define-syntax define-configuration
(lambda (s)
(syntax-case s (no-serialization prefix)
- ((_ stem (field (field-type def ...) doc custom-serializer ...) ...
+ ((_ stem (field field-type+def doc custom-serializer ...) ...
(no-serialization))
(define-configuration-helper
- #f #f #'(_ stem (field (field-type def ...) doc custom-serializer ...)
+ #f #f #'(_ stem (field field-type+def doc custom-serializer ...)
...)))
- ((_ stem (field (field-type def ...) doc custom-serializer ...) ...
+ ((_ stem (field field-type+def doc custom-serializer ...) ...
(prefix serializer-prefix))
(define-configuration-helper
- #t #'serializer-prefix #'(_ stem (field (field-type def ...)
+ #t #'serializer-prefix #'(_ stem (field field-type+def
doc custom-serializer ...)
...)))
- ((_ stem (field (field-type def ...) doc custom-serializer ...) ...)
+ ((_ stem (field field-type+def doc custom-serializer ...) ...)
(define-configuration-helper
- #t #f #'(_ stem (field (field-type def ...) doc custom-serializer ...)
+ #t #f #'(_ stem (field field-type+def doc custom-serializer ...)
...))))))
(define-syntax-rule (define-configuration/no-serialization
- stem (field (field-type def ...)
+ stem (field field-type+def
doc custom-serializer ...) ...)
- (define-configuration stem (field (field-type def ...)
+ (define-configuration stem (field field-type+def
doc custom-serializer ...) ...
(no-serialization)))
diff --git a/tests/services/configuration.scm b/tests/services/configuration.scm
index 86a36a388d..0debf8095b 100644
--- a/tests/services/configuration.scm
+++ b/tests/services/configuration.scm
@@ -27,6 +27,9 @@ (define-module (tests services configuration)
(test-begin "services-configuration")
+(define (serialize-number field value)
+ (format #f "~a=~a" field value))
+
;;;
;;; define-configuration macro.
@@ -47,7 +50,6 @@ (define-configuration port-configuration-cs
80
(port-configuration-cs-port (port-configuration-cs)))
-(define serialize-number "")
(define-configuration port-configuration-ndv
(port (number) "The port number."))
@@ -101,15 +103,31 @@ (define-configuration configuration-with-prefix
(define-maybe number)
(define-configuration config-with-maybe-number
- (port (maybe-number 80) "The port number."))
-
-(define (serialize-number field value)
- (format #f "~a=~a" field value))
+ (port (maybe-number 80) "")
+ (count maybe-number ""))
(test-equal "maybe value serialization"
"port=80"
(serialize-maybe-number "port" 80))
+(define (config-with-maybe-number->string x)
+ (eval (gexp->approximate-sexp
+ (serialize-configuration x config-with-maybe-number-fields))
+ (current-module)))
+
+(test-equal "maybe value serialization of the instance"
+ "port=42count=43"
+ (config-with-maybe-number->string
+ (config-with-maybe-number
+ (port 42)
+ (count 43))))
+
+(test-equal "maybe value serialization of the instance, unspecified"
+ "port=42"
+ (config-with-maybe-number->string
+ (config-with-maybe-number
+ (port 42))))
+
(define-maybe/no-serialization string)
(define-configuration config-with-maybe-string/no-serialization
--
2.34.0
A
A
Attila Lendvai wrote on 7 Apr 2022 17:01
[PATCH v3 2/2] services: configuration: Use *unspecified* instead of 'disabled.
(address . 54674@debbugs.gnu.org)(name . Attila Lendvai)(address . attila@lendvai.name)
20220407150140.32738-2-attila@lendvai.name
Use it as a marker for field values that have not been set.

Rationale: 'disabled may easily clash with user values for boolean fields, is
confusing (i.e. its meaning is *not* boolean false, but unspecified) and it
also passes through silently the symbol? predicate of a field of type symbol.

* gnu/services/configuration.scm (configuration-missing-default-value):
Renamed from configuration-no-default-value.
* gnu/services/configuration.scm (define-maybe-helper): Use *unspecified*
instead of 'disabled, and make the default value optional.
* tests/services/configuration.scm ("maybe type, no default")
("maybe type, with default"): New tests.
---

v3 cleans up the commit message. the code is not changed.

gnu/home/services/desktop.scm | 12 ++---
gnu/services/authentication.scm | 82 ++++++++++++++++----------------
gnu/services/cgit.scm | 12 ++---
gnu/services/configuration.scm | 17 ++++---
gnu/services/file-sharing.scm | 24 +++++-----
gnu/services/messaging.scm | 37 +++++++-------
gnu/services/networking.scm | 12 ++---
gnu/services/pm.scm | 54 ++++++++++-----------
gnu/services/telephony.scm | 14 +++---
gnu/services/vpn.scm | 2 +-
tests/services/configuration.scm | 12 +++++
11 files changed, 144 insertions(+), 134 deletions(-)

Toggle diff (451 lines)
diff --git a/gnu/home/services/desktop.scm b/gnu/home/services/desktop.scm
index cbb9cf76da..a54ad0d115 100644
--- a/gnu/home/services/desktop.scm
+++ b/gnu/home/services/desktop.scm
@@ -91,26 +91,26 @@ (define-configuration home-redshift-configuration
"Nighttime color temperature (kelvins).")
(daytime-brightness
- (maybe-inexact-number 'disabled)
+ (maybe-inexact-number)
"Daytime screen brightness, between 0.1 and 1.0.")
(nighttime-brightness
- (maybe-inexact-number 'disabled)
+ (maybe-inexact-number)
"Nighttime screen brightness, between 0.1 and 1.0.")
(latitude
- (maybe-inexact-number 'disabled)
+ (maybe-inexact-number)
"Latitude, when @code{location-provider} is @code{'manual}.")
(longitude
- (maybe-inexact-number 'disabled)
+ (maybe-inexact-number)
"Longitude, when @code{location-provider} is @code{'manual}.")
(dawn-time
- (maybe-string 'disabled)
+ (maybe-string)
"Custom time for the transition from night to day in the
morning---@code{\"HH:MM\"} format. When specified, solar elevation is not
used to determine the daytime/nighttime period.")
(dusk-time
- (maybe-string 'disabled)
+ (maybe-string)
"Likewise, custom time for the transition from day to night in the
evening.")
diff --git a/gnu/services/authentication.scm b/gnu/services/authentication.scm
index cb0ef6d85a..1c4800bfbd 100644
--- a/gnu/services/authentication.scm
+++ b/gnu/services/authentication.scm
@@ -218,7 +218,7 @@ (define-configuration nslcd-configuration
;; Runtime options
(threads
- (maybe-number 'disabled)
+ (maybe-number)
"The number of threads to start that can handle requests and perform LDAP
queries. Each thread opens a separate connection to the LDAP server. The
default is to start 5 threads.")
@@ -243,45 +243,45 @@ (define-configuration nslcd-configuration
"The list of LDAP server URIs. Normally, only the first server will be
used with the following servers as fall-back.")
(ldap-version
- (maybe-string 'disabled)
+ (maybe-string)
"The version of the LDAP protocol to use. The default is to use the
maximum version supported by the LDAP library.")
(binddn
- (maybe-string 'disabled)
+ (maybe-string)
"Specifies the distinguished name with which to bind to the directory
server for lookups. The default is to bind anonymously.")
(bindpw
- (maybe-string 'disabled)
+ (maybe-string)
"Specifies the credentials with which to bind. This option is only
applicable when used with binddn.")
(rootpwmoddn
- (maybe-string 'disabled)
+ (maybe-string)
"Specifies the distinguished name to use when the root user tries to modify
a user's password using the PAM module.")
(rootpwmodpw
- (maybe-string 'disabled)
+ (maybe-string)
"Specifies the credentials with which to bind if the root user tries to
change a user's password. This option is only applicable when used with
rootpwmoddn")
;; SASL authentication options
(sasl-mech
- (maybe-string 'disabled)
+ (maybe-string)
"Specifies the SASL mechanism to be used when performing SASL
authentication.")
(sasl-realm
- (maybe-string 'disabled)
+ (maybe-string)
"Specifies the SASL realm to be used when performing SASL authentication.")
(sasl-authcid
- (maybe-string 'disabled)
+ (maybe-string)
"Specifies the authentication identity to be used when performing SASL
authentication.")
(sasl-authzid
- (maybe-string 'disabled)
+ (maybe-string)
"Specifies the authorization identity to be used when performing SASL
authentication.")
(sasl-canonicalize?
- (maybe-boolean 'disabled)
+ (maybe-boolean)
"Determines whether the LDAP server host name should be canonicalised. If
this is enabled the LDAP library will do a reverse host name lookup. By
default, it is left up to the LDAP library whether this check is performed or
@@ -289,7 +289,7 @@ (define-configuration nslcd-configuration
;; Kerberos authentication options
(krb5-ccname
- (maybe-string 'disabled)
+ (maybe-string)
"Set the name for the GSS-API Kerberos credentials cache.")
;; Search / mapping options
@@ -302,11 +302,11 @@ (define-configuration nslcd-configuration
default scope is subtree; base scope is almost never useful for name service
lookups; children scope is not supported on all servers.")
(deref
- (maybe-deref-option 'disabled)
+ (maybe-deref-option)
"Specifies the policy for dereferencing aliases. The default policy is to
never dereference aliases.")
(referrals
- (maybe-boolean 'disabled)
+ (maybe-boolean)
"Specifies whether automatic referral chasing should be enabled. The
default behaviour is to chase referrals.")
(maps
@@ -322,132 +322,132 @@ (define-configuration nslcd-configuration
;; Timing / reconnect options
(bind-timelimit
- (maybe-number 'disabled)
+ (maybe-number)
"Specifies the time limit in seconds to use when connecting to the
directory server. The default value is 10 seconds.")
(timelimit
- (maybe-number 'disabled)
+ (maybe-number)
"Specifies the time limit (in seconds) to wait for a response from the LDAP
server. A value of zero, which is the default, is to wait indefinitely for
searches to be completed.")
(idle-timelimit
- (maybe-number 'disabled)
+ (maybe-number)
"Specifies the period if inactivity (in seconds) after which the con?
nection to the LDAP server will be closed. The default is not to time out
connections.")
(reconnect-sleeptime
- (maybe-number 'disabled)
+ (maybe-number)
"Specifies the number of seconds to sleep when connecting to all LDAP
servers fails. By default one second is waited between the first failure and
the first retry.")
(reconnect-retrytime
- (maybe-number 'disabled)
+ (maybe-number)
"Specifies the time after which the LDAP server is considered to be
permanently unavailable. Once this time is reached retries will be done only
once per this time period. The default value is 10 seconds.")
;; TLS options
(ssl
- (maybe-ssl-option 'disabled)
+ (maybe-ssl-option)
"Specifies whether to use SSL/TLS or not (the default is not to). If
'start-tls is specified then StartTLS is used rather than raw LDAP over SSL.")
(tls-reqcert
- (maybe-tls-reqcert-option 'disabled)
+ (maybe-tls-reqcert-option)
"Specifies what checks to perform on a server-supplied certificate.
The meaning of the values is described in the ldap.conf(5) manual page.")
(tls-cacertdir
- (maybe-string 'disabled)
+ (maybe-string)
"Specifies the directory containing X.509 certificates for peer authen?
tication. This parameter is ignored when using GnuTLS.")
(tls-cacertfile
- (maybe-string 'disabled)
+ (maybe-string)
"Specifies the path to the X.509 certificate for peer authentication.")
(tls-randfile
- (maybe-string 'disabled)
+ (maybe-string)
"Specifies the path to an entropy source. This parameter is ignored when
using GnuTLS.")
(tls-ciphers
- (maybe-string 'disabled)
+ (maybe-string)
"Specifies the ciphers to use for TLS as a string.")
(tls-cert
- (maybe-string 'disabled)
+ (maybe-string)
"Specifies the path to the file containing the local certificate for client
TLS authentication.")
(tls-key
- (maybe-string 'disabled)
+ (maybe-string)
"Specifies the path to the file containing the private key for client TLS
authentication.")
;; Other options
(pagesize
- (maybe-number 'disabled)
+ (maybe-number)
"Set this to a number greater than 0 to request paged results from the LDAP
server in accordance with RFC2696. The default (0) is to not request paged
results.")
(nss-initgroups-ignoreusers
- (maybe-ignore-users-option 'disabled)
+ (maybe-ignore-users-option)
"This option prevents group membership lookups through LDAP for the
specified users. Alternatively, the value 'all-local may be used. With that
value nslcd builds a full list of non-LDAP users on startup.")
(nss-min-uid
- (maybe-number 'disabled)
+ (maybe-number)
"This option ensures that LDAP users with a numeric user id lower than the
specified value are ignored.")
(nss-uid-offset
- (maybe-number 'disabled)
+ (maybe-number)
"This option specifies an offset that is added to all LDAP numeric user
ids. This can be used to avoid user id collisions with local users.")
(nss-gid-offset
- (maybe-number 'disabled)
+ (maybe-number)
"This option specifies an offset that is added to all LDAP numeric group
ids. This can be used to avoid user id collisions with local groups.")
(nss-nested-groups
- (maybe-boolean 'disabled)
+ (maybe-boolean)
"If this option is set, the member attribute of a group may point to
another group. Members of nested groups are also returned in the higher level
group and parent groups are returned when finding groups for a specific user.
The default is not to perform extra searches for nested groups.")
(nss-getgrent-skipmembers
- (maybe-boolean 'disabled)
+ (maybe-boolean)
"If this option is set, the group member list is not retrieved when looking
up groups. Lookups for finding which groups a user belongs to will remain
functional so the user will likely still get the correct groups assigned on
login.")
(nss-disable-enumeration
- (maybe-boolean 'disabled)
+ (maybe-boolean)
"If this option is set, functions which cause all user/group entries to be
loaded from the directory will not succeed in doing so. This can dramatically
reduce LDAP server load in situations where there are a great number of users
and/or groups. This option is not recommended for most configurations.")
(validnames
- (maybe-string 'disabled)
+ (maybe-string)
"This option can be used to specify how user and group names are verified
within the system. This pattern is used to check all user and group names
that are requested and returned from LDAP.")
(ignorecase
- (maybe-boolean 'disabled)
+ (maybe-boolean)
"This specifies whether or not to perform searches using case-insensitive
matching. Enabling this could open up the system to authorization bypass
vulnerabilities and introduce nscd cache poisoning vulnerabilities which allow
denial of service.")
(pam-authc-ppolicy
- (maybe-boolean 'disabled)
+ (maybe-boolean)
"This option specifies whether password policy controls are requested and
handled from the LDAP server when performing user authentication.")
(pam-authc-search
- (maybe-string 'disabled)
+ (maybe-string)
"By default nslcd performs an LDAP search with the user's credentials after
BIND (authentication) to ensure that the BIND operation was successful. The
default search is a simple check to see if the user's DN exists. A search
filter can be specified that will be used instead. It should return at least
one entry.")
(pam-authz-search
- (maybe-string 'disabled)
+ (maybe-string)
"This option allows flexible fine tuning of the authorisation check that
should be performed. The search filter specified is executed and if any
entries match, access is granted, otherwise access is denied.")
(pam-password-prohibit-message
- (maybe-string 'disabled)
+ (maybe-string)
"If this option is set password modification using pam_ldap will be denied
and the specified message will be presented to the user instead. The message
can be used to direct the user to an alternative means of changing their
diff --git a/gnu/services/cgit.scm b/gnu/services/cgit.scm
index bfc89a40a4..bcb3e1a796 100644
--- a/gnu/services/cgit.scm
+++ b/gnu/services/cgit.scm
@@ -241,27 +241,27 @@ (define-configuration repository-cgit-configuration
(repo-file-object "")
"Override the default @code{email-filter}.")
(enable-commit-graph?
- (maybe-repo-boolean 'disabled)
+ (maybe-repo-boolean)
"A flag which can be used to disable the global setting
@code{enable-commit-graph?}.")
(enable-log-filecount?
- (maybe-repo-boolean 'disabled)
+ (maybe-repo-boolean)
"A flag which can be used to disable the global setting
@code{enable-log-filecount?}.")
(enable-log-linecount?
- (maybe-repo-boolean 'disabled)
+ (maybe-repo-boolean)
"A flag which can be used to disable the global setting
@code{enable-log-linecount?}.")
(enable-remote-branches?
- (maybe-repo-boolean 'disabled)
+ (maybe-repo-boolean)
"Flag which, when set to @code{#t}, will make cgit display remote
branches in the summary and refs views.")
(enable-subject-links?
- (maybe-repo-boolean 'disabled)
+ (maybe-repo-boolean)
"A flag which can be used to override the global setting
@code{enable-subject-links?}.")
(enable-html-serving?
- (maybe-repo-boolean 'disabled)
+ (maybe-repo-boolean)
"A flag which can be used to override the global setting
@code{enable-html-serving?}.")
(hide?
diff --git a/gnu/services/configuration.scm b/gnu/services/configuration.scm
index bdca33ed68..f6b20fb82b 100644
--- a/gnu/services/configuration.scm
+++ b/gnu/services/configuration.scm
@@ -93,7 +93,7 @@ (define (configuration-field-error field val)
(define (configuration-missing-field kind field)
(configuration-error
(format #f "~a configuration missing required field ~a" kind field)))
-(define (configuration-no-default-value kind field)
+(define (configuration-missing-default-value kind field)
(configuration-error
(format #f "The field `~a' of the `~a' configuration record \
does not have a default value" field kind)))
@@ -142,7 +142,8 @@ (define (define-maybe-helper serialize? prefix syn)
(id #'stem #'serialize-maybe- #'stem))))
#`(begin
(define (maybe-stem? val)
- (or (eq? val 'disabled) (stem? val)))
+ (or (unspecified? val)
+ (stem? val)))
#,@(if serialize?
(list #'(define (serialize-maybe-stem field-name val)
(if (stem? val)
@@ -170,10 +171,10 @@ (define (normalize-field-type+def s)
(values #'(field-type def)))
((field-type)
(identifier? #'field-type)
- (values #'(field-type 'disabled)))
+ (values #'(field-type *unspecified*)))
(field-type
(identifier? #'field-type)
- (values #'(field-type 'disabled)))))
+ (values #'(field-type *unspecified*)))))
(define (define-configuration-helper serialize? serializer-prefix syn)
(syntax-case syn ()
@@ -219,9 +220,7 @@ (define-record-type* #,(id #'stem #'< #'stem #'>)
source-properties->location))
(innate))
#,@(map (lambda (name getter def)
- (if (eq? (syntax->datum def) (quote 'undefined))
- #`(#,name #,getter)
- #`(#,name #,getter (default #,def))))
+ #`(#,name #,getter (default #,def)))
#'(field ...)
#'(field-getter ...)
#'(field-default ...)))
@@ -236,8 +235,8 @@ (define #,(id #'stem #'stem #'-fields)
(lambda ()
(display '#,(id #'stem #'% #'stem))
(if (eq? (syntax->datum field-default)
- 'undefined)
- (configuration-no-default-value
+ '*unspecified*)
+ (configuration-missing-default-value
'#,(id #'stem #'% #'stem) 'field)
field-default)))
(documentation doc))
diff --git a/gnu/services/file-sharing.scm b/gnu/services/file-sharing.scm
index e3d681b08f..6e71fa9154 100644
--- a/gnu/services/file-sharing.scm
+++ b/gnu/services/file-sharing.scm
@@ -115,8 +115,7 @@ (define-maybe string)
(set! serialize-maybe-string
(lambda (field-name val)
(serialize-string field-name
- (if (and (symbol? val)
- (eq? val 'disabled))
+ (if (unspecified? val)
""
val))))
@@ -181,8 +180,7 @@ (define (serialize-file-object field-name val)
(define-maybe file-object)
(set! serialize-maybe-file-object
(lambda (field-name val)
- (if (and (symbol? val)
- (eq? val 'disabled))
+ (if (unspecified? val)
(serialize-string field-name "")
(serialize-file-object field-name val))))
@@ -281,7 +279,7 @@ (define-configuration transmission-daemon-configuration
torrent is complete. Otherwise, files for all torrents (including those still
being downloaded) will be placed in @code{download-dir}.")
(incomplete-dir
- (maybe-string 'disabled)
+ (maybe-string)
"The directory in which files from incompletely downloaded torrents will be
held when @code{incomplete-dir-enabled?} is @code{#t}.")
(umask
@@ -305,7 +303,7 @@ (define-configuration transmission-daemon-configuration
automatically (and the original files removed, if
@code{trash-original-torrent-files?} is @code{#t}).")
(watch-dir
- (maybe-string 'disabled)
+ (maybe-string)
"The directory to be watched for @file{.torrent} files indicating new
torrents to be added, when @code{watch-dir-enabled} is @code{#t}.")
(trash-original-torrent-files?
@@ -401,11 +399,11 @@ (define-configuration transmission-daemon-configuration
@code{prefer-unencrypted-connections}, @code{prefer-encrypted-connections} or
@code{require-encrypted-connections}.")
(peer-congestion-algorithm
- (maybe-string 'disabled)
+ (maybe-string)
"The TCP congestion-control algorithm to use for peer connections,
specified using a string recognized by the operating system in calls to
-@code{setsockopt} (or set to @code{disabled}, in which case the
-operating-system default is used).
+@code{setsockopt} (or leave it unset, in which case the operating-system
+default is used).
Note that on GNU/Linux systems, the kernel must be configured to allow
processes to use a congestion-control algorithm not in the default set;
@@ -465,7 +463,7 @@ (define-configuration transmission-daemon-configuration
"When @code{#t}, the daemon will ignore peers mentioned in the blocklist it
has most recently downloaded from @code{blocklist-url}.")
(blocklist-url
- (maybe-string 'disabled)
+ (maybe-string)
"The URL of a peer blocklist (in @acronym{P2P}-plaintext or eMule
@file{.dat} format) to be periodically downloaded and applied when
@code{blocklist-enabled?}
This message was truncated. Download the full message here.
A
A
Attila Lendvai wrote on 18 Apr 2022 11:26
Re: [bug#54674] [PATCH] services: configuration: Use *unspecified* instead of 'disabled.
(name . Maxime Devos)(address . maximedevos@telenet.be)(address . 54674@debbugs.gnu.org)
rA7JQjdYjBC_kIfluPIuWwrkxcSrezhRbdmuIOAw3d01e4m6XtluI3NJmnzS7P3lL9t7t_GTKSEOtPtLdWxN0PQwgCis9p3dMvm192qvCDM=@lendvai.name
i don't want to be pushy, but some changes that i wish i could publish is held back by the fate of this patchset (https://github.com/attila-lendvai/guix-crypto/commits/staging).hence i wish there was some progress on this, and i'm willing to do whatever may help the process (e.g. writing some more tests?).

i'd be satisfied with a simple promise that it's already being investigated/tested, or even with a rejection that this is not the right direction and it probably won't be accepted. it would be disappointing, but then i could refactor my channel to work with the current guix proper codebase and publish it.

--
• attila lendvai
• PGP: 963F 5D5F 45C7 DFCD 0A39
--
“Keep things as simple as you can, but no simpler.”
— Albert Einstein (1879–1955), variations: things/explanation; Einstein/Occam
A
A
Attila Lendvai wrote on 20 Apr 2022 11:15
[PATCH v4 1/2] services: configuration: Support (field1 maybe-number "") format.
(address . 54674@debbugs.gnu.org)(name . Attila Lendvai)(address . attila@lendvai.name)
20220420091553.26732-1-attila@lendvai.name
As opposed to explicitly using 'disabled as value, or using the
(field1 (maybe-number) "") format.

It's mostly the work of Maxime Devos shared under #54674, with some
modifications by Attila Lendvai.

* gnu/services/configuration.scm (normalize-field-type+def): New function.
(define-configuration-helper) (define-configuration): Support new field
format.
* tests/services/configuration.scm (config-with-maybe-number->string): New
function.
("maybe value serialization of the instance"): New test.
("maybe value serialization of the instance, unspecified"): New test.
---

v4: the only change is to drop the extra parens around the type in
all the (field1 (maybe-foo) "") forms.

gnu/services/configuration.scm | 169 +++++++++++++++++--------------
tests/services/configuration.scm | 28 ++++-
2 files changed, 114 insertions(+), 83 deletions(-)

Toggle diff (268 lines)
diff --git a/gnu/services/configuration.scm b/gnu/services/configuration.scm
index 0de350a4df..bdca33ed68 100644
--- a/gnu/services/configuration.scm
+++ b/gnu/services/configuration.scm
@@ -5,6 +5,7 @@
;;; Copyright © 2021 Xinglu Chen <public@yoctocell.xyz>
;;; Copyright © 2021 Maxim Cournoyer <maxim.cournoyer@gmail.com>
;;; Copyright © 2021 Andrew Tropin <andrew@trop.in>
+;;; Copyright © 2022 Maxime Devos <maximedevos@telenet.be>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -162,78 +163,90 @@ (define-maybe-helper #t #f #'(_ stem))))))
(define-syntax-rule (define-maybe/no-serialization stem)
(define-maybe stem (no-serialization)))
+(define (normalize-field-type+def s)
+ (syntax-case s ()
+ ((field-type def)
+ (identifier? #'field-type)
+ (values #'(field-type def)))
+ ((field-type)
+ (identifier? #'field-type)
+ (values #'(field-type 'disabled)))
+ (field-type
+ (identifier? #'field-type)
+ (values #'(field-type 'disabled)))))
+
(define (define-configuration-helper serialize? serializer-prefix syn)
(syntax-case syn ()
- ((_ stem (field (field-type def ...) doc custom-serializer ...) ...)
- (with-syntax (((field-getter ...)
- (map (lambda (field)
- (id #'stem #'stem #'- field))
- #'(field ...)))
- ((field-predicate ...)
- (map (lambda (type)
- (id #'stem type #'?))
- #'(field-type ...)))
- ((field-default ...)
- (map (match-lambda
- ((field-type default-value)
- default-value)
- ((field-type)
- ;; Quote `undefined' to prevent a possibly
- ;; unbound warning.
- (syntax 'undefined)))
- #'((field-type def ...) ...)))
- ((field-serializer ...)
- (map (lambda (type custom-serializer)
- (and serialize?
- (match custom-serializer
- ((serializer)
- serializer)
- (()
- (if serializer-prefix
- (id #'stem
- serializer-prefix
- #'serialize- type)
- (id #'stem #'serialize- type))))))
- #'(field-type ...)
- #'((custom-serializer ...) ...))))
- #`(begin
- (define-record-type* #,(id #'stem #'< #'stem #'>)
- #,(id #'stem #'% #'stem)
- #,(id #'stem #'make- #'stem)
- #,(id #'stem #'stem #'?)
- (%location #,(id #'stem #'stem #'-location)
- (default (and=> (current-source-location)
- source-properties->location))
- (innate))
- #,@(map (lambda (name getter def)
- (if (eq? (syntax->datum def) (quote 'undefined))
- #`(#,name #,getter)
- #`(#,name #,getter (default #,def))))
- #'(field ...)
- #'(field-getter ...)
- #'(field-default ...)))
- (define #,(id #'stem #'stem #'-fields)
- (list (configuration-field
- (name 'field)
- (type 'field-type)
- (getter field-getter)
- (predicate field-predicate)
- (serializer field-serializer)
- (default-value-thunk
- (lambda ()
- (display '#,(id #'stem #'% #'stem))
- (if (eq? (syntax->datum field-default)
- 'undefined)
- (configuration-no-default-value
- '#,(id #'stem #'% #'stem) 'field)
- field-default)))
- (documentation doc))
- ...))
- (define-syntax-rule (stem arg (... ...))
- (let ((conf (#,(id #'stem #'% #'stem) arg (... ...))))
- (validate-configuration conf
- #,(id #'stem #'stem #'-fields))
- conf)))))))
+ ((_ stem (field field-type+def doc custom-serializer ...) ...)
+ (with-syntax
+ ((((field-type def) ...)
+ (map normalize-field-type+def #'(field-type+def ...))))
+ (with-syntax
+ (((field-getter ...)
+ (map (lambda (field)
+ (id #'stem #'stem #'- field))
+ #'(field ...)))
+ ((field-predicate ...)
+ (map (lambda (type)
+ (id #'stem type #'?))
+ #'(field-type ...)))
+ ((field-default ...)
+ (map (match-lambda
+ ((field-type default-value)
+ default-value))
+ #'((field-type def) ...)))
+ ((field-serializer ...)
+ (map (lambda (type custom-serializer)
+ (and serialize?
+ (match custom-serializer
+ ((serializer)
+ serializer)
+ (()
+ (if serializer-prefix
+ (id #'stem
+ serializer-prefix
+ #'serialize- type)
+ (id #'stem #'serialize- type))))))
+ #'(field-type ...)
+ #'((custom-serializer ...) ...))))
+ #`(begin
+ (define-record-type* #,(id #'stem #'< #'stem #'>)
+ #,(id #'stem #'% #'stem)
+ #,(id #'stem #'make- #'stem)
+ #,(id #'stem #'stem #'?)
+ (%location #,(id #'stem #'stem #'-location)
+ (default (and=> (current-source-location)
+ source-properties->location))
+ (innate))
+ #,@(map (lambda (name getter def)
+ (if (eq? (syntax->datum def) (quote 'undefined))
+ #`(#,name #,getter)
+ #`(#,name #,getter (default #,def))))
+ #'(field ...)
+ #'(field-getter ...)
+ #'(field-default ...)))
+ (define #,(id #'stem #'stem #'-fields)
+ (list (configuration-field
+ (name 'field)
+ (type 'field-type)
+ (getter field-getter)
+ (predicate field-predicate)
+ (serializer field-serializer)
+ (default-value-thunk
+ (lambda ()
+ (display '#,(id #'stem #'% #'stem))
+ (if (eq? (syntax->datum field-default)
+ 'undefined)
+ (configuration-no-default-value
+ '#,(id #'stem #'% #'stem) 'field)
+ field-default)))
+ (documentation doc))
+ ...))
+ (define-syntax-rule (stem arg (... ...))
+ (let ((conf (#,(id #'stem #'% #'stem) arg (... ...))))
+ (validate-configuration conf
+ #,(id #'stem #'stem #'-fields))
+ conf))))))))
(define no-serialization ;syntactic keyword for 'define-configuration'
'(no serialization))
@@ -241,26 +254,26 @@ (define no-serialization ;syntactic keyword for 'define-configuration'
(define-syntax define-configuration
(lambda (s)
(syntax-case s (no-serialization prefix)
- ((_ stem (field (field-type def ...) doc custom-serializer ...) ...
+ ((_ stem (field field-type+def doc custom-serializer ...) ...
(no-serialization))
(define-configuration-helper
- #f #f #'(_ stem (field (field-type def ...) doc custom-serializer ...)
+ #f #f #'(_ stem (field field-type+def doc custom-serializer ...)
...)))
- ((_ stem (field (field-type def ...) doc custom-serializer ...) ...
+ ((_ stem (field field-type+def doc custom-serializer ...) ...
(prefix serializer-prefix))
(define-configuration-helper
- #t #'serializer-prefix #'(_ stem (field (field-type def ...)
+ #t #'serializer-prefix #'(_ stem (field field-type+def
doc custom-serializer ...)
...)))
- ((_ stem (field (field-type def ...) doc custom-serializer ...) ...)
+ ((_ stem (field field-type+def doc custom-serializer ...) ...)
(define-configuration-helper
- #t #f #'(_ stem (field (field-type def ...) doc custom-serializer ...)
+ #t #f #'(_ stem (field field-type+def doc custom-serializer ...)
...))))))
(define-syntax-rule (define-configuration/no-serialization
- stem (field (field-type def ...)
+ stem (field field-type+def
doc custom-serializer ...) ...)
- (define-configuration stem (field (field-type def ...)
+ (define-configuration stem (field field-type+def
doc custom-serializer ...) ...
(no-serialization)))
diff --git a/tests/services/configuration.scm b/tests/services/configuration.scm
index 86a36a388d..0debf8095b 100644
--- a/tests/services/configuration.scm
+++ b/tests/services/configuration.scm
@@ -27,6 +27,9 @@ (define-module (tests services configuration)
(test-begin "services-configuration")
+(define (serialize-number field value)
+ (format #f "~a=~a" field value))
+
;;;
;;; define-configuration macro.
@@ -47,7 +50,6 @@ (define-configuration port-configuration-cs
80
(port-configuration-cs-port (port-configuration-cs)))
-(define serialize-number "")
(define-configuration port-configuration-ndv
(port (number) "The port number."))
@@ -101,15 +103,31 @@ (define-configuration configuration-with-prefix
(define-maybe number)
(define-configuration config-with-maybe-number
- (port (maybe-number 80) "The port number."))
-
-(define (serialize-number field value)
- (format #f "~a=~a" field value))
+ (port (maybe-number 80) "")
+ (count maybe-number ""))
(test-equal "maybe value serialization"
"port=80"
(serialize-maybe-number "port" 80))
+(define (config-with-maybe-number->string x)
+ (eval (gexp->approximate-sexp
+ (serialize-configuration x config-with-maybe-number-fields))
+ (current-module)))
+
+(test-equal "maybe value serialization of the instance"
+ "port=42count=43"
+ (config-with-maybe-number->string
+ (config-with-maybe-number
+ (port 42)
+ (count 43))))
+
+(test-equal "maybe value serialization of the instance, unspecified"
+ "port=42"
+ (config-with-maybe-number->string
+ (config-with-maybe-number
+ (port 42))))
+
(define-maybe/no-serialization string)
(define-configuration config-with-maybe-string/no-serialization
--
2.35.1
A
A
Attila Lendvai wrote on 20 Apr 2022 11:15
[PATCH v4 2/2] services: configuration: Use *unspecified* instead of 'disabled.
(address . 54674@debbugs.gnu.org)(name . Attila Lendvai)(address . attila@lendvai.name)
20220420091553.26732-2-attila@lendvai.name
Use *unspecified* as a marker for field values that have not been set.

Rationale: 'disabled may easily clash with user values for boolean fields, is
confusing (i.e. its meaning is *not* boolean false, but unspecified) and it
also passes silently through the symbol? predicate of a field of type symbol.

* gnu/services/configuration.scm (configuration-missing-default-value):
Renamed from configuration-no-default-value.
* gnu/services/configuration.scm (define-maybe-helper): Use *unspecified*
instead of 'disabled, and make the default value optional.
* tests/services/configuration.scm ("maybe type, no default")
("maybe type, with default"): New tests.
---
gnu/home/services/desktop.scm | 12 ++---
gnu/services/authentication.scm | 82 ++++++++++++++++----------------
gnu/services/cgit.scm | 12 ++---
gnu/services/configuration.scm | 17 ++++---
gnu/services/file-sharing.scm | 24 +++++-----
gnu/services/messaging.scm | 37 +++++++-------
gnu/services/networking.scm | 12 ++---
gnu/services/pm.scm | 54 ++++++++++-----------
gnu/services/telephony.scm | 14 +++---
gnu/services/vpn.scm | 2 +-
tests/services/configuration.scm | 12 +++++
11 files changed, 144 insertions(+), 134 deletions(-)

Toggle diff (454 lines)
diff --git a/gnu/home/services/desktop.scm b/gnu/home/services/desktop.scm
index cbb9cf76da..b0f4d969b0 100644
--- a/gnu/home/services/desktop.scm
+++ b/gnu/home/services/desktop.scm
@@ -91,26 +91,26 @@ (define-configuration home-redshift-configuration
"Nighttime color temperature (kelvins).")
(daytime-brightness
- (maybe-inexact-number 'disabled)
+ maybe-inexact-number
"Daytime screen brightness, between 0.1 and 1.0.")
(nighttime-brightness
- (maybe-inexact-number 'disabled)
+ maybe-inexact-number
"Nighttime screen brightness, between 0.1 and 1.0.")
(latitude
- (maybe-inexact-number 'disabled)
+ maybe-inexact-number
"Latitude, when @code{location-provider} is @code{'manual}.")
(longitude
- (maybe-inexact-number 'disabled)
+ maybe-inexact-number
"Longitude, when @code{location-provider} is @code{'manual}.")
(dawn-time
- (maybe-string 'disabled)
+ maybe-string
"Custom time for the transition from night to day in the
morning---@code{\"HH:MM\"} format. When specified, solar elevation is not
used to determine the daytime/nighttime period.")
(dusk-time
- (maybe-string 'disabled)
+ maybe-string
"Likewise, custom time for the transition from day to night in the
evening.")
diff --git a/gnu/services/authentication.scm b/gnu/services/authentication.scm
index cb0ef6d85a..f7becdfafb 100644
--- a/gnu/services/authentication.scm
+++ b/gnu/services/authentication.scm
@@ -218,7 +218,7 @@ (define-configuration nslcd-configuration
;; Runtime options
(threads
- (maybe-number 'disabled)
+ maybe-number
"The number of threads to start that can handle requests and perform LDAP
queries. Each thread opens a separate connection to the LDAP server. The
default is to start 5 threads.")
@@ -243,45 +243,45 @@ (define-configuration nslcd-configuration
"The list of LDAP server URIs. Normally, only the first server will be
used with the following servers as fall-back.")
(ldap-version
- (maybe-string 'disabled)
+ maybe-string
"The version of the LDAP protocol to use. The default is to use the
maximum version supported by the LDAP library.")
(binddn
- (maybe-string 'disabled)
+ maybe-string
"Specifies the distinguished name with which to bind to the directory
server for lookups. The default is to bind anonymously.")
(bindpw
- (maybe-string 'disabled)
+ maybe-string
"Specifies the credentials with which to bind. This option is only
applicable when used with binddn.")
(rootpwmoddn
- (maybe-string 'disabled)
+ maybe-string
"Specifies the distinguished name to use when the root user tries to modify
a user's password using the PAM module.")
(rootpwmodpw
- (maybe-string 'disabled)
+ maybe-string
"Specifies the credentials with which to bind if the root user tries to
change a user's password. This option is only applicable when used with
rootpwmoddn")
;; SASL authentication options
(sasl-mech
- (maybe-string 'disabled)
+ maybe-string
"Specifies the SASL mechanism to be used when performing SASL
authentication.")
(sasl-realm
- (maybe-string 'disabled)
+ maybe-string
"Specifies the SASL realm to be used when performing SASL authentication.")
(sasl-authcid
- (maybe-string 'disabled)
+ maybe-string
"Specifies the authentication identity to be used when performing SASL
authentication.")
(sasl-authzid
- (maybe-string 'disabled)
+ maybe-string
"Specifies the authorization identity to be used when performing SASL
authentication.")
(sasl-canonicalize?
- (maybe-boolean 'disabled)
+ maybe-boolean
"Determines whether the LDAP server host name should be canonicalised. If
this is enabled the LDAP library will do a reverse host name lookup. By
default, it is left up to the LDAP library whether this check is performed or
@@ -289,7 +289,7 @@ (define-configuration nslcd-configuration
;; Kerberos authentication options
(krb5-ccname
- (maybe-string 'disabled)
+ maybe-string
"Set the name for the GSS-API Kerberos credentials cache.")
;; Search / mapping options
@@ -302,11 +302,11 @@ (define-configuration nslcd-configuration
default scope is subtree; base scope is almost never useful for name service
lookups; children scope is not supported on all servers.")
(deref
- (maybe-deref-option 'disabled)
+ maybe-deref-option
"Specifies the policy for dereferencing aliases. The default policy is to
never dereference aliases.")
(referrals
- (maybe-boolean 'disabled)
+ maybe-boolean
"Specifies whether automatic referral chasing should be enabled. The
default behaviour is to chase referrals.")
(maps
@@ -322,132 +322,132 @@ (define-configuration nslcd-configuration
;; Timing / reconnect options
(bind-timelimit
- (maybe-number 'disabled)
+ maybe-number
"Specifies the time limit in seconds to use when connecting to the
directory server. The default value is 10 seconds.")
(timelimit
- (maybe-number 'disabled)
+ maybe-number
"Specifies the time limit (in seconds) to wait for a response from the LDAP
server. A value of zero, which is the default, is to wait indefinitely for
searches to be completed.")
(idle-timelimit
- (maybe-number 'disabled)
+ maybe-number
"Specifies the period if inactivity (in seconds) after which the con?
nection to the LDAP server will be closed. The default is not to time out
connections.")
(reconnect-sleeptime
- (maybe-number 'disabled)
+ maybe-number
"Specifies the number of seconds to sleep when connecting to all LDAP
servers fails. By default one second is waited between the first failure and
the first retry.")
(reconnect-retrytime
- (maybe-number 'disabled)
+ maybe-number
"Specifies the time after which the LDAP server is considered to be
permanently unavailable. Once this time is reached retries will be done only
once per this time period. The default value is 10 seconds.")
;; TLS options
(ssl
- (maybe-ssl-option 'disabled)
+ maybe-ssl-option
"Specifies whether to use SSL/TLS or not (the default is not to). If
'start-tls is specified then StartTLS is used rather than raw LDAP over SSL.")
(tls-reqcert
- (maybe-tls-reqcert-option 'disabled)
+ maybe-tls-reqcert-option
"Specifies what checks to perform on a server-supplied certificate.
The meaning of the values is described in the ldap.conf(5) manual page.")
(tls-cacertdir
- (maybe-string 'disabled)
+ maybe-string
"Specifies the directory containing X.509 certificates for peer authen?
tication. This parameter is ignored when using GnuTLS.")
(tls-cacertfile
- (maybe-string 'disabled)
+ maybe-string
"Specifies the path to the X.509 certificate for peer authentication.")
(tls-randfile
- (maybe-string 'disabled)
+ maybe-string
"Specifies the path to an entropy source. This parameter is ignored when
using GnuTLS.")
(tls-ciphers
- (maybe-string 'disabled)
+ maybe-string
"Specifies the ciphers to use for TLS as a string.")
(tls-cert
- (maybe-string 'disabled)
+ maybe-string
"Specifies the path to the file containing the local certificate for client
TLS authentication.")
(tls-key
- (maybe-string 'disabled)
+ maybe-string
"Specifies the path to the file containing the private key for client TLS
authentication.")
;; Other options
(pagesize
- (maybe-number 'disabled)
+ maybe-number
"Set this to a number greater than 0 to request paged results from the LDAP
server in accordance with RFC2696. The default (0) is to not request paged
results.")
(nss-initgroups-ignoreusers
- (maybe-ignore-users-option 'disabled)
+ maybe-ignore-users-option
"This option prevents group membership lookups through LDAP for the
specified users. Alternatively, the value 'all-local may be used. With that
value nslcd builds a full list of non-LDAP users on startup.")
(nss-min-uid
- (maybe-number 'disabled)
+ maybe-number
"This option ensures that LDAP users with a numeric user id lower than the
specified value are ignored.")
(nss-uid-offset
- (maybe-number 'disabled)
+ maybe-number
"This option specifies an offset that is added to all LDAP numeric user
ids. This can be used to avoid user id collisions with local users.")
(nss-gid-offset
- (maybe-number 'disabled)
+ maybe-number
"This option specifies an offset that is added to all LDAP numeric group
ids. This can be used to avoid user id collisions with local groups.")
(nss-nested-groups
- (maybe-boolean 'disabled)
+ maybe-boolean
"If this option is set, the member attribute of a group may point to
another group. Members of nested groups are also returned in the higher level
group and parent groups are returned when finding groups for a specific user.
The default is not to perform extra searches for nested groups.")
(nss-getgrent-skipmembers
- (maybe-boolean 'disabled)
+ maybe-boolean
"If this option is set, the group member list is not retrieved when looking
up groups. Lookups for finding which groups a user belongs to will remain
functional so the user will likely still get the correct groups assigned on
login.")
(nss-disable-enumeration
- (maybe-boolean 'disabled)
+ maybe-boolean
"If this option is set, functions which cause all user/group entries to be
loaded from the directory will not succeed in doing so. This can dramatically
reduce LDAP server load in situations where there are a great number of users
and/or groups. This option is not recommended for most configurations.")
(validnames
- (maybe-string 'disabled)
+ maybe-string
"This option can be used to specify how user and group names are verified
within the system. This pattern is used to check all user and group names
that are requested and returned from LDAP.")
(ignorecase
- (maybe-boolean 'disabled)
+ maybe-boolean
"This specifies whether or not to perform searches using case-insensitive
matching. Enabling this could open up the system to authorization bypass
vulnerabilities and introduce nscd cache poisoning vulnerabilities which allow
denial of service.")
(pam-authc-ppolicy
- (maybe-boolean 'disabled)
+ maybe-boolean
"This option specifies whether password policy controls are requested and
handled from the LDAP server when performing user authentication.")
(pam-authc-search
- (maybe-string 'disabled)
+ maybe-string
"By default nslcd performs an LDAP search with the user's credentials after
BIND (authentication) to ensure that the BIND operation was successful. The
default search is a simple check to see if the user's DN exists. A search
filter can be specified that will be used instead. It should return at least
one entry.")
(pam-authz-search
- (maybe-string 'disabled)
+ maybe-string
"This option allows flexible fine tuning of the authorisation check that
should be performed. The search filter specified is executed and if any
entries match, access is granted, otherwise access is denied.")
(pam-password-prohibit-message
- (maybe-string 'disabled)
+ maybe-string
"If this option is set password modification using pam_ldap will be denied
and the specified message will be presented to the user instead. The message
can be used to direct the user to an alternative means of changing their
diff --git a/gnu/services/cgit.scm b/gnu/services/cgit.scm
index bfc89a40a4..c2c003983a 100644
--- a/gnu/services/cgit.scm
+++ b/gnu/services/cgit.scm
@@ -241,27 +241,27 @@ (define-configuration repository-cgit-configuration
(repo-file-object "")
"Override the default @code{email-filter}.")
(enable-commit-graph?
- (maybe-repo-boolean 'disabled)
+ maybe-repo-boolean
"A flag which can be used to disable the global setting
@code{enable-commit-graph?}.")
(enable-log-filecount?
- (maybe-repo-boolean 'disabled)
+ maybe-repo-boolean
"A flag which can be used to disable the global setting
@code{enable-log-filecount?}.")
(enable-log-linecount?
- (maybe-repo-boolean 'disabled)
+ maybe-repo-boolean
"A flag which can be used to disable the global setting
@code{enable-log-linecount?}.")
(enable-remote-branches?
- (maybe-repo-boolean 'disabled)
+ maybe-repo-boolean
"Flag which, when set to @code{#t}, will make cgit display remote
branches in the summary and refs views.")
(enable-subject-links?
- (maybe-repo-boolean 'disabled)
+ maybe-repo-boolean
"A flag which can be used to override the global setting
@code{enable-subject-links?}.")
(enable-html-serving?
- (maybe-repo-boolean 'disabled)
+ maybe-repo-boolean
"A flag which can be used to override the global setting
@code{enable-html-serving?}.")
(hide?
diff --git a/gnu/services/configuration.scm b/gnu/services/configuration.scm
index bdca33ed68..f6b20fb82b 100644
--- a/gnu/services/configuration.scm
+++ b/gnu/services/configuration.scm
@@ -93,7 +93,7 @@ (define (configuration-field-error field val)
(define (configuration-missing-field kind field)
(configuration-error
(format #f "~a configuration missing required field ~a" kind field)))
-(define (configuration-no-default-value kind field)
+(define (configuration-missing-default-value kind field)
(configuration-error
(format #f "The field `~a' of the `~a' configuration record \
does not have a default value" field kind)))
@@ -142,7 +142,8 @@ (define (define-maybe-helper serialize? prefix syn)
(id #'stem #'serialize-maybe- #'stem))))
#`(begin
(define (maybe-stem? val)
- (or (eq? val 'disabled) (stem? val)))
+ (or (unspecified? val)
+ (stem? val)))
#,@(if serialize?
(list #'(define (serialize-maybe-stem field-name val)
(if (stem? val)
@@ -170,10 +171,10 @@ (define (normalize-field-type+def s)
(values #'(field-type def)))
((field-type)
(identifier? #'field-type)
- (values #'(field-type 'disabled)))
+ (values #'(field-type *unspecified*)))
(field-type
(identifier? #'field-type)
- (values #'(field-type 'disabled)))))
+ (values #'(field-type *unspecified*)))))
(define (define-configuration-helper serialize? serializer-prefix syn)
(syntax-case syn ()
@@ -219,9 +220,7 @@ (define-record-type* #,(id #'stem #'< #'stem #'>)
source-properties->location))
(innate))
#,@(map (lambda (name getter def)
- (if (eq? (syntax->datum def) (quote 'undefined))
- #`(#,name #,getter)
- #`(#,name #,getter (default #,def))))
+ #`(#,name #,getter (default #,def)))
#'(field ...)
#'(field-getter ...)
#'(field-default ...)))
@@ -236,8 +235,8 @@ (define #,(id #'stem #'stem #'-fields)
(lambda ()
(display '#,(id #'stem #'% #'stem))
(if (eq? (syntax->datum field-default)
- 'undefined)
- (configuration-no-default-value
+ '*unspecified*)
+ (configuration-missing-default-value
'#,(id #'stem #'% #'stem) 'field)
field-default)))
(documentation doc))
diff --git a/gnu/services/file-sharing.scm b/gnu/services/file-sharing.scm
index e3d681b08f..e32d1f145d 100644
--- a/gnu/services/file-sharing.scm
+++ b/gnu/services/file-sharing.scm
@@ -115,8 +115,7 @@ (define-maybe string)
(set! serialize-maybe-string
(lambda (field-name val)
(serialize-string field-name
- (if (and (symbol? val)
- (eq? val 'disabled))
+ (if (unspecified? val)
""
val))))
@@ -181,8 +180,7 @@ (define (serialize-file-object field-name val)
(define-maybe file-object)
(set! serialize-maybe-file-object
(lambda (field-name val)
- (if (and (symbol? val)
- (eq? val 'disabled))
+ (if (unspecified? val)
(serialize-string field-name "")
(serialize-file-object field-name val))))
@@ -281,7 +279,7 @@ (define-configuration transmission-daemon-configuration
torrent is complete. Otherwise, files for all torrents (including those still
being downloaded) will be placed in @code{download-dir}.")
(incomplete-dir
- (maybe-string 'disabled)
+ maybe-string
"The directory in which files from incompletely downloaded torrents will be
held when @code{incomplete-dir-enabled?} is @code{#t}.")
(umask
@@ -305,7 +303,7 @@ (define-configuration transmission-daemon-configuration
automatically (and the original files removed, if
@code{trash-original-torrent-files?} is @code{#t}).")
(watch-dir
- (maybe-string 'disabled)
+ maybe-string
"The directory to be watched for @file{.torrent} files indicating new
torrents to be added, when @code{watch-dir-enabled} is @code{#t}.")
(trash-original-torrent-files?
@@ -401,11 +399,11 @@ (define-configuration transmission-daemon-configuration
@code{prefer-unencrypted-connections}, @code{prefer-encrypted-connections} or
@code{require-encrypted-connections}.")
(peer-congestion-algorithm
- (maybe-string 'disabled)
+ maybe-string
"The TCP congestion-control algorithm to use for peer connections,
specified using a string recognized by the operating system in calls to
-@code{setsockopt} (or set to @code{disabled}, in which case the
-operating-system default is used).
+@code{setsockopt} (or leave it unset, in which case the operating-system
+default is used).
Note that on GNU/Linux systems, the kernel must be configured to allow
processes to use a congestion-control algorithm not in the default set;
@@ -465,7 +463,7 @@ (define-configuration transmission-daemon-configuration
"When @code{#t}, the daemon will ignore peers mentioned in the blocklist it
has most recently downloaded from @code{blocklist-url}.")
(blocklist-url
- (maybe-string 'disabled)
+ maybe-string
"The URL of a peer blocklist (in @acronym{P2P}-plaintext or eMule
@file{.dat} format) to be periodically downloaded and applied when
@code{blocklist-enabled?} is @code{#t}.")
@@ -564,11 +562,11 @@ (define-configuration transmission-daemon-configuration
the side effect of disabling host-name whitelisting (see
@code{rpc-
This message was truncated. Download the full message here.
M
M
Maxime Devos wrote on 23 Apr 2022 16:55
Re: [bug#54674] [PATCH v4 1/2] services: configuration: Support (field1 maybe-number "") format.
813b73d348bd7de3e19573f5e4261da2120711c0.camel@telenet.be
I didn't look into the code in detail, but for this kind of thing,
if it compiles, it probably works. For completeness, you might want to
run a few system tests (‘make check-system’ IIRC).

However, ...

Attila Lendvai schreef op wo 20-04-2022 om 11:15 [+0200]:
Toggle quote (14 lines)
> As opposed to explicitly using 'disabled as value, or using the
> (field1 (maybe-number) "") format.
>
> It's mostly the work of Maxime Devos shared under #54674, with some
> modifications by Attila Lendvai.
>
> * gnu/services/configuration.scm (normalize-field-type+def): New function.
> (define-configuration-helper) (define-configuration): Support new field
> format.
> * tests/services/configuration.scm (config-with-maybe-number->string): New
> function.
> ("maybe value serialization of the instance"): New test.
> ("maybe value serialization of the instance, unspecified"): New test.

... 'define-configuration' and 'disabled' is documented in the manual
(guix)Complex Configurations:

When defining a “maybe type”, the corresponding serializer for the
regular type will be used by default. For example, a field of
type ‘maybe-string’ will be serialized using the
‘serialize-string’ procedure by default, you can of course change
this by specifying a custom serializer procedure. Likewise, the
type of the value would have to be a string, unless it is set to
the ‘disabled’ symbol.

It also appears in other locations in the documentation:

‘daytime-brightness’ (default: ‘disabled’) (type: maybe-inexact-number)
Daytime screen brightness, between 0.1 and 1.0.

The available configuration parameters follow. Each parameter
definition is preceded by its type; for example, ‘string-list foo’
indicates that the ‘foo’ parameter should be specified as a list of
strings. Types starting with ‘maybe-’ denote parameters that won’t show
up in ‘prosody.cfg.lua’ when their value is ‘'disabled’.

[...]

So the documentation appears to be needed to be changed as well.

Greetings,
Maxime.
-----BEGIN PGP SIGNATURE-----

iI0EABYKADUWIQTB8z7iDFKP233XAR9J4+4iGRcl7gUCYmQTYxccbWF4aW1lZGV2
b3NAdGVsZW5ldC5iZQAKCRBJ4+4iGRcl7mIUAQDFuL+3LYJEbYvQSkmLu4z1kwjz
LsD+us5fzeWQk2Hu0QD/aGbHFKHxpWBiCsqmNi7Wwz5rOTdMiyiqZAVT2VrW2gQ=
=Pbj/
-----END PGP SIGNATURE-----


A
A
Attila Lendvai wrote on 25 Apr 2022 00:41
[PATCH] doc: Follow the 'disabled -> *unspecified* configuration refactor.
(address . 54674@debbugs.gnu.org)(name . Attila Lendvai)(address . attila@lendvai.name)
20220424224124.6823-1-attila@lendvai.name
---

update the doc in a separate commit. you may want to squash it on the
refactor commit, depending on what trade off the project prefers.

doc/guix.texi | 85 ++++++++++++++++++++++++++-------------------------
1 file changed, 43 insertions(+), 42 deletions(-)

Toggle diff (243 lines)
diff --git a/doc/guix.texi b/doc/guix.texi
index a865b2e2e4..ac1b4d1d37 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -18623,15 +18623,16 @@ The node host name that is used to make the first connection to the
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
-bootsrapping by setting this to the @code{'disabled} symbol.
+bootsrapping by explicitly setting this to the @code{*unspecified*}
+value.
Defaults to @samp{"bootstrap.jami.net:4222"}.
@end deftypevr
@deftypevr {@code{opendht-configuration} parameter} maybe-number port
-The UDP port to bind to. When set to @code{'disabled}, an available
-port is automatically selected.
+The UDP port to bind to. When explicitly set to @code{*unspecified*},
+an available port is automatically selected.
Defaults to @samp{4222}.
@@ -24396,7 +24397,7 @@ The available configuration parameters follow. Each parameter
definition is preceded by its type; for example, @samp{string-list foo}
indicates that the @code{foo} parameter should be specified as a list of
strings. Types starting with @code{maybe-} denote parameters that won't
-show up in @code{prosody.cfg.lua} when their value is @code{'disabled}.
+show up in @code{prosody.cfg.lua} when their value is left unspecified.
There is also a way to specify the configuration as a string, if you
have an old @code{prosody.cfg.lua} file that you want to port over from
@@ -25010,7 +25011,7 @@ Whether to enable debug level messages.
@item @code{auto-answer?} (default: @code{#f}) (type: boolean)
Whether to force automatic answer to incoming calls.
-@item @code{accounts} (default: @code{disabled}) (type: maybe-jami-account-list)
+@item @code{accounts} (type: maybe-jami-account-list)
A list of Jami accounts to be (re-)provisioned every time the Jami
daemon service starts. When providing this field, the account
directories under @file{/var/lib/jami/} are recreated every time the
@@ -25032,39 +25033,39 @@ should @emph{not} be encrypted. It is highly recommended to make it
readable only to the @samp{root} user (i.e., not in the store), to guard
against leaking the secret key material of the Jami account it contains.
-@item @code{allowed-contacts} (default: @code{disabled}) (type: maybe-account-fingerprint-list)
+@item @code{allowed-contacts} (type: maybe-account-fingerprint-list)
The list of allowed contacts for the account, entered as their 40
characters long fingerprint. Messages or calls from accounts not in
-that list will be rejected. When unspecified, the configuration of the
-account archive is used as-is with respect to contacts and public
+that list will be rejected. When left specified, the configuration of
+the account archive is used as-is with respect to contacts and public
inbound calls/messaging allowance, which typically defaults to allow any
contact to communicate with the account.
-@item @code{moderators} (default: @code{disabled}) (type: maybe-account-fingerprint-list)
+@item @code{moderators} (type: maybe-account-fingerprint-list)
The list of contacts that should have moderation privileges (to ban,
mute, etc. other users) in rendezvous conferences, entered as their 40
-characters long fingerprint. When unspecified, the configuration of the
-account archive is used as-is with respect to moderation, which
+characters long fingerprint. When left unspecified, the configuration
+of the account archive is used as-is with respect to moderation, which
typically defaults to allow anyone to moderate.
-@item @code{rendezvous-point?} (default: @code{disabled}) (type: maybe-boolean)
+@item @code{rendezvous-point?} (type: maybe-boolean)
Whether the account should operate in the rendezvous mode. In this
mode, all the incoming audio/video calls are mixed into a conference.
When left unspecified, the value from the account archive prevails.
-@item @code{peer-discovery?} (default: @code{disabled}) (type: maybe-boolean)
+@item @code{peer-discovery?} (type: maybe-boolean)
Whether peer discovery should be enabled. Peer discovery is used to
discover other OpenDHT nodes on the local network, which can be useful
to maintain communication between devices on such network even when the
connection to the the Internet has been lost. When left unspecified,
the value from the account archive prevails.
-@item @code{bootstrap-hostnames} (default: @code{disabled}) (type: maybe-string-list)
+@item @code{bootstrap-hostnames} (type: maybe-string-list)
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.
-@item @code{name-server-uri} (default: @code{disabled}) (type: maybe-string)
+@item @code{name-server-uri} (type: maybe-string)
The URI of the name server to use, that can be used to retrieve the
account fingerprint for a registered username.
@@ -25698,8 +25699,8 @@ Defaults to @samp{prefer-encrypted-connections}.
@deftypevr {@code{transmission-daemon-configuration} parameter} maybe-string peer-congestion-algorithm
The TCP congestion-control algorithm to use for peer connections,
specified using a string recognized by the operating system in calls to
-@code{setsockopt} (or set to @code{disabled}, in which case the
-operating-system default is used).
+@code{setsockopt}. When left unspecified, the operating-system default
+is used.
Note that on GNU/Linux systems, the kernel must be configured to allow
processes to use a congestion-control algorithm not in the default set;
@@ -29327,7 +29328,7 @@ Defaults to @samp{tun}.
If you do not have some of these files (eg.@: you use a username and
password), you can disable any of the following three fields by setting
-it to @code{'disabled}.
+it to @code{*unspecified*}.
@deftypevr {@code{openvpn-client-configuration} parameter} maybe-string ca
The certificate authority to check connections against.
@@ -29401,7 +29402,6 @@ Authenticate with server using username/password. The option is a file
containing username/password on 2 lines. Do not use a file-like object as it
would be added to the store and readable by any user.
-Defaults to @samp{'disabled}.
@end deftypevr
@deftypevr {@code{openvpn-client-configuration} parameter} key-usage verify-key-usage?
@@ -29482,7 +29482,7 @@ Defaults to @samp{tun}.
If you do not have some of these files (eg.@: you use a username and
password), you can disable any of the following three fields by setting
-it to @code{'disabled}.
+it to @code{*unspecified*}.
@deftypevr {@code{openvpn-server-configuration} parameter} maybe-string ca
The certificate authority to check connections against.
@@ -30281,10 +30281,10 @@ content by adding a valid @code{tlp-configuration}:
@end deffn
Each parameter definition is preceded by its type; for example,
-@samp{boolean foo} indicates that the @code{foo} parameter
-should be specified as a boolean. Types starting with
-@code{maybe-} denote parameters that won't show up in TLP config file
-when their value is @code{'disabled}.
+@samp{boolean foo} indicates that the @code{foo} parameter should be
+specified as a boolean. Types starting with @code{maybe-} denote
+parameters that won't show up in TLP config file when their value is
+left unset, or is explicitly set to the @code{*unspecified*} value.
@c The following documentation was initially generated by
@c (generate-tlp-documentation) in (gnu services pm). Manually maintained
@@ -37840,15 +37840,16 @@ macro which is a shorthand of this.
@deffn {Scheme Syntax} define-maybe @var{type}
Sometimes a field should not be serialized if the user doesn’t specify a
value. To achieve this, you can use the @code{define-maybe} macro to
-define a ``maybe type''; if the value of a maybe type is set to the
-@code{disabled}, it will not be serialized.
+define a ``maybe type''; if the value of a maybe type is left unset, or
+is set to the @code{*unspecified*} value, then it will not be
+serialized.
When defining a ``maybe type'', the corresponding serializer for the
regular type will be used by default. For example, a field of type
@code{maybe-string} will be serialized using the @code{serialize-string}
procedure by default, you can of course change this by specifying a
custom serializer procedure. Likewise, the type of the value would have
-to be a string, unless it is set to the @code{disabled} symbol.
+to be a string, or left unspecified.
@lisp
(define-maybe string)
@@ -37858,9 +37859,9 @@ to be a string, unless it is set to the @code{disabled} symbol.
(define-configuration baz-configuration
(name
- ;; Nothing will be serialized by default. If set to a string, the
- ;; `serialize-string' procedure will be used to serialize the string.
- (maybe-string 'disabled)
+ ;; If set to a string, the `serialize-string' procedure will be used
+ ;; to serialize the string. Otherwise this field is not serialized.
+ maybe-string ; equivalent to (maybe-string *unspecified*)
"The name of this module."))
@end lisp
@@ -37877,7 +37878,7 @@ serializer name by using the @code{prefix} literal.
There is also the @code{no-serialization} literal, which when set means
that no serializer will be defined for the ``maybe type'', regardless of
-its value is @code{disabled} or not.
+whether its value is set or not.
@code{define-maybe/no-serialization} is a shorthand for specifying the
@code{no-serialization} literal.
@@ -37886,7 +37887,7 @@ its value is @code{disabled} or not.
(define-configuration/no-serialization test-configuration
(mode
- (maybe-symbol 'disabled)
+ maybe-symbol
"Docstring."))
@end lisp
@end deffn
@@ -38018,10 +38019,10 @@ Below is an example of a record type created using
"The name of the contact."
serialize-contact-name)
(phone-number
- (maybe-integer 'disabled)
+ maybe-integer
"The person's phone number.")
(email
- (maybe-string 'disabled)
+ maybe-string
"The person's email address.")
(married?
(boolean)
@@ -38745,24 +38746,24 @@ Daytime color temperature (kelvins).
@item @code{nighttime-temperature} (default: @code{4500}) (type: integer)
Nighttime color temperature (kelvins).
-@item @code{daytime-brightness} (default: @code{disabled}) (type: maybe-inexact-number)
-Daytime screen brightness, between 0.1 and 1.0.
+@item @code{daytime-brightness} (type: maybe-inexact-number)
+Daytime screen brightness, between 0.1 and 1.0, or left unspecified.
-@item @code{nighttime-brightness} (default: @code{disabled}) (type: maybe-inexact-number)
-Nighttime screen brightness, between 0.1 and 1.0.
+@item @code{nighttime-brightness} (type: maybe-inexact-number)
+Nighttime screen brightness, between 0.1 and 1.0, or left unspecified.
-@item @code{latitude} (default: @code{disabled}) (type: maybe-inexact-number)
+@item @code{latitude} (type: maybe-inexact-number)
Latitude, when @code{location-provider} is @code{'manual}.
-@item @code{longitude} (default: @code{disabled}) (type: maybe-inexact-number)
+@item @code{longitude} (type: maybe-inexact-number)
Longitude, when @code{location-provider} is @code{'manual}.
-@item @code{dawn-time} (default: @code{disabled}) (type: maybe-string)
+@item @code{dawn-time} (type: maybe-string)
Custom time for the transition from night to day in the
morning---@code{"HH:MM"} format. When specified, solar elevation is not
used to determine the daytime/nighttime period.
-@item @code{dusk-time} (default: @code{disabled}) (type: maybe-string)
+@item @code{dusk-time} (type: maybe-string)
Likewise, custom time for the transition from day to night in the
evening.
--
2.35.1
A
A
Attila Lendvai wrote on 17 May 2022 13:38
Re: [bug#54674] [PATCH v4 1/2] services: configuration: Support (field1 maybe-number "") format.
(address . 54674@debbugs.gnu.org)
_T-G43zruF_RwIN_x5jlycFSZ3wxWqlJaJAwz2W47H8aXUUFI1XEjI8WWK-SigdA7HW8mxR-bM0xIto1mKJk7vbVkru8XtMazqOksHuc9oc=@lendvai.name
thank you for suggesting `make check-system` Maxime. it pointed out some issues with the jami service that i have fixed.

i would love to reshape this into something that will get merged. is there anything i can do to help that process?

unfortunately, `make check-system` returns with the attached output. after some staring and grepping, i can't identify why these tests are failing, and whether it is a new bug at all that happens due to my changes.

i'll send the new version of the patch in upcoming mails.

--
• attila lendvai
• PGP: 963F 5D5F 45C7 DFCD 0A39
--
“Anything that can contribute to such a fundamental change in our perception of reality must therefore command our earnest attention.”
— Albert Hofmann (1906–2008), 'LSD: My Problem Child'
A
A
Attila Lendvai wrote on 17 May 2022 13:39
[PATCH v5 1/3] services: configuration: Support (field1 maybe-number "") format.
(address . 54674@debbugs.gnu.org)(name . Attila Lendvai)(address . attila@lendvai.name)
20220517113926.3931-1-attila@lendvai.name
As opposed to explicitly using 'disabled as value, or using the
(field1 (maybe-number) "") format.

It's mostly the work of Maxime Devos shared under #54674, with some
modifications by Attila Lendvai.

* gnu/services/configuration.scm (normalize-field-type+def): New function.
(define-configuration-helper) (define-configuration): Support new field
format.
* tests/services/configuration.scm (config-with-maybe-number->string): New
function.
("maybe value serialization of the instance"): New test.
("maybe value serialization of the instance, unspecified"): New test.
---

v5 fixes some jami issues

gnu/services/configuration.scm | 169 +++++++++++++++++--------------
tests/services/configuration.scm | 28 ++++-
2 files changed, 114 insertions(+), 83 deletions(-)

Toggle diff (268 lines)
diff --git a/gnu/services/configuration.scm b/gnu/services/configuration.scm
index 0de350a4df..bdca33ed68 100644
--- a/gnu/services/configuration.scm
+++ b/gnu/services/configuration.scm
@@ -5,6 +5,7 @@
;;; Copyright © 2021 Xinglu Chen <public@yoctocell.xyz>
;;; Copyright © 2021 Maxim Cournoyer <maxim.cournoyer@gmail.com>
;;; Copyright © 2021 Andrew Tropin <andrew@trop.in>
+;;; Copyright © 2022 Maxime Devos <maximedevos@telenet.be>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -162,78 +163,90 @@ (define-maybe-helper #t #f #'(_ stem))))))
(define-syntax-rule (define-maybe/no-serialization stem)
(define-maybe stem (no-serialization)))
+(define (normalize-field-type+def s)
+ (syntax-case s ()
+ ((field-type def)
+ (identifier? #'field-type)
+ (values #'(field-type def)))
+ ((field-type)
+ (identifier? #'field-type)
+ (values #'(field-type 'disabled)))
+ (field-type
+ (identifier? #'field-type)
+ (values #'(field-type 'disabled)))))
+
(define (define-configuration-helper serialize? serializer-prefix syn)
(syntax-case syn ()
- ((_ stem (field (field-type def ...) doc custom-serializer ...) ...)
- (with-syntax (((field-getter ...)
- (map (lambda (field)
- (id #'stem #'stem #'- field))
- #'(field ...)))
- ((field-predicate ...)
- (map (lambda (type)
- (id #'stem type #'?))
- #'(field-type ...)))
- ((field-default ...)
- (map (match-lambda
- ((field-type default-value)
- default-value)
- ((field-type)
- ;; Quote `undefined' to prevent a possibly
- ;; unbound warning.
- (syntax 'undefined)))
- #'((field-type def ...) ...)))
- ((field-serializer ...)
- (map (lambda (type custom-serializer)
- (and serialize?
- (match custom-serializer
- ((serializer)
- serializer)
- (()
- (if serializer-prefix
- (id #'stem
- serializer-prefix
- #'serialize- type)
- (id #'stem #'serialize- type))))))
- #'(field-type ...)
- #'((custom-serializer ...) ...))))
- #`(begin
- (define-record-type* #,(id #'stem #'< #'stem #'>)
- #,(id #'stem #'% #'stem)
- #,(id #'stem #'make- #'stem)
- #,(id #'stem #'stem #'?)
- (%location #,(id #'stem #'stem #'-location)
- (default (and=> (current-source-location)
- source-properties->location))
- (innate))
- #,@(map (lambda (name getter def)
- (if (eq? (syntax->datum def) (quote 'undefined))
- #`(#,name #,getter)
- #`(#,name #,getter (default #,def))))
- #'(field ...)
- #'(field-getter ...)
- #'(field-default ...)))
- (define #,(id #'stem #'stem #'-fields)
- (list (configuration-field
- (name 'field)
- (type 'field-type)
- (getter field-getter)
- (predicate field-predicate)
- (serializer field-serializer)
- (default-value-thunk
- (lambda ()
- (display '#,(id #'stem #'% #'stem))
- (if (eq? (syntax->datum field-default)
- 'undefined)
- (configuration-no-default-value
- '#,(id #'stem #'% #'stem) 'field)
- field-default)))
- (documentation doc))
- ...))
- (define-syntax-rule (stem arg (... ...))
- (let ((conf (#,(id #'stem #'% #'stem) arg (... ...))))
- (validate-configuration conf
- #,(id #'stem #'stem #'-fields))
- conf)))))))
+ ((_ stem (field field-type+def doc custom-serializer ...) ...)
+ (with-syntax
+ ((((field-type def) ...)
+ (map normalize-field-type+def #'(field-type+def ...))))
+ (with-syntax
+ (((field-getter ...)
+ (map (lambda (field)
+ (id #'stem #'stem #'- field))
+ #'(field ...)))
+ ((field-predicate ...)
+ (map (lambda (type)
+ (id #'stem type #'?))
+ #'(field-type ...)))
+ ((field-default ...)
+ (map (match-lambda
+ ((field-type default-value)
+ default-value))
+ #'((field-type def) ...)))
+ ((field-serializer ...)
+ (map (lambda (type custom-serializer)
+ (and serialize?
+ (match custom-serializer
+ ((serializer)
+ serializer)
+ (()
+ (if serializer-prefix
+ (id #'stem
+ serializer-prefix
+ #'serialize- type)
+ (id #'stem #'serialize- type))))))
+ #'(field-type ...)
+ #'((custom-serializer ...) ...))))
+ #`(begin
+ (define-record-type* #,(id #'stem #'< #'stem #'>)
+ #,(id #'stem #'% #'stem)
+ #,(id #'stem #'make- #'stem)
+ #,(id #'stem #'stem #'?)
+ (%location #,(id #'stem #'stem #'-location)
+ (default (and=> (current-source-location)
+ source-properties->location))
+ (innate))
+ #,@(map (lambda (name getter def)
+ (if (eq? (syntax->datum def) (quote 'undefined))
+ #`(#,name #,getter)
+ #`(#,name #,getter (default #,def))))
+ #'(field ...)
+ #'(field-getter ...)
+ #'(field-default ...)))
+ (define #,(id #'stem #'stem #'-fields)
+ (list (configuration-field
+ (name 'field)
+ (type 'field-type)
+ (getter field-getter)
+ (predicate field-predicate)
+ (serializer field-serializer)
+ (default-value-thunk
+ (lambda ()
+ (display '#,(id #'stem #'% #'stem))
+ (if (eq? (syntax->datum field-default)
+ 'undefined)
+ (configuration-no-default-value
+ '#,(id #'stem #'% #'stem) 'field)
+ field-default)))
+ (documentation doc))
+ ...))
+ (define-syntax-rule (stem arg (... ...))
+ (let ((conf (#,(id #'stem #'% #'stem) arg (... ...))))
+ (validate-configuration conf
+ #,(id #'stem #'stem #'-fields))
+ conf))))))))
(define no-serialization ;syntactic keyword for 'define-configuration'
'(no serialization))
@@ -241,26 +254,26 @@ (define no-serialization ;syntactic keyword for 'define-configuration'
(define-syntax define-configuration
(lambda (s)
(syntax-case s (no-serialization prefix)
- ((_ stem (field (field-type def ...) doc custom-serializer ...) ...
+ ((_ stem (field field-type+def doc custom-serializer ...) ...
(no-serialization))
(define-configuration-helper
- #f #f #'(_ stem (field (field-type def ...) doc custom-serializer ...)
+ #f #f #'(_ stem (field field-type+def doc custom-serializer ...)
...)))
- ((_ stem (field (field-type def ...) doc custom-serializer ...) ...
+ ((_ stem (field field-type+def doc custom-serializer ...) ...
(prefix serializer-prefix))
(define-configuration-helper
- #t #'serializer-prefix #'(_ stem (field (field-type def ...)
+ #t #'serializer-prefix #'(_ stem (field field-type+def
doc custom-serializer ...)
...)))
- ((_ stem (field (field-type def ...) doc custom-serializer ...) ...)
+ ((_ stem (field field-type+def doc custom-serializer ...) ...)
(define-configuration-helper
- #t #f #'(_ stem (field (field-type def ...) doc custom-serializer ...)
+ #t #f #'(_ stem (field field-type+def doc custom-serializer ...)
...))))))
(define-syntax-rule (define-configuration/no-serialization
- stem (field (field-type def ...)
+ stem (field field-type+def
doc custom-serializer ...) ...)
- (define-configuration stem (field (field-type def ...)
+ (define-configuration stem (field field-type+def
doc custom-serializer ...) ...
(no-serialization)))
diff --git a/tests/services/configuration.scm b/tests/services/configuration.scm
index 86a36a388d..0debf8095b 100644
--- a/tests/services/configuration.scm
+++ b/tests/services/configuration.scm
@@ -27,6 +27,9 @@ (define-module (tests services configuration)
(test-begin "services-configuration")
+(define (serialize-number field value)
+ (format #f "~a=~a" field value))
+
;;;
;;; define-configuration macro.
@@ -47,7 +50,6 @@ (define-configuration port-configuration-cs
80
(port-configuration-cs-port (port-configuration-cs)))
-(define serialize-number "")
(define-configuration port-configuration-ndv
(port (number) "The port number."))
@@ -101,15 +103,31 @@ (define-configuration configuration-with-prefix
(define-maybe number)
(define-configuration config-with-maybe-number
- (port (maybe-number 80) "The port number."))
-
-(define (serialize-number field value)
- (format #f "~a=~a" field value))
+ (port (maybe-number 80) "")
+ (count maybe-number ""))
(test-equal "maybe value serialization"
"port=80"
(serialize-maybe-number "port" 80))
+(define (config-with-maybe-number->string x)
+ (eval (gexp->approximate-sexp
+ (serialize-configuration x config-with-maybe-number-fields))
+ (current-module)))
+
+(test-equal "maybe value serialization of the instance"
+ "port=42count=43"
+ (config-with-maybe-number->string
+ (config-with-maybe-number
+ (port 42)
+ (count 43))))
+
+(test-equal "maybe value serialization of the instance, unspecified"
+ "port=42"
+ (config-with-maybe-number->string
+ (config-with-maybe-number
+ (port 42))))
+
(define-maybe/no-serialization string)
(define-configuration config-with-maybe-string/no-serialization
--
2.35.1
A
A
Attila Lendvai wrote on 17 May 2022 13:39
[PATCH v5 2/3] services: configuration: Use *unspecified* instead of 'disabled.
(address . 54674@debbugs.gnu.org)(name . Attila Lendvai)(address . attila@lendvai.name)
20220517113926.3931-2-attila@lendvai.name
Use *unspecified* as a marker for field values that have not been set.

Rationale: 'disabled may easily clash with user values for boolean fields, is
confusing (i.e. its meaning is *not* boolean false, but unspecified) and it
also passes silently through the symbol? predicate of a field of type symbol.

* gnu/services/configuration.scm (configuration-missing-default-value):
Renamed from configuration-no-default-value.
* gnu/services/configuration.scm (define-maybe-helper): Use *unspecified*
instead of 'disabled, and make the default value optional.
* tests/services/configuration.scm ("maybe type, no default")
("maybe type, with default"): New tests.
---
gnu/home/services/desktop.scm | 12 ++---
gnu/services/authentication.scm | 82 ++++++++++++++++----------------
gnu/services/cgit.scm | 12 ++---
gnu/services/configuration.scm | 17 ++++---
gnu/services/file-sharing.scm | 24 +++++-----
gnu/services/messaging.scm | 37 +++++++-------
gnu/services/networking.scm | 12 ++---
gnu/services/pm.scm | 54 ++++++++++-----------
gnu/services/telephony.scm | 22 ++++-----
gnu/services/vpn.scm | 2 +-
tests/services/configuration.scm | 12 +++++
11 files changed, 148 insertions(+), 138 deletions(-)

Toggle diff (454 lines)
diff --git a/gnu/home/services/desktop.scm b/gnu/home/services/desktop.scm
index cbb9cf76da..b0f4d969b0 100644
--- a/gnu/home/services/desktop.scm
+++ b/gnu/home/services/desktop.scm
@@ -91,26 +91,26 @@ (define-configuration home-redshift-configuration
"Nighttime color temperature (kelvins).")
(daytime-brightness
- (maybe-inexact-number 'disabled)
+ maybe-inexact-number
"Daytime screen brightness, between 0.1 and 1.0.")
(nighttime-brightness
- (maybe-inexact-number 'disabled)
+ maybe-inexact-number
"Nighttime screen brightness, between 0.1 and 1.0.")
(latitude
- (maybe-inexact-number 'disabled)
+ maybe-inexact-number
"Latitude, when @code{location-provider} is @code{'manual}.")
(longitude
- (maybe-inexact-number 'disabled)
+ maybe-inexact-number
"Longitude, when @code{location-provider} is @code{'manual}.")
(dawn-time
- (maybe-string 'disabled)
+ maybe-string
"Custom time for the transition from night to day in the
morning---@code{\"HH:MM\"} format. When specified, solar elevation is not
used to determine the daytime/nighttime period.")
(dusk-time
- (maybe-string 'disabled)
+ maybe-string
"Likewise, custom time for the transition from day to night in the
evening.")
diff --git a/gnu/services/authentication.scm b/gnu/services/authentication.scm
index cb0ef6d85a..f7becdfafb 100644
--- a/gnu/services/authentication.scm
+++ b/gnu/services/authentication.scm
@@ -218,7 +218,7 @@ (define-configuration nslcd-configuration
;; Runtime options
(threads
- (maybe-number 'disabled)
+ maybe-number
"The number of threads to start that can handle requests and perform LDAP
queries. Each thread opens a separate connection to the LDAP server. The
default is to start 5 threads.")
@@ -243,45 +243,45 @@ (define-configuration nslcd-configuration
"The list of LDAP server URIs. Normally, only the first server will be
used with the following servers as fall-back.")
(ldap-version
- (maybe-string 'disabled)
+ maybe-string
"The version of the LDAP protocol to use. The default is to use the
maximum version supported by the LDAP library.")
(binddn
- (maybe-string 'disabled)
+ maybe-string
"Specifies the distinguished name with which to bind to the directory
server for lookups. The default is to bind anonymously.")
(bindpw
- (maybe-string 'disabled)
+ maybe-string
"Specifies the credentials with which to bind. This option is only
applicable when used with binddn.")
(rootpwmoddn
- (maybe-string 'disabled)
+ maybe-string
"Specifies the distinguished name to use when the root user tries to modify
a user's password using the PAM module.")
(rootpwmodpw
- (maybe-string 'disabled)
+ maybe-string
"Specifies the credentials with which to bind if the root user tries to
change a user's password. This option is only applicable when used with
rootpwmoddn")
;; SASL authentication options
(sasl-mech
- (maybe-string 'disabled)
+ maybe-string
"Specifies the SASL mechanism to be used when performing SASL
authentication.")
(sasl-realm
- (maybe-string 'disabled)
+ maybe-string
"Specifies the SASL realm to be used when performing SASL authentication.")
(sasl-authcid
- (maybe-string 'disabled)
+ maybe-string
"Specifies the authentication identity to be used when performing SASL
authentication.")
(sasl-authzid
- (maybe-string 'disabled)
+ maybe-string
"Specifies the authorization identity to be used when performing SASL
authentication.")
(sasl-canonicalize?
- (maybe-boolean 'disabled)
+ maybe-boolean
"Determines whether the LDAP server host name should be canonicalised. If
this is enabled the LDAP library will do a reverse host name lookup. By
default, it is left up to the LDAP library whether this check is performed or
@@ -289,7 +289,7 @@ (define-configuration nslcd-configuration
;; Kerberos authentication options
(krb5-ccname
- (maybe-string 'disabled)
+ maybe-string
"Set the name for the GSS-API Kerberos credentials cache.")
;; Search / mapping options
@@ -302,11 +302,11 @@ (define-configuration nslcd-configuration
default scope is subtree; base scope is almost never useful for name service
lookups; children scope is not supported on all servers.")
(deref
- (maybe-deref-option 'disabled)
+ maybe-deref-option
"Specifies the policy for dereferencing aliases. The default policy is to
never dereference aliases.")
(referrals
- (maybe-boolean 'disabled)
+ maybe-boolean
"Specifies whether automatic referral chasing should be enabled. The
default behaviour is to chase referrals.")
(maps
@@ -322,132 +322,132 @@ (define-configuration nslcd-configuration
;; Timing / reconnect options
(bind-timelimit
- (maybe-number 'disabled)
+ maybe-number
"Specifies the time limit in seconds to use when connecting to the
directory server. The default value is 10 seconds.")
(timelimit
- (maybe-number 'disabled)
+ maybe-number
"Specifies the time limit (in seconds) to wait for a response from the LDAP
server. A value of zero, which is the default, is to wait indefinitely for
searches to be completed.")
(idle-timelimit
- (maybe-number 'disabled)
+ maybe-number
"Specifies the period if inactivity (in seconds) after which the con?
nection to the LDAP server will be closed. The default is not to time out
connections.")
(reconnect-sleeptime
- (maybe-number 'disabled)
+ maybe-number
"Specifies the number of seconds to sleep when connecting to all LDAP
servers fails. By default one second is waited between the first failure and
the first retry.")
(reconnect-retrytime
- (maybe-number 'disabled)
+ maybe-number
"Specifies the time after which the LDAP server is considered to be
permanently unavailable. Once this time is reached retries will be done only
once per this time period. The default value is 10 seconds.")
;; TLS options
(ssl
- (maybe-ssl-option 'disabled)
+ maybe-ssl-option
"Specifies whether to use SSL/TLS or not (the default is not to). If
'start-tls is specified then StartTLS is used rather than raw LDAP over SSL.")
(tls-reqcert
- (maybe-tls-reqcert-option 'disabled)
+ maybe-tls-reqcert-option
"Specifies what checks to perform on a server-supplied certificate.
The meaning of the values is described in the ldap.conf(5) manual page.")
(tls-cacertdir
- (maybe-string 'disabled)
+ maybe-string
"Specifies the directory containing X.509 certificates for peer authen?
tication. This parameter is ignored when using GnuTLS.")
(tls-cacertfile
- (maybe-string 'disabled)
+ maybe-string
"Specifies the path to the X.509 certificate for peer authentication.")
(tls-randfile
- (maybe-string 'disabled)
+ maybe-string
"Specifies the path to an entropy source. This parameter is ignored when
using GnuTLS.")
(tls-ciphers
- (maybe-string 'disabled)
+ maybe-string
"Specifies the ciphers to use for TLS as a string.")
(tls-cert
- (maybe-string 'disabled)
+ maybe-string
"Specifies the path to the file containing the local certificate for client
TLS authentication.")
(tls-key
- (maybe-string 'disabled)
+ maybe-string
"Specifies the path to the file containing the private key for client TLS
authentication.")
;; Other options
(pagesize
- (maybe-number 'disabled)
+ maybe-number
"Set this to a number greater than 0 to request paged results from the LDAP
server in accordance with RFC2696. The default (0) is to not request paged
results.")
(nss-initgroups-ignoreusers
- (maybe-ignore-users-option 'disabled)
+ maybe-ignore-users-option
"This option prevents group membership lookups through LDAP for the
specified users. Alternatively, the value 'all-local may be used. With that
value nslcd builds a full list of non-LDAP users on startup.")
(nss-min-uid
- (maybe-number 'disabled)
+ maybe-number
"This option ensures that LDAP users with a numeric user id lower than the
specified value are ignored.")
(nss-uid-offset
- (maybe-number 'disabled)
+ maybe-number
"This option specifies an offset that is added to all LDAP numeric user
ids. This can be used to avoid user id collisions with local users.")
(nss-gid-offset
- (maybe-number 'disabled)
+ maybe-number
"This option specifies an offset that is added to all LDAP numeric group
ids. This can be used to avoid user id collisions with local groups.")
(nss-nested-groups
- (maybe-boolean 'disabled)
+ maybe-boolean
"If this option is set, the member attribute of a group may point to
another group. Members of nested groups are also returned in the higher level
group and parent groups are returned when finding groups for a specific user.
The default is not to perform extra searches for nested groups.")
(nss-getgrent-skipmembers
- (maybe-boolean 'disabled)
+ maybe-boolean
"If this option is set, the group member list is not retrieved when looking
up groups. Lookups for finding which groups a user belongs to will remain
functional so the user will likely still get the correct groups assigned on
login.")
(nss-disable-enumeration
- (maybe-boolean 'disabled)
+ maybe-boolean
"If this option is set, functions which cause all user/group entries to be
loaded from the directory will not succeed in doing so. This can dramatically
reduce LDAP server load in situations where there are a great number of users
and/or groups. This option is not recommended for most configurations.")
(validnames
- (maybe-string 'disabled)
+ maybe-string
"This option can be used to specify how user and group names are verified
within the system. This pattern is used to check all user and group names
that are requested and returned from LDAP.")
(ignorecase
- (maybe-boolean 'disabled)
+ maybe-boolean
"This specifies whether or not to perform searches using case-insensitive
matching. Enabling this could open up the system to authorization bypass
vulnerabilities and introduce nscd cache poisoning vulnerabilities which allow
denial of service.")
(pam-authc-ppolicy
- (maybe-boolean 'disabled)
+ maybe-boolean
"This option specifies whether password policy controls are requested and
handled from the LDAP server when performing user authentication.")
(pam-authc-search
- (maybe-string 'disabled)
+ maybe-string
"By default nslcd performs an LDAP search with the user's credentials after
BIND (authentication) to ensure that the BIND operation was successful. The
default search is a simple check to see if the user's DN exists. A search
filter can be specified that will be used instead. It should return at least
one entry.")
(pam-authz-search
- (maybe-string 'disabled)
+ maybe-string
"This option allows flexible fine tuning of the authorisation check that
should be performed. The search filter specified is executed and if any
entries match, access is granted, otherwise access is denied.")
(pam-password-prohibit-message
- (maybe-string 'disabled)
+ maybe-string
"If this option is set password modification using pam_ldap will be denied
and the specified message will be presented to the user instead. The message
can be used to direct the user to an alternative means of changing their
diff --git a/gnu/services/cgit.scm b/gnu/services/cgit.scm
index bfc89a40a4..c2c003983a 100644
--- a/gnu/services/cgit.scm
+++ b/gnu/services/cgit.scm
@@ -241,27 +241,27 @@ (define-configuration repository-cgit-configuration
(repo-file-object "")
"Override the default @code{email-filter}.")
(enable-commit-graph?
- (maybe-repo-boolean 'disabled)
+ maybe-repo-boolean
"A flag which can be used to disable the global setting
@code{enable-commit-graph?}.")
(enable-log-filecount?
- (maybe-repo-boolean 'disabled)
+ maybe-repo-boolean
"A flag which can be used to disable the global setting
@code{enable-log-filecount?}.")
(enable-log-linecount?
- (maybe-repo-boolean 'disabled)
+ maybe-repo-boolean
"A flag which can be used to disable the global setting
@code{enable-log-linecount?}.")
(enable-remote-branches?
- (maybe-repo-boolean 'disabled)
+ maybe-repo-boolean
"Flag which, when set to @code{#t}, will make cgit display remote
branches in the summary and refs views.")
(enable-subject-links?
- (maybe-repo-boolean 'disabled)
+ maybe-repo-boolean
"A flag which can be used to override the global setting
@code{enable-subject-links?}.")
(enable-html-serving?
- (maybe-repo-boolean 'disabled)
+ maybe-repo-boolean
"A flag which can be used to override the global setting
@code{enable-html-serving?}.")
(hide?
diff --git a/gnu/services/configuration.scm b/gnu/services/configuration.scm
index bdca33ed68..f6b20fb82b 100644
--- a/gnu/services/configuration.scm
+++ b/gnu/services/configuration.scm
@@ -93,7 +93,7 @@ (define (configuration-field-error field val)
(define (configuration-missing-field kind field)
(configuration-error
(format #f "~a configuration missing required field ~a" kind field)))
-(define (configuration-no-default-value kind field)
+(define (configuration-missing-default-value kind field)
(configuration-error
(format #f "The field `~a' of the `~a' configuration record \
does not have a default value" field kind)))
@@ -142,7 +142,8 @@ (define (define-maybe-helper serialize? prefix syn)
(id #'stem #'serialize-maybe- #'stem))))
#`(begin
(define (maybe-stem? val)
- (or (eq? val 'disabled) (stem? val)))
+ (or (unspecified? val)
+ (stem? val)))
#,@(if serialize?
(list #'(define (serialize-maybe-stem field-name val)
(if (stem? val)
@@ -170,10 +171,10 @@ (define (normalize-field-type+def s)
(values #'(field-type def)))
((field-type)
(identifier? #'field-type)
- (values #'(field-type 'disabled)))
+ (values #'(field-type *unspecified*)))
(field-type
(identifier? #'field-type)
- (values #'(field-type 'disabled)))))
+ (values #'(field-type *unspecified*)))))
(define (define-configuration-helper serialize? serializer-prefix syn)
(syntax-case syn ()
@@ -219,9 +220,7 @@ (define-record-type* #,(id #'stem #'< #'stem #'>)
source-properties->location))
(innate))
#,@(map (lambda (name getter def)
- (if (eq? (syntax->datum def) (quote 'undefined))
- #`(#,name #,getter)
- #`(#,name #,getter (default #,def))))
+ #`(#,name #,getter (default #,def)))
#'(field ...)
#'(field-getter ...)
#'(field-default ...)))
@@ -236,8 +235,8 @@ (define #,(id #'stem #'stem #'-fields)
(lambda ()
(display '#,(id #'stem #'% #'stem))
(if (eq? (syntax->datum field-default)
- 'undefined)
- (configuration-no-default-value
+ '*unspecified*)
+ (configuration-missing-default-value
'#,(id #'stem #'% #'stem) 'field)
field-default)))
(documentation doc))
diff --git a/gnu/services/file-sharing.scm b/gnu/services/file-sharing.scm
index e3d681b08f..e32d1f145d 100644
--- a/gnu/services/file-sharing.scm
+++ b/gnu/services/file-sharing.scm
@@ -115,8 +115,7 @@ (define-maybe string)
(set! serialize-maybe-string
(lambda (field-name val)
(serialize-string field-name
- (if (and (symbol? val)
- (eq? val 'disabled))
+ (if (unspecified? val)
""
val))))
@@ -181,8 +180,7 @@ (define (serialize-file-object field-name val)
(define-maybe file-object)
(set! serialize-maybe-file-object
(lambda (field-name val)
- (if (and (symbol? val)
- (eq? val 'disabled))
+ (if (unspecified? val)
(serialize-string field-name "")
(serialize-file-object field-name val))))
@@ -281,7 +279,7 @@ (define-configuration transmission-daemon-configuration
torrent is complete. Otherwise, files for all torrents (including those still
being downloaded) will be placed in @code{download-dir}.")
(incomplete-dir
- (maybe-string 'disabled)
+ maybe-string
"The directory in which files from incompletely downloaded torrents will be
held when @code{incomplete-dir-enabled?} is @code{#t}.")
(umask
@@ -305,7 +303,7 @@ (define-configuration transmission-daemon-configuration
automatically (and the original files removed, if
@code{trash-original-torrent-files?} is @code{#t}).")
(watch-dir
- (maybe-string 'disabled)
+ maybe-string
"The directory to be watched for @file{.torrent} files indicating new
torrents to be added, when @code{watch-dir-enabled} is @code{#t}.")
(trash-original-torrent-files?
@@ -401,11 +399,11 @@ (define-configuration transmission-daemon-configuration
@code{prefer-unencrypted-connections}, @code{prefer-encrypted-connections} or
@code{require-encrypted-connections}.")
(peer-congestion-algorithm
- (maybe-string 'disabled)
+ maybe-string
"The TCP congestion-control algorithm to use for peer connections,
specified using a string recognized by the operating system in calls to
-@code{setsockopt} (or set to @code{disabled}, in which case the
-operating-system default is used).
+@code{setsockopt} (or leave it unset, in which case the operating-system
+default is used).
Note that on GNU/Linux systems, the kernel must be configured to allow
processes to use a congestion-control algorithm not in the default set;
@@ -465,7 +463,7 @@ (define-configuration transmission-daemon-configuration
"When @code{#t}, the daemon will ignore peers mentioned in the blocklist it
has most recently downloaded from @code{blocklist-url}.")
(blocklist-url
- (maybe-string 'disabled)
+ maybe-string
"The URL of a peer blocklist (in @acronym{P2P}-plaintext or eMule
@file{.dat} format) to be periodically downloaded and applied when
@code{blocklist-enabled?} is @code{#t}.")
@@ -564,11 +562,11 @@ (define-configuration transmission-daemon-configuration
the side effect of disabling host-name whitelisting (see
@code{r
This message was truncated. Download the full message here.
A
A
Attila Lendvai wrote on 17 May 2022 13:39
[PATCH v5 3/3] doc: Follow the 'disabled -> *unspecified* configuration refactor.
(address . 54674@debbugs.gnu.org)(name . Attila Lendvai)(address . attila@lendvai.name)
20220517113926.3931-3-attila@lendvai.name
---
doc/guix.texi | 85 ++++++++++++++++++++++++++-------------------------
1 file changed, 43 insertions(+), 42 deletions(-)

Toggle diff (243 lines)
diff --git a/doc/guix.texi b/doc/guix.texi
index 5399584cb0..a578a5bd60 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -18632,15 +18632,16 @@ The node host name that is used to make the first connection to the
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
-bootsrapping by setting this to the @code{'disabled} symbol.
+bootsrapping by explicitly setting this to the @code{*unspecified*}
+value.
Defaults to @samp{"bootstrap.jami.net:4222"}.
@end deftypevr
@deftypevr {@code{opendht-configuration} parameter} maybe-number port
-The UDP port to bind to. When set to @code{'disabled}, an available
-port is automatically selected.
+The UDP port to bind to. When explicitly set to @code{*unspecified*},
+an available port is automatically selected.
Defaults to @samp{4222}.
@@ -24405,7 +24406,7 @@ The available configuration parameters follow. Each parameter
definition is preceded by its type; for example, @samp{string-list foo}
indicates that the @code{foo} parameter should be specified as a list of
strings. Types starting with @code{maybe-} denote parameters that won't
-show up in @code{prosody.cfg.lua} when their value is @code{'disabled}.
+show up in @code{prosody.cfg.lua} when their value is left unspecified.
There is also a way to specify the configuration as a string, if you
have an old @code{prosody.cfg.lua} file that you want to port over from
@@ -25019,7 +25020,7 @@ Whether to enable debug level messages.
@item @code{auto-answer?} (default: @code{#f}) (type: boolean)
Whether to force automatic answer to incoming calls.
-@item @code{accounts} (default: @code{disabled}) (type: maybe-jami-account-list)
+@item @code{accounts} (type: maybe-jami-account-list)
A list of Jami accounts to be (re-)provisioned every time the Jami
daemon service starts. When providing this field, the account
directories under @file{/var/lib/jami/} are recreated every time the
@@ -25041,39 +25042,39 @@ should @emph{not} be encrypted. It is highly recommended to make it
readable only to the @samp{root} user (i.e., not in the store), to guard
against leaking the secret key material of the Jami account it contains.
-@item @code{allowed-contacts} (default: @code{disabled}) (type: maybe-account-fingerprint-list)
+@item @code{allowed-contacts} (type: maybe-account-fingerprint-list)
The list of allowed contacts for the account, entered as their 40
characters long fingerprint. Messages or calls from accounts not in
-that list will be rejected. When unspecified, the configuration of the
-account archive is used as-is with respect to contacts and public
+that list will be rejected. When left specified, the configuration of
+the account archive is used as-is with respect to contacts and public
inbound calls/messaging allowance, which typically defaults to allow any
contact to communicate with the account.
-@item @code{moderators} (default: @code{disabled}) (type: maybe-account-fingerprint-list)
+@item @code{moderators} (type: maybe-account-fingerprint-list)
The list of contacts that should have moderation privileges (to ban,
mute, etc. other users) in rendezvous conferences, entered as their 40
-characters long fingerprint. When unspecified, the configuration of the
-account archive is used as-is with respect to moderation, which
+characters long fingerprint. When left unspecified, the configuration
+of the account archive is used as-is with respect to moderation, which
typically defaults to allow anyone to moderate.
-@item @code{rendezvous-point?} (default: @code{disabled}) (type: maybe-boolean)
+@item @code{rendezvous-point?} (type: maybe-boolean)
Whether the account should operate in the rendezvous mode. In this
mode, all the incoming audio/video calls are mixed into a conference.
When left unspecified, the value from the account archive prevails.
-@item @code{peer-discovery?} (default: @code{disabled}) (type: maybe-boolean)
+@item @code{peer-discovery?} (type: maybe-boolean)
Whether peer discovery should be enabled. Peer discovery is used to
discover other OpenDHT nodes on the local network, which can be useful
to maintain communication between devices on such network even when the
connection to the the Internet has been lost. When left unspecified,
the value from the account archive prevails.
-@item @code{bootstrap-hostnames} (default: @code{disabled}) (type: maybe-string-list)
+@item @code{bootstrap-hostnames} (type: maybe-string-list)
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.
-@item @code{name-server-uri} (default: @code{disabled}) (type: maybe-string)
+@item @code{name-server-uri} (type: maybe-string)
The URI of the name server to use, that can be used to retrieve the
account fingerprint for a registered username.
@@ -25707,8 +25708,8 @@ Defaults to @samp{prefer-encrypted-connections}.
@deftypevr {@code{transmission-daemon-configuration} parameter} maybe-string peer-congestion-algorithm
The TCP congestion-control algorithm to use for peer connections,
specified using a string recognized by the operating system in calls to
-@code{setsockopt} (or set to @code{disabled}, in which case the
-operating-system default is used).
+@code{setsockopt}. When left unspecified, the operating-system default
+is used.
Note that on GNU/Linux systems, the kernel must be configured to allow
processes to use a congestion-control algorithm not in the default set;
@@ -29336,7 +29337,7 @@ Defaults to @samp{tun}.
If you do not have some of these files (eg.@: you use a username and
password), you can disable any of the following three fields by setting
-it to @code{'disabled}.
+it to @code{*unspecified*}.
@deftypevr {@code{openvpn-client-configuration} parameter} maybe-string ca
The certificate authority to check connections against.
@@ -29410,7 +29411,6 @@ Authenticate with server using username/password. The option is a file
containing username/password on 2 lines. Do not use a file-like object as it
would be added to the store and readable by any user.
-Defaults to @samp{'disabled}.
@end deftypevr
@deftypevr {@code{openvpn-client-configuration} parameter} key-usage verify-key-usage?
@@ -29491,7 +29491,7 @@ Defaults to @samp{tun}.
If you do not have some of these files (eg.@: you use a username and
password), you can disable any of the following three fields by setting
-it to @code{'disabled}.
+it to @code{*unspecified*}.
@deftypevr {@code{openvpn-server-configuration} parameter} maybe-string ca
The certificate authority to check connections against.
@@ -30290,10 +30290,10 @@ content by adding a valid @code{tlp-configuration}:
@end deffn
Each parameter definition is preceded by its type; for example,
-@samp{boolean foo} indicates that the @code{foo} parameter
-should be specified as a boolean. Types starting with
-@code{maybe-} denote parameters that won't show up in TLP config file
-when their value is @code{'disabled}.
+@samp{boolean foo} indicates that the @code{foo} parameter should be
+specified as a boolean. Types starting with @code{maybe-} denote
+parameters that won't show up in TLP config file when their value is
+left unset, or is explicitly set to the @code{*unspecified*} value.
@c The following documentation was initially generated by
@c (generate-tlp-documentation) in (gnu services pm). Manually maintained
@@ -37853,15 +37853,16 @@ macro which is a shorthand of this.
@deffn {Scheme Syntax} define-maybe @var{type}
Sometimes a field should not be serialized if the user doesn’t specify a
value. To achieve this, you can use the @code{define-maybe} macro to
-define a ``maybe type''; if the value of a maybe type is set to the
-@code{disabled}, it will not be serialized.
+define a ``maybe type''; if the value of a maybe type is left unset, or
+is set to the @code{*unspecified*} value, then it will not be
+serialized.
When defining a ``maybe type'', the corresponding serializer for the
regular type will be used by default. For example, a field of type
@code{maybe-string} will be serialized using the @code{serialize-string}
procedure by default, you can of course change this by specifying a
custom serializer procedure. Likewise, the type of the value would have
-to be a string, unless it is set to the @code{disabled} symbol.
+to be a string, or left unspecified.
@lisp
(define-maybe string)
@@ -37871,9 +37872,9 @@ to be a string, unless it is set to the @code{disabled} symbol.
(define-configuration baz-configuration
(name
- ;; Nothing will be serialized by default. If set to a string, the
- ;; `serialize-string' procedure will be used to serialize the string.
- (maybe-string 'disabled)
+ ;; If set to a string, the `serialize-string' procedure will be used
+ ;; to serialize the string. Otherwise this field is not serialized.
+ maybe-string ; equivalent to (maybe-string *unspecified*)
"The name of this module."))
@end lisp
@@ -37890,7 +37891,7 @@ serializer name by using the @code{prefix} literal.
There is also the @code{no-serialization} literal, which when set means
that no serializer will be defined for the ``maybe type'', regardless of
-its value is @code{disabled} or not.
+whether its value is set or not.
@code{define-maybe/no-serialization} is a shorthand for specifying the
@code{no-serialization} literal.
@@ -37899,7 +37900,7 @@ its value is @code{disabled} or not.
(define-configuration/no-serialization test-configuration
(mode
- (maybe-symbol 'disabled)
+ maybe-symbol
"Docstring."))
@end lisp
@end deffn
@@ -38031,10 +38032,10 @@ Below is an example of a record type created using
"The name of the contact."
serialize-contact-name)
(phone-number
- (maybe-integer 'disabled)
+ maybe-integer
"The person's phone number.")
(email
- (maybe-string 'disabled)
+ maybe-string
"The person's email address.")
(married?
(boolean)
@@ -38758,24 +38759,24 @@ Daytime color temperature (kelvins).
@item @code{nighttime-temperature} (default: @code{4500}) (type: integer)
Nighttime color temperature (kelvins).
-@item @code{daytime-brightness} (default: @code{disabled}) (type: maybe-inexact-number)
-Daytime screen brightness, between 0.1 and 1.0.
+@item @code{daytime-brightness} (type: maybe-inexact-number)
+Daytime screen brightness, between 0.1 and 1.0, or left unspecified.
-@item @code{nighttime-brightness} (default: @code{disabled}) (type: maybe-inexact-number)
-Nighttime screen brightness, between 0.1 and 1.0.
+@item @code{nighttime-brightness} (type: maybe-inexact-number)
+Nighttime screen brightness, between 0.1 and 1.0, or left unspecified.
-@item @code{latitude} (default: @code{disabled}) (type: maybe-inexact-number)
+@item @code{latitude} (type: maybe-inexact-number)
Latitude, when @code{location-provider} is @code{'manual}.
-@item @code{longitude} (default: @code{disabled}) (type: maybe-inexact-number)
+@item @code{longitude} (type: maybe-inexact-number)
Longitude, when @code{location-provider} is @code{'manual}.
-@item @code{dawn-time} (default: @code{disabled}) (type: maybe-string)
+@item @code{dawn-time} (type: maybe-string)
Custom time for the transition from night to day in the
morning---@code{"HH:MM"} format. When specified, solar elevation is not
used to determine the daytime/nighttime period.
-@item @code{dusk-time} (default: @code{disabled}) (type: maybe-string)
+@item @code{dusk-time} (type: maybe-string)
Likewise, custom time for the transition from day to night in the
evening.
--
2.35.1
M
M
Maxime Devos wrote on 17 May 2022 18:15
Re: [bug#54674] [PATCH v4 1/2] services: configuration: Support (field1 maybe-number "") format.
13fb88d83d867659fc4d5f9c76685d80933e15be.camel@telenet.be
Attila Lendvai schreef op di 17-05-2022 om 11:38 [+0000]:
Toggle quote (5 lines)
> unfortunately, `make check-system` returns with the attached output.
> after some staring and grepping, i can't identify why these tests are
> failing, and whether it is a new bug at all that happens due to my
> changes.

The standard test is to run "make check-system" again without patches
and see if it still fails.

Toggle quote (3 lines)
> i would love to reshape this into something that will get merged.
> is there anything i can do to help that process?

AFAICT the patch is ready, except for maybe the Jami issue.

Also, if there are more reviewers for patches in general (and likewise,
more people investigating bugs), then committers have less to take care
of (-> faster response times).  Likewise with more committers.
That's more of a long-term and general (not specific to this patch)
thing though.

Greetings,
Maxime.
-----BEGIN PGP SIGNATURE-----

iI0EABYKADUWIQTB8z7iDFKP233XAR9J4+4iGRcl7gUCYoPKDRccbWF4aW1lZGV2
b3NAdGVsZW5ldC5iZQAKCRBJ4+4iGRcl7nfDAP4+VKslugKgNXcZU85DpG5LW4jb
t89okZPBznWhetkF6QD/U5YENiILJCpoHnqixObk0yWtnYj108O7OjgyLwBXNgU=
=0lIH
-----END PGP SIGNATURE-----


A
A
Attila Lendvai wrote on 19 May 2022 16:21
(name . Maxime Devos)(address . maximedevos@telenet.be)(address . 54674@debbugs.gnu.org)
3Cis7cFHPfYGze2JdN3x727hDCzDrk7Rl5hfMYOPnWyg01E2iwQoqpzCP3qFB53n8PlXEgPbbP4TvtjepzNfFj2DB6gNwLz9OK47dFAZy2Y=@lendvai.name
Toggle quote (4 lines)
> The standard test is to run "make check-system" again without patches
> and see if it still fails.


the trouble is that it fails even on master. i took the time now, pulled latest master, and ran a `make check-system`, and it fails the same way for me as with my patch. i've attached the log, produced this time by *master*; in essence:

This is the GNU system. Welcome.
jami login: Jami Daemon 11.0.0, by Savoir-faire Linux 2004-2019
[Video support enabled]
[Plugins support enabled]

10:05:11.924 os_core_unix.c !pjlib 2.11 for POSIX initialized
Jami Daemon 11.0.0, by Savoir-faire Linux 2004-2019
[Video support enabled]
[Plugins support enabled]

One does not simply initialize the client: Another daemon is detected
/gnu/store/01phrvxnxrg1q0gxa35g7f77q06crf6v-shepherd-marionette.scm:1:1718: ERROR:
1. &action-exception-error:
service: jami
action: start
key: match-error
args: ("match" "no matching pattern" #f)

[...]

--
• attila lendvai
• PGP: 963F 5D5F 45C7 DFCD 0A39
--
“You’ve stopped seeking the truth when you view doubt not as a clue to be followed but a challenge to be overcome.”
— Peter Boghossian (1966–)
A
A
Attila Lendvai wrote on 19 May 2022 22:41
(name . Maxime Devos)(address . maximedevos@telenet.be)(address . 54674@debbugs.gnu.org)
SzWPf0ohkT8I-4BWfATCCH70m04rZh4xi_nFo9CSZrXyFa8rf1pMDYZN72SbXwRXt3gr_ltVwY_b_qoDZq9sAgxcpLP-FC3REKo1kJbqN8g=@lendvai.name
FTR, master's `make check-system` failures are tracked here:


--
• attila lendvai
• PGP: 963F 5D5F 45C7 DFCD 0A39
--
“War must be, while we defend our lives against a destroyer who would devour all; but I do not love the bright sword for its sharpness, nor the arrow for its swiftness, nor the warrior for his glory. I love only that which they defend.”
— J. R. R. Tolkien (1892–1973), 'The Two Towers' (1954), http://youtu.be/jfxdlWje5nk
L
L
Ludovic Courtès wrote on 15 Jun 2022 00:31
Re: bug#54674: [PATCH] services: configuration: Use *unspecified* instead of 'disabled.
(name . Attila Lendvai)(address . attila@lendvai.name)(address . 54674-done@debbugs.gnu.org)
87wndivpvz.fsf_-_@gnu.org
Hi Attila,

Finally pushed!

713d140750 * doc: Follow the 'disabled -> *unspecified* configuration refactor.
8cb1a49a39 * services: configuration: Use *unspecified* instead of 'disabled.
e11517052b * services: configuration: Support (field1 maybe-number "") format.

I edited the commit logs so that every change is mentioned.

Anyway, a nice improvement!

Thank you, and thanks Maxime for reviewing and helping out.

Ludo’.
Closed
?