From 8cb1a49a3998c39f315a4199b7d4a121a6d66449 Mon Sep 17 00:00:00 2001 From: Attila Lendvai Date: Tue, 17 May 2022 13:39:28 +0200 Subject: services: configuration: Use *unspecified* instead of 'disabled. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. (define-maybe-helper): Use *unspecified* instead of 'disabled, and make the default value optional. * gnu/home/services/desktop.scm (home-redshift-configuration): Change (maybe-xyz 'disabled) to maybe-xyz. * gnu/services/authentication.scm (nslcd-configuration): Likewise. * gnu/services/cgit.scm (repository-cgit-configuration): Likewise. * gnu/services/file-sharing.scm (serialize-maybe-string) (serialize-maybe-file-object): Use 'unspecified?' instead of (eq? val 'disabled). * gnu/services/messaging.scm (raw-content?): Likewise. (ssl-configuration): Change (maybe-xyz 'disabled) to maybe-xyz. (prosody-configuration): Likewise. * gnu/services/file-sharing.scm (transmission-daemon-configuration): Likewise. * gnu/services/messaging.scm (define-all-configurations): Use *unspecified* instead of 'disabled'. * gnu/services/networking.scm (opendht-configuration): Likewise. * gnu/services/pm.scm (tlp-configuration): Likewise. * gnu/services/telephony.scm (jami-account): Likewise. (jami-configuration): Likewise. * gnu/services/vpn.scm (openvpn-client-configuration): Likewise. * tests/services/configuration.scm ("maybe type, no default") ("maybe type, with default"): New tests. Signed-off-by: Ludovic Courtès --- gnu/services/configuration.scm | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'gnu/services/configuration.scm') 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-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 @@ does not have a default value" field kind))) (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 @@ does not have a default value" field kind))) (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 @@ does not have a default value" field kind))) 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 @@ does not have a default value" field kind))) (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)) -- cgit 1.4.1