From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id UH2BJMUdBmOYQwAAbAwnHQ (envelope-from ) for ; Wed, 24 Aug 2022 14:47:01 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id CHJ2I8UdBmOXCwAAG6o9tA (envelope-from ) for ; Wed, 24 Aug 2022 14:47:01 +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 33E4639B82 for ; Wed, 24 Aug 2022 14:47:01 +0200 (CEST) Received: from localhost ([::1]:44296 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oQpme-0003HK-8x for larch@yhetil.org; Wed, 24 Aug 2022 08:47:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34010) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oQphr-0005Pm-Cg for bug-guix@gnu.org; Wed, 24 Aug 2022 08:42:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:56177) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oQphq-0000mc-HF 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 1oQphq-00083B-9Q for bug-guix@gnu.org; Wed, 24 Aug 2022 08:42:02 -0400 X-Loop: help-debbugs@gnu.org Subject: bug#56799: [PATCH 3/5] services: configuration: Add maybe-value exported procedure. Resent-From: Attila Lendvai Original-Sender: "Debbugs-submit" Resent-CC: bug-guix@gnu.org Resent-Date: Wed, 24 Aug 2022 12:42:02 +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.166134487230842 (code B ref 56799); Wed, 24 Aug 2022 12:42:02 +0000 Received: (at 56799) by debbugs.gnu.org; 24 Aug 2022 12:41:12 +0000 Received: from localhost ([127.0.0.1]:45917 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oQph2-00081H-7h for submit@debbugs.gnu.org; Wed, 24 Aug 2022 08:41:12 -0400 Received: from mail-ej1-f52.google.com ([209.85.218.52]:43882) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oQph0-00080x-GP for 56799@debbugs.gnu.org; Wed, 24 Aug 2022 08:41:10 -0400 Received: by mail-ej1-f52.google.com with SMTP id gb36so33239661ejc.10 for <56799@debbugs.gnu.org>; Wed, 24 Aug 2022 05:41:10 -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=BXzFccNAioTNrtwtKF1NfWTp3i9MpLbsWl+Ya2NR4ks=; b=h65RWbrEx/xIhskx/YUfaFc22T44XAOHALL3N3w9vV8Wx5FZYdCZQt7PyCjFxkxKfu Ds8NKAMe2gYlVh8lb+xyW04XDBrommgVBsugYVaiT/qKvTa6DUaDWpj6PG835VodqA74 yIwB9ziLpu88uuqhB39rQFB9szT21gGRqQAo+RSFDPGaQ/5tWHAUJTU8wrpFCwXq3Ttq 1sAOKY2UlSulVb94lTP+XL097SJvbOvB/FLhaGAyvnQKPHJa+X8DbY+/QwEGV1wRYVTb DVLS9A97iwbDkDqGEtRlsE3FBj5KYcG9Eu+ZFj7nIUh9h5FhJ1Mj3UXpODX2+KxZsykX Lr4w== 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=BXzFccNAioTNrtwtKF1NfWTp3i9MpLbsWl+Ya2NR4ks=; b=O74iOwaTdt3VCkaUZVhRH9TVjkAJQTsFr6RZ9SbTPnQs/dxCGHAgoHdUYjAURYocFc bzCDl+6L5kbb4Kyt9aT2xZFtRG89ea/cIeG1Mv9x47GlSF2uaBpmgWnMMNI3hApe//6g lydsml65hxrp37xsPFlAfyk2l2GFFXGv0D1dN19brfz8o83DQ9dSAkY1K0YcDxsiCwbk N6DLRW68gW6rIZxTnPbi8EfdYtJAIM70YmLP/2FQhRRTMyq4Lt2yluokkR0k113PK2XJ IrxJ2ao8aVECqxY31MVReHMYrfQSBNR8ByJoN4tE9sIfNWih02MwGMCUTdokOL2puRc/ pcHg== X-Gm-Message-State: ACgBeo31kH0G9G32JOorTv+4X4yCNBrMlrWZk7sT0eWZuAQVvyrxa6VR /fTz+XtdBApkrbbdjm6xc/BhKiPOnuI= X-Google-Smtp-Source: AA6agR5q4YkHKQxam7o6gtZHMXj+4ct1MWtBumA2rZ84/YXQORAlV424r+dNIdQuJ4/SRBXxWFAGeQ== X-Received: by 2002:a17:906:eecb:b0:73c:5c85:142b with SMTP id wu11-20020a170906eecb00b0073c5c85142bmr2800691ejb.433.1661344864873; Wed, 24 Aug 2022 05:41:04 -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.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Aug 2022 05:41:04 -0700 (PDT) From: Attila Lendvai Date: Wed, 24 Aug 2022 14:40:40 +0200 Message-Id: <20220824124042.10959-3-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=1661345221; 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=BXzFccNAioTNrtwtKF1NfWTp3i9MpLbsWl+Ya2NR4ks=; b=CokSTWrcKEShwNxaVbLmgp6WwoYwcWOhvSeEJjeFCmn0n/vIZpBudRzOhSdOVjQ2A+d984 yFypifJGuhIlBdAN/LBB8A2JliigFCLdkAnPOHFI2Trd+VkZ7ztvFkEV4Dre+LMrPs18CY +16Kl1j6Xd9cxz7GcX/6H0JlNb30hHvCMgzVqen2fIIO7/k9lIubth27l6z0NZX+IhcdcF JR5I+TP/UGpmWzJnpah6412xYtAwkYwYQRkcDJDvxTxd8ss/QfvOR0OWK8IMRTDGc/o9r5 aeU/4FnE6MmRIibUd7VD+5VWpDduzpjGzZMoMKDLHe0bwoqGP3f8ZJFi2ym5eQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1661345221; a=rsa-sha256; cv=none; b=l2RzESve6Ucen4nvfaZQmlWbXiwjGKnxhGEZOlSPIXArjn4L0VZmYhkKjLJ0cGrb28v+yI i9aMpEaQGL6ovuXoe693/2djFj2Aaza65eKMg3Y3ovjD5xS58m9PVYg/Br1ZIuOUgytkw0 c77ZrxHk6gg2v9o2ItOT9hJHgZ0U7FMW0Gh9vIawAWoxZ/1IFpMM8QfSaaxmW2stsmzoGJ 29y4XqlOHNZbMA98h0gQc6/FiqY7muOqlx8GZ25aowsI8A7DUTEpEYB/j2NgGE3Ga93cwh TPRZQ2VD3Bafk/3r64pCspBW9kJrtTry00khaLo42qiDrwVQSFmhwp24pNakdQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20210112 header.b=h65RWbrE; 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.19 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20210112 header.b=h65RWbrE; 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: 33E4639B82 X-Spam-Score: 3.19 X-Migadu-Scanner: scn0.migadu.com X-TUID: mRRYQZHlxrjn * gnu/services/configuration.scm (maybe-value): New procedure. --- gnu/services/configuration.scm | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/gnu/services/configuration.scm b/gnu/services/configuration.scm index a9426066b9..60965486a7 100644 --- a/gnu/services/configuration.scm +++ b/gnu/services/configuration.scm @@ -58,6 +58,7 @@ (define-module (gnu services configuration) define-maybe define-maybe/no-serialization %unset-value + maybe-value maybe-value-set? generate-documentation configuration->documentation @@ -315,6 +316,15 @@ (define (maybe-value-set? value) "Predicate to check whether a 'maybe' value was explicitly provided." (not (eq? %unset-value value))) +;; Ideally there should be a compiler macro for this predicate, that expands +;; to a conditional that only instantiates the default value when needed. +(define* (maybe-value value #:optional (default #f)) + "Returns VALUE, unless it is the unset value, in which case it returns +DEFAULT." + (if (maybe-value-set? value) + value + default)) + ;; 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.35.1