From patchwork Thu Apr 7 13:52:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Attila Lendvai X-Patchwork-Id: 38375 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 0A72527BBEA; Thu, 7 Apr 2022 14:56:22 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,SPF_HELO_PASS autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 4E8E427BBE9 for ; Thu, 7 Apr 2022 14:56:21 +0100 (BST) Received: from localhost ([::1]:48734 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ncScW-0007EF-H7 for patchwork@mira.cbaines.net; Thu, 07 Apr 2022 09:56:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55664) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ncSaJ-0005f9-6R for guix-patches@gnu.org; Thu, 07 Apr 2022 09:54:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:38124) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ncSaI-00044e-9Y for guix-patches@gnu.org; Thu, 07 Apr 2022 09:54:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ncSaI-0005i7-3A for guix-patches@gnu.org; Thu, 07 Apr 2022 09:54:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#54674] [PATCH v2 1/2] services: configuration: Support (field1 maybe-number "") format. References: <20220401191957.16624-1-attila@lendvai.name> In-Reply-To: <20220401191957.16624-1-attila@lendvai.name> Resent-From: Attila Lendvai Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 07 Apr 2022 13:54:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 54674 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 54674@debbugs.gnu.org Cc: Attila Lendvai Received: via spool by 54674-submit@debbugs.gnu.org id=B54674.164933958921884 (code B ref 54674); Thu, 07 Apr 2022 13:54:02 +0000 Received: (at 54674) by debbugs.gnu.org; 7 Apr 2022 13:53:09 +0000 Received: from localhost ([127.0.0.1]:60254 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ncSZQ-0005gs-Ut for submit@debbugs.gnu.org; Thu, 07 Apr 2022 09:53:09 -0400 Received: from mail-ej1-f53.google.com ([209.85.218.53]:37788) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ncSZP-0005gb-Fa for 54674@debbugs.gnu.org; Thu, 07 Apr 2022 09:53:08 -0400 Received: by mail-ej1-f53.google.com with SMTP id bg10so11031728ejb.4 for <54674@debbugs.gnu.org>; Thu, 07 Apr 2022 06:53:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=qK8JBptPO9o5gmgN6sjw8xcAIwidA+W4zSseYx+1TOg=; b=S320fhU6zaTj0Gjm16nuJgGxoSPNk3hzkxBBeg9wcgUtSEE/E03QlMsENUYrEJdELf 8QdfwC/h+xzLmM0gG1sS7r3JtNvWdHChDVJ/iJs8Lx65as65QZ+Wl+UXFpBzyF9nkxhD NNsuXP5mLKyvm12SSQoaZPM9QI6E2DgTjMhWa+u6XvuSOk45QYEl7EeyNXJocbBApXPu KguC1Wzes5oJror+PJGRimmO/vlwm+ncpryaBuv63xyx0f2RcKLYrDVJRfqKko2IERNd LPc/FxaCPR+kl6fnRRF6G8CM4hCAaoTVOZiO4wGaoiDZbGc4IufysiADPn4VaAL3q/SG EfLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :mime-version:content-transfer-encoding; bh=qK8JBptPO9o5gmgN6sjw8xcAIwidA+W4zSseYx+1TOg=; b=gsM0zfW1TTm4VI4hp5fbwHaNxOExXMRQeXaa2QQNxxS19aqo+uahLMRxz+03b2/T4I tJSfrwEihpUxYWoKJxagvEX4GYrfQqG4QCFWWfFoX1YUhnZKYr1v5FLl741sVJmZyuOX NyjTRT0OPu3/PE9DnSPWGZt0BvWmI+QxmtNM4w1T99H17dlaE7JSlvMgJjByw/meIvZk x+Hpu56rJkCBzpeMW/tA8hNw8NRo2VW9EIEtGAsp0WweVySEfQiY3y27ZN19Qjhxbqce cuPBihooK98nhTkdfvfWWusWCeGlMY5bLdZOgwgrFy1psiBTnGUuR/2xMYyTJi2JzHL8 C7iA== X-Gm-Message-State: AOAM530mHS8tnirv9WeyJ/YXA5YGZEeeJzXzIcZa8hlHqqveZgLL1aaj O+nINQ4Ky/FYkS7PsOl9rOKXRkANGjs= X-Google-Smtp-Source: ABdhPJxHHRdOwXTVLw6SRty2II5e3RJv/UYnwsppWM5GlZ1BRMzfyQNPc5MpgOZ1VuCYZK7DNWz5tQ== X-Received: by 2002:a17:906:7711:b0:6db:32b4:f262 with SMTP id q17-20020a170906771100b006db32b4f262mr13941683ejm.522.1649339581291; Thu, 07 Apr 2022 06:53:01 -0700 (PDT) Received: from lelap.local (catv-89-132-245-188.catv.fixed.vodafone.hu. [89.132.245.188]) by smtp.gmail.com with ESMTPSA id f1-20020a056402194100b00416b174987asm9387642edz.35.2022.04.07.06.53.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Apr 2022 06:53:00 -0700 (PDT) From: Attila Lendvai Date: Thu, 7 Apr 2022 15:52:13 +0200 Message-Id: <20220407135213.17193-1-attila@lendvai.name> X-Mailer: git-send-email 2.34.0 MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches As opposed to explicitly using 'disabled as value, or using the (field1 (maybe-number) "") format. It's mostly the work of Maxime Devos , 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(-) 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 ;;; Copyright © 2021 Maxim Cournoyer ;;; Copyright © 2021 Andrew Tropin +;;; Copyright © 2022 Maxime Devos ;;; ;;; 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 From patchwork Thu Apr 7 13:52:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Attila Lendvai X-Patchwork-Id: 38376 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 27DE927BBEA; Thu, 7 Apr 2022 14:57:35 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,SPF_HELO_PASS autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 2FEAD27BBE9 for ; Thu, 7 Apr 2022 14:57:33 +0100 (BST) Received: from localhost ([::1]:49466 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ncSdg-0007jp-93 for patchwork@mira.cbaines.net; Thu, 07 Apr 2022 09:57:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56394) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ncSdC-0007hm-LJ for guix-patches@gnu.org; Thu, 07 Apr 2022 09:57:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:39149) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ncSdC-0004fU-Bh for guix-patches@gnu.org; Thu, 07 Apr 2022 09:57:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ncSdC-00062h-As for guix-patches@gnu.org; Thu, 07 Apr 2022 09:57:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#54674] [PATCH v2 2/2] services: configuration: Use *unspecified* instead of 'disabled. Resent-From: Attila Lendvai Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 07 Apr 2022 13:57:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 54674 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 54674@debbugs.gnu.org Cc: Attila Lendvai Received: via spool by 54674-submit@debbugs.gnu.org id=B54674.164933979523192 (code B ref 54674); Thu, 07 Apr 2022 13:57:02 +0000 Received: (at 54674) by debbugs.gnu.org; 7 Apr 2022 13:56:35 +0000 Received: from localhost ([127.0.0.1]:33046 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ncScj-00061z-Pn for submit@debbugs.gnu.org; Thu, 07 Apr 2022 09:56:35 -0400 Received: from mail-ej1-f43.google.com ([209.85.218.43]:34692) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ncScg-00061l-VJ for 54674@debbugs.gnu.org; Thu, 07 Apr 2022 09:56:32 -0400 Received: by mail-ej1-f43.google.com with SMTP id l26so11066810ejx.1 for <54674@debbugs.gnu.org>; Thu, 07 Apr 2022 06:56:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=8yR8xW0aFmnU8eKER6Evq4FR6Ot4DU3Oa2CFKHCTKWo=; b=UWzs9eRzD4kkT4naf78Z6ZTmpanb1xpKmp6/muilgsJ5NwvR+sjNoFwPchqn0QJ1Yy 6fs8lrFYjZAmjqUWd9398LSLUsKG3t+2473rAI19FGIRmuLkuvbPWp8VjFUXS+NkwtG9 ntc8QfJEqptP6JByf0u+uTcWYaqC/bujrcWgCa3Rf74L+9ObHOdt+kyoUn2FxnSIOfY7 ocqx7ym2bJ9eEgEquXN8VNMHpobV219lF5ouiFY/yQpmKTsEa5pao/hBPpb69Nx2zfni b6ouc/JL1mPrq9tdVawilMorGU7fprWPQVHJU0ZSeP4JdFQkrbnoKXym32IWMBGPmPzX ZLtA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=8yR8xW0aFmnU8eKER6Evq4FR6Ot4DU3Oa2CFKHCTKWo=; b=opj2BQkeXQRIRFajGVmXhB4qdJkWC6q0wrmWtR0TzezXDGRvQK1Df0S5ah8HU/X6XZ kOcoVEnHsbqjlBwNBzUAOfckWye5oLgCpquLUZQhnuMOjgFK+eQSpALfgmIhA6RvKddK WHeeTJRcwAgzuegQyD1NHPk4j2sggZ/8hdcExtuuwQW6k4eyFcie8fzkFmpsX5jVzRou REM+/8n2Z/j0TKYqpVINLlEsptEtcWrlNXp5orLfL35AgBGg1heBHvQgZad9IwmKSikE Rp1CDoZOcCLl3nOiR7hgO4D5SNgNTwb83EdEnDtjmZTEpWJpkUzbk7eP2mMkn6z+LnHn GK9Q== X-Gm-Message-State: AOAM531blQm7BPcwTRa55yjf9U9orJLdcuiXzL6YN2fpQ3Fjxg8G9m0I EQrCod5JxjkPnUUqAfUippJxs8m8Ags= X-Google-Smtp-Source: ABdhPJx/iviAbiFE9hIZwDnPK9PpVxN3ZN3YTzwNa8/5i9vK2kb3+3Age5AiO/Yj9vfqcPFf/76Aww== X-Received: by 2002:a17:906:1603:b0:6ce:362:c938 with SMTP id m3-20020a170906160300b006ce0362c938mr13658170ejd.253.1649339784368; Thu, 07 Apr 2022 06:56:24 -0700 (PDT) Received: from lelap.local (catv-89-132-245-188.catv.fixed.vodafone.hu. [89.132.245.188]) by smtp.gmail.com with ESMTPSA id f1-20020a056402194100b00416b174987asm9387642edz.35.2022.04.07.06.56.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Apr 2022 06:56:23 -0700 (PDT) From: Attila Lendvai Date: Thu, 7 Apr 2022 15:52:15 +0200 Message-Id: <20220407135213.17193-2-attila@lendvai.name> X-Mailer: git-send-email 2.34.0 In-Reply-To: <20220407135213.17193-1-attila@lendvai.name> References: <20220407135213.17193-1-attila@lendvai.name> MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches ...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(-) 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?} is @code{#t}.") @@ -564,11 +562,11 @@ (define-configuration transmission-daemon-configuration the side effect of disabling host-name whitelisting (see @code{rpc-host-whitelist-enabled?}.") (rpc-username - (maybe-string 'disabled) + (maybe-string) "The username required by clients to access the @acronym{RPC} interface when @code{rpc-authentication-required?} is @code{#t}.") (rpc-password - (maybe-transmission-password-hash 'disabled) + (maybe-transmission-password-hash) "The password required by clients to access the @acronym{RPC} interface when @code{rpc-authentication-required?} is @code{#t}. This must be specified using a password hash in the format recognized by Transmission clients, either @@ -613,7 +611,7 @@ (define-configuration transmission-daemon-configuration @code{script-torrent-done-filename} will be invoked each time a torrent completes.") (script-torrent-done-filename - (maybe-file-object 'disabled) + (maybe-file-object) "A file name or file-like object specifying a script to run each time a torrent completes, when @code{script-torrent-done-enabled?} is @code{#t}.") (scrape-paused-torrents-enabled? diff --git a/gnu/services/messaging.scm b/gnu/services/messaging.scm index 4bceb1d37a..5f20d768ef 100644 --- a/gnu/services/messaging.scm +++ b/gnu/services/messaging.scm @@ -72,6 +72,7 @@ (define (make-pred arg) (lambda (field target) (and (memq (syntax->datum target) `(common ,arg)) field))) (syntax-case stx () + ;; TODO Also handle (field-type) form, without a default. ((_ stem (field (field-type def) doc target) ...) (with-syntax (((new-field-type ...) (map (lambda (field-type target) @@ -85,7 +86,7 @@ (define (make-pred arg) ((new-def ...) (map (lambda (def target) (if (eq? 'common (syntax->datum target)) - #''disabled def)) + #'*unspecified* def)) #'(def ...) #'(target ...))) ((new-doc ...) (map (lambda (doc target) @@ -195,7 +196,7 @@ (define (serialize-file-object-list field-name val) (define-maybe file-object-list) (define (raw-content? val) - (not (eq? val 'disabled))) + (not (unspecified? val))) (define (serialize-raw-content field-name val) val) (define-maybe raw-content) @@ -223,15 +224,15 @@ (define-maybe mod-muc-configuration) (define-configuration ssl-configuration (protocol - (maybe-string 'disabled) + (maybe-string) "This determines what handshake to use.") (key - (maybe-file-name 'disabled) + (maybe-file-name) "Path to your private key file.") (certificate - (maybe-file-name 'disabled) + (maybe-file-name) "Path to your certificate file.") (capath @@ -240,48 +241,48 @@ (define-configuration ssl-configuration trust when verifying the certificates of remote servers.") (cafile - (maybe-file-object 'disabled) + (maybe-file-object) "Path to a file containing root certificates that you wish Prosody to trust. Similar to @code{capath} but with all certificates concatenated together.") (verify - (maybe-string-list 'disabled) + (maybe-string-list) "A list of verification options (these mostly map to OpenSSL's @code{set_verify()} flags).") (options - (maybe-string-list 'disabled) + (maybe-string-list) "A list of general options relating to SSL/TLS. These map to OpenSSL's @code{set_options()}. For a full list of options available in LuaSec, see the LuaSec source.") (depth - (maybe-non-negative-integer 'disabled) + (maybe-non-negative-integer) "How long a chain of certificate authorities to check when looking for a trusted root certificate.") (ciphers - (maybe-string 'disabled) + (maybe-string) "An OpenSSL cipher string. This selects what ciphers Prosody will offer to clients, and in what order.") (dhparam - (maybe-file-name 'disabled) + (maybe-file-name) "A path to a file containing parameters for Diffie-Hellman key exchange. You can create such a file with: @code{openssl dhparam -out /etc/prosody/certs/dh-2048.pem 2048}") (curve - (maybe-string 'disabled) + (maybe-string) "Curve for Elliptic curve Diffie-Hellman. Prosody's default is @samp{\"secp384r1\"}.") (verifyext - (maybe-string-list 'disabled) + (maybe-string-list) "A list of \"extra\" verification options.") (password - (maybe-string 'disabled) + (maybe-string) "Password for encrypted private keys.")) (define (serialize-ssl-configuration field-name val) #~(format #f "ssl = {\n~a};\n" @@ -469,12 +470,12 @@ (define-all-configurations prosody-configuration global) (http-max-content-size - (maybe-non-negative-integer 'disabled) + (maybe-non-negative-integer *unspecified*) "Maximum allowed size of the HTTP body (in bytes)." common) (http-external-url - (maybe-string 'disabled) + (maybe-string *unspecified*) "Some modules expose their own URL in various ways. This URL is built from the protocol, host and port used. If Prosody sits behind a proxy, the public URL will be @code{http-external-url} instead. See @@ -551,7 +552,7 @@ (define-all-configurations prosody-configuration int-component) (mod-muc - (maybe-mod-muc-configuration 'disabled) + (maybe-mod-muc-configuration *unspecified*) "Multi-user chat (MUC) is Prosody's module for allowing you to create hosted chatrooms/conferences for XMPP users. @@ -568,7 +569,7 @@ (define-all-configurations prosody-configuration ext-component) (raw-content - (maybe-raw-content 'disabled) + (maybe-raw-content *unspecified*) "Raw content that will be added to the configuration file." common))) diff --git a/gnu/services/networking.scm b/gnu/services/networking.scm index 5bb8638930..b5c46218e7 100644 --- a/gnu/services/networking.scm +++ b/gnu/services/networking.scm @@ -763,17 +763,17 @@ (define-configuration/no-serialization opendht-configuration "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 bootstrapping by setting this -to the @code{'disabled} symbol.") +specified here. It's also possible to disable bootstrapping by explicitly +setting this field to the @code{*unspecified*} value.") (port (maybe-number 4222) - "The UDP port to bind to. When set to @code{'disabled}, an available port -is automatically selected.") + "The UDP port to bind to. When set to @code{*unspecified*}, an available +port is automatically selected.") (proxy-server-port - (maybe-number 'disabled) + (maybe-number) "Spawn a proxy server listening on the specified port.") (proxy-server-port-tls - (maybe-number 'disabled) + (maybe-number) "Spawn a proxy server listening to TLS connections on the specified port.")) diff --git a/gnu/services/pm.scm b/gnu/services/pm.scm index e48236dbca..d1250ab488 100644 --- a/gnu/services/pm.scm +++ b/gnu/services/pm.scm @@ -114,55 +114,55 @@ (define-configuration tlp-configuration "Same as @code{max-lost-work-secs-on-ac} but on BAT mode.") (cpu-scaling-governor-on-ac - (maybe-space-separated-string-list 'disabled) + (maybe-space-separated-string-list) "CPU frequency scaling governor on AC mode. With intel_pstate driver, alternatives are powersave and performance. With acpi-cpufreq driver, alternatives are ondemand, powersave, performance and conservative.") (cpu-scaling-governor-on-bat - (maybe-space-separated-string-list 'disabled) + (maybe-space-separated-string-list) "Same as @code{cpu-scaling-governor-on-ac} but on BAT mode.") (cpu-scaling-min-freq-on-ac - (maybe-non-negative-integer 'disabled) + (maybe-non-negative-integer) "Set the min available frequency for the scaling governor on AC.") (cpu-scaling-max-freq-on-ac - (maybe-non-negative-integer 'disabled) + (maybe-non-negative-integer) "Set the max available frequency for the scaling governor on AC.") (cpu-scaling-min-freq-on-bat - (maybe-non-negative-integer 'disabled) + (maybe-non-negative-integer) "Set the min available frequency for the scaling governor on BAT.") (cpu-scaling-max-freq-on-bat - (maybe-non-negative-integer 'disabled) + (maybe-non-negative-integer) "Set the max available frequency for the scaling governor on BAT.") (cpu-min-perf-on-ac - (maybe-non-negative-integer 'disabled) + (maybe-non-negative-integer) "Limit the min P-state to control the power dissipation of the CPU, in AC mode. Values are stated as a percentage of the available performance.") (cpu-max-perf-on-ac - (maybe-non-negative-integer 'disabled) + (maybe-non-negative-integer) "Limit the max P-state to control the power dissipation of the CPU, in AC mode. Values are stated as a percentage of the available performance.") (cpu-min-perf-on-bat - (maybe-non-negative-integer 'disabled) + (maybe-non-negative-integer) "Same as @code{cpu-min-perf-on-ac} on BAT mode.") (cpu-max-perf-on-bat - (maybe-non-negative-integer 'disabled) + (maybe-non-negative-integer) "Same as @code{cpu-max-perf-on-ac} on BAT mode.") (cpu-boost-on-ac? - (maybe-boolean 'disabled) + (maybe-boolean) "Enable CPU turbo boost feature on AC mode.") (cpu-boost-on-bat? - (maybe-boolean 'disabled) + (maybe-boolean) "Same as @code{cpu-boost-on-ac?} on BAT mode.") (sched-powersave-on-ac? @@ -179,7 +179,7 @@ (define-configuration tlp-configuration "Enable Linux kernel NMI watchdog.") (phc-controls - (maybe-string 'disabled) + (maybe-string) "For Linux kernels with PHC patch applied, change CPU voltages. An example value would be @samp{\"F:V F:V F:V F:V\"}.") @@ -205,16 +205,16 @@ (define-configuration tlp-configuration "Same as @code{disk-apm-bat} but on BAT mode.") (disk-spindown-timeout-on-ac - (maybe-space-separated-string-list 'disabled) + (maybe-space-separated-string-list) "Hard disk spin down timeout. One value has to be specified for each declared hard disk.") (disk-spindown-timeout-on-bat - (maybe-space-separated-string-list 'disabled) + (maybe-space-separated-string-list) "Same as @code{disk-spindown-timeout-on-ac} but on BAT mode.") (disk-iosched - (maybe-space-separated-string-list 'disabled) + (maybe-space-separated-string-list) "Select IO scheduler for disk devices. One value has to be specified for each declared hard disk. Example alternatives are cfq, deadline and noop.") @@ -228,16 +228,16 @@ (define-configuration tlp-configuration "Same as @code{sata-linkpwr-ac} but on BAT mode.") (sata-linkpwr-blacklist - (maybe-string 'disabled) + (maybe-string) "Exclude specified SATA host devices for link power management.") (ahci-runtime-pm-on-ac? - (maybe-on-off-boolean 'disabled) + (maybe-on-off-boolean) "Enable Runtime Power Management for AHCI controller and disks on AC mode.") (ahci-runtime-pm-on-bat? - (maybe-on-off-boolean 'disabled) + (maybe-on-off-boolean) "Same as @code{ahci-runtime-pm-on-ac} on BAT mode.") (ahci-runtime-pm-timeout @@ -254,19 +254,19 @@ (define-configuration tlp-configuration "Same as @code{pcie-aspm-ac} but on BAT mode.") (start-charge-thresh-bat0 - (maybe-non-negative-integer 'disabled) + (maybe-non-negative-integer) "Percentage when battery 0 should begin charging.") (stop-charge-thresh-bat0 - (maybe-non-negative-integer 'disabled) + (maybe-non-negative-integer) "Percentage when battery 0 should stop charging.") (start-charge-thresh-bat1 - (maybe-non-negative-integer 'disabled) + (maybe-non-negative-integer) "Percentage when battery 1 should begin charging.") (stop-charge-thresh-bat1 - (maybe-non-negative-integer 'disabled) + (maybe-non-negative-integer) "Percentage when battery 1 should stop charging.") (radeon-power-profile-on-ac @@ -346,7 +346,7 @@ (define-configuration tlp-configuration blacklisted ones.") (runtime-pm-blacklist - (maybe-space-separated-string-list 'disabled) + (maybe-space-separated-string-list) "Exclude specified PCI(e) device addresses from Runtime Power Management.") (runtime-pm-driver-blacklist @@ -359,7 +359,7 @@ (define-configuration tlp-configuration "Enable USB autosuspend feature.") (usb-blacklist - (maybe-string 'disabled) + (maybe-string) "Exclude specified devices from USB autosuspend.") (usb-blacklist-wwan? @@ -367,12 +367,12 @@ (define-configuration tlp-configuration "Exclude WWAN devices from USB autosuspend.") (usb-whitelist - (maybe-string 'disabled) + (maybe-string) "Include specified devices into USB autosuspend, even if they are already excluded by the driver or via @code{usb-blacklist-wwan?}.") (usb-autosuspend-disable-on-shutdown? - (maybe-boolean 'disabled) + (maybe-boolean) "Enable USB autosuspend before shutdown.") (restore-device-state-on-startup? diff --git a/gnu/services/telephony.scm b/gnu/services/telephony.scm index 157d96abd6..c153cb37c3 100644 --- a/gnu/services/telephony.scm +++ b/gnu/services/telephony.scm @@ -155,7 +155,7 @@ (define-configuration jami-account secret key material of the Jami account it contains." empty-serializer) (allowed-contacts - (maybe-account-fingerprint-list 'disabled) + (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 @@ -164,7 +164,7 @@ (define-configuration jami-account the account." empty-serializer) (moderators - (maybe-account-fingerprint-list 'disabled) + (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 @@ -173,24 +173,24 @@ (define-configuration jami-account empty-serializer) ;; The serializable fields below are to be set with set-account-details. (rendezvous-point? - (maybe-boolean 'disabled) + (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.") (peer-discovery? - (maybe-boolean 'disabled) + (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.") (bootstrap-hostnames - (maybe-string-list 'disabled) + (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.") (name-server-uri - (maybe-string 'disabled) + (maybe-string) "The URI of the name server to use, that can be used to retrieve the account fingerprint for a registered username.")) @@ -245,7 +245,7 @@ (define-configuration/no-serialization jami-configuration (boolean #f) "Whether to force automatic answer to incoming calls.") (accounts - (maybe-jami-account-list 'disabled) + (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 service starts, ensuring a diff --git a/gnu/services/vpn.scm b/gnu/services/vpn.scm index b24e9cffb3..133a5ad9bf 100644 --- a/gnu/services/vpn.scm +++ b/gnu/services/vpn.scm @@ -363,7 +363,7 @@ (define-split-configuration openvpn-client-configuration channel to protect against DoS attacks.") (auth-user-pass - (maybe-string 'disabled) + (maybe-string) "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.") diff --git a/tests/services/configuration.scm b/tests/services/configuration.scm index 0debf8095b..334a1e409b 100644 --- a/tests/services/configuration.scm +++ b/tests/services/configuration.scm @@ -136,3 +136,15 @@ (define-configuration config-with-maybe-string/no-serialization (test-assert "maybe value without serialization no procedure bound" (not (defined? 'serialize-maybe-string))) + +(test-assert "maybe type, no default" + (unspecified? + (config-with-maybe-string/no-serialization-name + (config-with-maybe-string/no-serialization)))) + +(test-assert "maybe type, with default" + (equal? + "foo" + (config-with-maybe-string/no-serialization-name + (config-with-maybe-string/no-serialization + (name "foo")))))