From patchwork Mon Apr 4 11:25:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: M X-Patchwork-Id: 38306 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 CA1A027BBEA; Mon, 4 Apr 2022 12:26:23 +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,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 4CA3E27BBE9 for ; Mon, 4 Apr 2022 12:26:23 +0100 (BST) Received: from localhost ([::1]:39404 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nbKqk-0004p5-Ch for patchwork@mira.cbaines.net; Mon, 04 Apr 2022 07:26:22 -0400 Received: from eggs.gnu.org ([209.51.188.92]:33254) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nbKqQ-0004ow-37 for guix-patches@gnu.org; Mon, 04 Apr 2022 07:26:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:56747) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nbKqP-0004I2-Qx for guix-patches@gnu.org; Mon, 04 Apr 2022 07:26:01 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nbKqP-0005Lx-Ja for guix-patches@gnu.org; Mon, 04 Apr 2022 07:26:01 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#54674] [PATCH] services: configuration: Use *unspecified* instead of 'disabled. Resent-From: Maxime Devos Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Mon, 04 Apr 2022 11:26:01 +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: Attila Lendvai Cc: 54674@debbugs.gnu.org Received: via spool by 54674-submit@debbugs.gnu.org id=B54674.164907152020527 (code B ref 54674); Mon, 04 Apr 2022 11:26:01 +0000 Received: (at 54674) by debbugs.gnu.org; 4 Apr 2022 11:25:20 +0000 Received: from localhost ([127.0.0.1]:50644 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nbKpk-0005L1-6F for submit@debbugs.gnu.org; Mon, 04 Apr 2022 07:25:20 -0400 Received: from andre.telenet-ops.be ([195.130.132.53]:37910) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nbKpi-0005Ks-7D for 54674@debbugs.gnu.org; Mon, 04 Apr 2022 07:25:19 -0400 Received: from [172.20.10.5] ([188.188.236.140]) by andre.telenet-ops.be with bizsmtp id EbRF2700C32RwxY01bRF5g; Mon, 04 Apr 2022 13:25:16 +0200 Message-ID: From: Maxime Devos Date: Mon, 04 Apr 2022 13:25:11 +0200 In-Reply-To: References: <20220401191957.16624-1-attila@lendvai.name> <2f39bf8cd56b3019026e43532b2f7b937de99b7e.camel@telenet.be> User-Agent: Evolution 3.38.3-1 MIME-Version: 1.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telenet.be; s=r22; t=1649071516; bh=32bzLeOiOKTTSD9Wy/wtxIGO7L+4liqAIrvEYr5CgeQ=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=Iwx89byT+dniiQzhG4lO6hqrarnvl0eKACiMLxTZFFP7zAUneXTkYKvZS58Un+56X DZ3Ci6ZD4dpukTEbyUosxf7thXi3OSHPWzwb3pnfGatL79BanpMoQxkTxHS4jAV1YN 0tUCXTmZe9uKXm4U/+gObhUpH/IEP2KsWX9ngFQxjkaklMiz+cC9mWPhfoPyfRiAqY edXykuZCXaeoFFiGHSJiREYFd16HgBXZWHK3SVVW0+yPbWlUisunvV8RMMqdQZ+E2U oBuiPjKvyI8u5Mu3Cn7fT7KcxViiuvP2X9q+Jp0NrKyyqSMhz7wowxsPY3g/K3tQto S084dJqP8XbNA== 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 Attila Lendvai schreef op ma 04-04-2022 om 07:46 [+0000]: > in this change i try to introduce a codepath for a canonical form for > DEFINE-CONFIGURATION fields, but it won't work this way, because this > way the SYNTAX-CASE forms will only match when *every* field is of > the specified shape. See attachement for poposed solution. (Not done: *unspecified* instead of the symbol 'disabled' as default). Greetings, Maxime. diff --git a/gnu/services/configuration.scm b/gnu/services/configuration.scm index 0de350a4df..06bb73c9fa 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,9 +163,21 @@ does not have a default value" field kind))) (define-syntax-rule (define-maybe/no-serialization stem) (define-maybe stem (no-serialization))) +(define (analyse-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))))) + (define (define-configuration-helper serialize? serializer-prefix syn) (syntax-case syn () - ((_ stem (field (field-type def ...) doc custom-serializer ...) ...) + ((_ stem (field field-type+def doc custom-serializer ...) ...) + ;; TODO: fix indentation, maybe with-syntax*? + (with-syntax ((((field-type def ...) ...) + (map analyse-field-type+def #'(field-type+def ...)))) (with-syntax (((field-getter ...) (map (lambda (field) (id #'stem #'stem #'- field)) @@ -233,7 +246,7 @@ does not have a default value" field kind))) (let ((conf (#,(id #'stem #'% #'stem) arg (... ...)))) (validate-configuration conf #,(id #'stem #'stem #'-fields)) - conf))))))) + conf)))))))) (define no-serialization ;syntactic keyword for 'define-configuration' '(no serialization)) @@ -241,26 +254,26 @@ does not have a default value" field kind))) (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)))