From patchwork Sat Aug 13 06:54:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Cournoyer X-Patchwork-Id: 41590 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 1B6BB27BBEB; Sat, 13 Aug 2022 07:56:17 +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_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,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 9EA7C27BBEA for ; Sat, 13 Aug 2022 07:56:16 +0100 (BST) Received: from localhost ([::1]:42416 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oMl4B-0004Mk-PJ for patchwork@mira.cbaines.net; Sat, 13 Aug 2022 02:56:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45496) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oMl30-0004LP-Gs for guix-patches@gnu.org; Sat, 13 Aug 2022 02:55:06 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:41526) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oMl30-0006G5-0j for guix-patches@gnu.org; Sat, 13 Aug 2022 02:55:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oMl2z-0006oW-Tj for guix-patches@gnu.org; Sat, 13 Aug 2022 02:55:01 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#57168] [PATCH 01/14] services: configuration: Add a 'maybe-value-set?' procedure. References: <20220813065006.27151-1-maxim.cournoyer@gmail.com> In-Reply-To: <20220813065006.27151-1-maxim.cournoyer@gmail.com> Resent-From: Maxim Cournoyer Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sat, 13 Aug 2022 06:55:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 57168 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 57168@debbugs.gnu.org Cc: Maxim Cournoyer Received: via spool by 57168-submit@debbugs.gnu.org id=B57168.166037369226110 (code B ref 57168); Sat, 13 Aug 2022 06:55:01 +0000 Received: (at 57168) by debbugs.gnu.org; 13 Aug 2022 06:54:52 +0000 Received: from localhost ([127.0.0.1]:59490 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oMl2n-0006mT-5i for submit@debbugs.gnu.org; Sat, 13 Aug 2022 02:54:52 -0400 Received: from mail-qt1-f169.google.com ([209.85.160.169]:38891) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oMl2k-0006m7-If for 57168@debbugs.gnu.org; Sat, 13 Aug 2022 02:54:47 -0400 Received: by mail-qt1-f169.google.com with SMTP id y18so2291358qtv.5 for <57168@debbugs.gnu.org>; Fri, 12 Aug 2022 23:54:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc; bh=HPlyqZ1NEiLKUs8b9GgAK4ANceNvfGgBvBKUHD+Czpo=; b=XWG+QaprJSmcQx9la8wR+yuPWoYm1ZZ1mAj8xzsANRgC3iZCd0ZRc1Uy4ghn35MT/c 1EsaKL8/GdZB4TZ/LdOHjneDTELgWtAV1CESAKY3voi9yg4AbNmFVnUI8pwduOE0+K4C 3Z1EanuMLgTcTGYrkvLihPO0XszCV8wG6fSyh9G8TKyGv2bp19lUY1NAdo09gjZiiYsM By8O2unBCHw7CjGXZs9w3pJYRRVSh0RhIYP6GHTog7DkldNZ156OLs7O5QF1mK3YxYNN eIR1zf8PjlhJWv7Zy3PJbLA4GZNO9nNcc+FZyMPIg7EkH7Tu82pW84I4uNypmAMn6w9i zWqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc; bh=HPlyqZ1NEiLKUs8b9GgAK4ANceNvfGgBvBKUHD+Czpo=; b=aXmInAMyw55jwkz9mPRCn7g9WbxorAg3HEOvtNH2dk3xtjM0swZ+mkhSXjP9cFIWti /2kppq/MoJwtvkRBK9iACMub5N/YuSbQKX8+TmoQqZMgBgogEaoknIMLdAp7eltN0ELy 2JFxxfULunBeYC8ODzT8iuPYA1FDaH3TFdnJJRJZD/IghygEdvSdX3KXBKBxIYyylOK4 TwXGIJ/GgkRm1mXf75antGzUjXhQ8Uf0Y9oTD7i3VXVjcWzp4jPTcZ3w30XC7IL0nbDV ZNH0NYFl5mi/QO2ZkMTevroODLBFxMcJw1k18L+HyQztJ8optoF8ZTFqrQl4BAyWSZTP QSvQ== X-Gm-Message-State: ACgBeo3G6ebBmusu6546h6hfuTFMBkD8YdUu80D01kGImTkTMirA/Kvj /KMjRI2wSZcXWddhDqd1Ur4s2khR2+c= X-Google-Smtp-Source: AA6agR4PZ5QF9q0shVUYY8N+8ze+HFpnEWb5ySeabxfv01+ZlF2akLsJpMqsu78xWC2ZeoSSvJp1pw== X-Received: by 2002:a05:622a:1304:b0:343:470:62dc with SMTP id v4-20020a05622a130400b00343047062dcmr6519337qtk.270.1660373680646; Fri, 12 Aug 2022 23:54:40 -0700 (PDT) Received: from localhost.localdomain (dsl-205-233-125-72.b2b2c.ca. [205.233.125.72]) by smtp.gmail.com with ESMTPSA id s12-20020a05620a29cc00b006b6757a11fcsm3734441qkp.36.2022.08.12.23.54.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Aug 2022 23:54:40 -0700 (PDT) From: Maxim Cournoyer Date: Sat, 13 Aug 2022 02:54:20 -0400 Message-Id: <20220813065433.27319-1-maxim.cournoyer@gmail.com> X-Mailer: git-send-email 2.36.1 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 * gnu/services/configuration.scm (maybe-value-set?): New procedure. * doc/guix.texi (Complex Configurations): Document it. Remove comment showing usage of 'maybe-string' with a default value, which doesn't make sense. --- doc/guix.texi | 7 ++++++- gnu/services/configuration.scm | 5 +++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/doc/guix.texi b/doc/guix.texi index 86cfe7d49c..039df29ebc 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -38999,7 +38999,7 @@ to be a string, or left unspecified. (name ;; 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*) + maybe-string "The name of this module.")) @end lisp @@ -39030,6 +39030,11 @@ whether its value is set or not. @end lisp @end deffn +@deffn (Scheme Procedure) maybe-value-set? @var{value} +Predicate to check whether a user explicitly specified the value of a +maybe field. +@end deffn + @deffn {Scheme Procedure} serialize-configuration @var{configuration} @ @var{fields} Return a G-expression that contains the values corresponding to the diff --git a/gnu/services/configuration.scm b/gnu/services/configuration.scm index 3007e8de35..b41b4d2e62 100644 --- a/gnu/services/configuration.scm +++ b/gnu/services/configuration.scm @@ -57,6 +57,7 @@ (define-module (gnu services configuration) serialize-configuration define-maybe define-maybe/no-serialization + maybe-value-set? generate-documentation configuration->documentation empty-serializer @@ -300,6 +301,10 @@ (define-configuration stem (field field-type+def (define (empty-serializer field-name val) "") (define serialize-package empty-serializer) +(define (maybe-value-set? value) + "Predicate to check whether a 'maybe' value was explicitly provided." + (not (eq? 'unset value))) + ;; A little helper to make it easier to document all those fields. (define (generate-documentation documentation documentation-name) (define (str x) (object->string x))