From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id YBpWL/pK92K0ygAAbAwnHQ (envelope-from ) for ; Sat, 13 Aug 2022 08:55:54 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id gGdrL/pK92I0RAEA9RJhRA (envelope-from ) for ; Sat, 13 Aug 2022 08:55:54 +0200 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 7BDC312D64 for ; Sat, 13 Aug 2022 08:55:54 +0200 (CEST) Received: from localhost ([::1]:42416 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oMl3p-0004Mk-JZ for larch@yhetil.org; Sat, 13 Aug 2022 02:55:53 -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 Content-Transfer-Encoding: 8bit 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+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Migadu-Flow: FLOW_IN X-Migadu-To: larch@yhetil.org X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1660373754; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=HPlyqZ1NEiLKUs8b9GgAK4ANceNvfGgBvBKUHD+Czpo=; b=Pv7d0chOK/ygtvs0+YIGFq13LfhcRqqiaZ6MMww/0S1aEA1nP16xAPO+mkt/CWtmLMaxLD j1QMSk58tmP7ys8I6icVuHIqO1Vksf+7eHLQtXh1FwS8BfTH/NA6EXe9TKeshstg9DF7I5 Nh/qjagWLL9e06986Mh4MwvvSmnCZBL54VrqCyOv7TV1SEsxo+yjb0UZmtVenlmzDZ0zu+ tDhzWKngp6KEc3f3g8GwaYVfd5L/eyHwPzTDZDZ1rUYsezUHVmcgNe8G7/jVHJTZgvYNQN LHrT5JDNAtFUAGd2njNJSYiFwM6WHOR5I6aF+AZzhflc6ENUoCB5/dsxe4g+rg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1660373754; a=rsa-sha256; cv=none; b=RF+YeJ1jaXOP7E6mWcIH+NIvYJPOdaVVL+7cu6io8+f+RFGU7kNb1iv4OWT4EBvj6hdRgT gwL5kLMMOAhnAIyDyAuubY/GX4kfesIQ3ViF33Sf2FyhupulRX8joiWwAImYNGvBkaHlOX P7JJg4MXBt8xQqVzoOecfSrfITeTzBmLs78X2CmEvo/hv/CJ+xih4Yw135fCVcECTlT1FG oMY88lNqSMnnmZrN2XhSQwnDXU25kROGNcTnasjE59MHwNWWM3mF58UacTxleIsDAto/i3 XnbsfL2eln1SeF/GjfUqpZFuojc/Xb1v7/IONHF9W2cagpFxXTdLKQCOTmPYyw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20210112 header.b=XWG+Qapr; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: 7.84 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20210112 header.b=XWG+Qapr; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: 7BDC312D64 X-Spam-Score: 7.84 X-Migadu-Scanner: scn0.migadu.com X-TUID: /QsDpsnzVVxc * 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)) -- 2.36.1