From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id MNP7Gb8cBmOh/gAAbAwnHQ (envelope-from ) for ; Wed, 24 Aug 2022 14:42:39 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id EKrgGb8cBmOAvQAAauVa8A (envelope-from ) for ; Wed, 24 Aug 2022 14:42:39 +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 29A901CAF3 for ; Wed, 24 Aug 2022 14:42:39 +0200 (CEST) Received: from localhost ([::1]:50560 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oQpiQ-0005T8-6o for larch@yhetil.org; Wed, 24 Aug 2022 08:42:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34008) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oQphq-0005PI-JH for bug-guix@gnu.org; Wed, 24 Aug 2022 08:42:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:56176) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oQphq-0000mb-7Z for bug-guix@gnu.org; Wed, 24 Aug 2022 08:42:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oQphp-000834-Tf for bug-guix@gnu.org; Wed, 24 Aug 2022 08:42:01 -0400 X-Loop: help-debbugs@gnu.org Subject: bug#56799: [PATCH 2/5] services: configuration: Add %unset-value exported variable. Resent-From: Attila Lendvai Original-Sender: "Debbugs-submit" Resent-CC: bug-guix@gnu.org Resent-Date: Wed, 24 Aug 2022 12:42:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 56799 X-GNU-PR-Package: guix X-GNU-PR-Keywords: To: 56799@debbugs.gnu.org Cc: Attila Lendvai Received: via spool by 56799-submit@debbugs.gnu.org id=B56799.166134487230834 (code B ref 56799); Wed, 24 Aug 2022 12:42:01 +0000 Received: (at 56799) by debbugs.gnu.org; 24 Aug 2022 12:41:12 +0000 Received: from localhost ([127.0.0.1]:45915 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oQph1-00081F-Tp for submit@debbugs.gnu.org; Wed, 24 Aug 2022 08:41:12 -0400 Received: from mail-ej1-f44.google.com ([209.85.218.44]:39457) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oQpgw-00080e-LZ for 56799@debbugs.gnu.org; Wed, 24 Aug 2022 08:41:10 -0400 Received: by mail-ej1-f44.google.com with SMTP id u15so24595930ejt.6 for <56799@debbugs.gnu.org>; Wed, 24 Aug 2022 05:41:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc; bh=eSDt8zmRXKS8Yhu9ydlpUZpveYmXH1nPJbzogUia+bk=; b=Qh2D2l6XknrJSnHgGqb52d3nSvTWhwMOJLKvyFzS2ppQJcVc71ctjLzc2NfDi5IHpX 7ICk5DobAwOKWEhnTE1eczYyAtuBYBS9bUaDPQR36p5rRR8BexZTC+kyA7eKDrT3OGuH bmy042VWZWlgSEUh2nYuQKuJfo9w3GbE9bvpMiNw09B6ycAAyNn5/itbvol4wWJ5vV/7 dvggD1q6DicKaWTMREAvtbpxH6kBy4UCbMroZHlNDK+39u3gpzlBihbzXi1//SVRuBRU w9gSgVCow26oX5TK/C4TPY8QDpgoFtLTf34FxOxATHPlbSpwjLHgVGXa+wo02bwBkkWV cOaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc; bh=eSDt8zmRXKS8Yhu9ydlpUZpveYmXH1nPJbzogUia+bk=; b=Hub+xP/E4BEUvuIZzqAHqbtIlqNgQhi1dGkeh2/o46FE/6BRIjbKTystY2aeaaYlUe FCAX0mKQjak7jqgffb/W1zSSJU5QIZo4QsSwM0uu83Q4tAIxouKEPXX+QHvLHdbGug13 QEiHi0IixW82un98hdFFVayr53eTQvSZvqMJVVcGotsK6zddSGYjwEEDFLG7R2UxvC3H 0tZ1WuvVW3HKpwiX9vWy/FAHZ6peiMZHCabPDidsWvVbv3sddEySTQAUsTzfzBm/x2zG J+MifXF7BBIwx/mHnEss0wPi+zb6GdBY5Xv+HjGSlF9XRZNrkDn6zHkLXKD8kZlkI06u vEiw== X-Gm-Message-State: ACgBeo2+xFt2PYy5RaVCPCBsFDYM2oT8pM3KlWT+d1DKHG9XpZ0eBodr z8954RBzu3ITEbm7CuKnH1JTNzC5In0= X-Google-Smtp-Source: AA6agR4OF0jVKs8l2aInux+4xxkTGcWtIBdDspf5cghsjxXDMTJu4Eo/YeL6QcWZwrQwNmVshrpQHw== X-Received: by 2002:a17:907:a426:b0:73d:9d53:b33 with SMTP id sg38-20020a170907a42600b0073d9d530b33mr2767354ejc.116.1661344860982; Wed, 24 Aug 2022 05:41:00 -0700 (PDT) Received: from localhost.localdomain ([2a02:ab88:7509:f780:ed82:a496:f55:e07b]) by smtp.gmail.com with ESMTPSA id f2-20020a17090631c200b006fee7b5dff2sm1114628ejf.143.2022.08.24.05.41.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Aug 2022 05:41:00 -0700 (PDT) From: Attila Lendvai Date: Wed, 24 Aug 2022 14:40:39 +0200 Message-Id: <20220824124042.10959-2-attila@lendvai.name> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220824124042.10959-1-attila@lendvai.name> References: <20220824124042.10959-1-attila@lendvai.name> 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: bug-guix@gnu.org List-Id: Bug reports for GNU Guix List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guix-bounces+larch=yhetil.org@gnu.org Sender: "bug-Guix" 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=1661344959; 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=eSDt8zmRXKS8Yhu9ydlpUZpveYmXH1nPJbzogUia+bk=; b=SEly+FfkBAdznUGvgWqwnKWiftxFZ8lYIRaLgg2Uc/6+MWny22RUoYkj9oqDbeT1xYNuXZ yr23t6YfKIblJmOT42HVGKOcsyE1y80tV1j88CbKwYZVG6lMqQwL7WoQsuL+6d0H563mJC CfxRZrZIKo7drv3sM34uYQACyKYPJZ0/tJgv7nSu+Rmu43SEm+3Vy9nBkheuujOdLQ90o6 psI/lSwb0TMtaIFR2xvcswoSQNTEbeBaHtHIsI1jYIS3VgrfVDBvk9wmUWsbCdYk4xMQdO 0RygtY80Vr/bLaUSG5OVrp23QpUjy7t03d8DE2JWOgI8xBexK4rpX07gOhJXNw== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1661344959; a=rsa-sha256; cv=none; b=iBK2eC3VZIXRyshWxeYQt3Tba5nU5l/dXsGWJ4AsM/BzCLLW1Kc3sIvo+vx5tU5Y5xP0Ce WzDfrZEd2JOb68ZXhgkefE2L/IpHHPMRkiDSKiw+IT6/2uXH0u3cnGI2nfK6W/sOptwgMT DC+3U4EET71wuM8sfQUmMSns66K4PpgeIEU84v/opg8SD9Q/4gpK2DpkgF+HTbWF9DTfdr wEstm7KG/CEdIke6XoEp2pdu11YVtH/yPUgnVeBcsiRhK9Z5KmjV27NpmFXXrM++OEfcVt XchOVSVK2hly8BqxR4pUgur6//pHdyr8wL26da6ZM3W9flDCQ53grTgDc26uQA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20210112 header.b=Qh2D2l6X; dmarc=none; spf=pass (aspmx1.migadu.com: domain of "bug-guix-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="bug-guix-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: 3.69 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20210112 header.b=Qh2D2l6X; dmarc=none; spf=pass (aspmx1.migadu.com: domain of "bug-guix-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="bug-guix-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: 29A901CAF3 X-Spam-Score: 3.69 X-Migadu-Scanner: scn0.migadu.com X-TUID: Yp2eXvLLLnRR * gnu/services/configuration.scm (%unset-value): New variable. (normalize-field-type+def): Use it. (maybe-value-unset?): Use it. --- gnu/services/configuration.scm | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/gnu/services/configuration.scm b/gnu/services/configuration.scm index e2c4fe9998..a9426066b9 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 + %unset-value maybe-value-set? generate-documentation configuration->documentation @@ -172,10 +173,10 @@ (define (normalize-field-type+def s) (values #'(field-type def))) ((field-type) (identifier? #'field-type) - (values #'(field-type 'unset))) + (values #'(field-type %unset-value))) (field-type (identifier? #'field-type) - (values #'(field-type 'unset))))) + (values #'(field-type %unset-value))))) (define (define-configuration-helper serialize? serializer-prefix syn) (syntax-case syn () @@ -301,9 +302,18 @@ (define-configuration stem (field field-type+def (define (empty-serializer field-name val) "") (define serialize-package empty-serializer) +;; Ideally this should be an implementation detail, but we export it +;; to provide a simpler API that enables unsetting a configuration +;; field that has a maybe type, but also a default value. +;; +;; An example use-case would be something like a network application +;; that uses a default port, but the field can explicitly be unset to +;; request a random port at startup. +(define %unset-value 'unset) + (define (maybe-value-set? value) "Predicate to check whether a 'maybe' value was explicitly provided." - (not (eq? 'unset value))) + (not (eq? %unset-value value))) ;; A little helper to make it easier to document all those fields. (define (generate-documentation documentation documentation-name) -- 2.35.1