(address . guix-patches@gnu.org)(name . Attila Lendvai)(address . 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.