From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:8:6d80::]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id +NMuBe8Me2BF3gAAgWs5BA (envelope-from ) for ; Sat, 17 Apr 2021 18:29:35 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id aKpXO+4Me2DtPQAA1q6Kng (envelope-from ) for ; Sat, 17 Apr 2021 16:29:34 +0000 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 6D41A1711B for ; Sat, 17 Apr 2021 18:29:34 +0200 (CEST) Received: from localhost ([::1]:41036 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lXnp7-0005ZV-Cm for larch@yhetil.org; Sat, 17 Apr 2021 12:29:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55180) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lXnos-0005ZN-I1 for guix-devel@gnu.org; Sat, 17 Apr 2021 12:29:18 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:36167) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lXnos-0000Da-AO; Sat, 17 Apr 2021 12:29:18 -0400 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=41666 helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1lXnor-0004lC-HY; Sat, 17 Apr 2021 12:29:18 -0400 From: =?utf-8?Q?Ludovic_Court=C3=A8s?= To: Maxim Cournoyer Subject: Re: Add a way to disable serialization support to (guix services configuration) References: <878s5ncjaw.fsf@gmail.com> X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: 28 Germinal an 229 de la =?utf-8?Q?R=C3=A9volution?= X-PGP-Key-ID: 0x090B11993D9AEBB5 X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc X-PGP-Fingerprint: 3CE4 6455 8A84 FDC6 9DB4 0CFB 090B 1199 3D9A EBB5 X-OS: x86_64-pc-linux-gnu Date: Sat, 17 Apr 2021 18:29:15 +0200 In-Reply-To: <878s5ncjaw.fsf@gmail.com> (Maxim Cournoyer's message of "Mon, 12 Apr 2021 16:57:43 -0400") Message-ID: <87fszoswmc.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-BeenThere: guix-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: guix-devel Errors-To: guix-devel-bounces+larch=yhetil.org@gnu.org Sender: "Guix-devel" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1618676974; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post; bh=uAatJZO+xymDJ3/0oQhyMNBaqrNT85QrxWcFsOIvgwQ=; b=vDazZ37i9PUNNb8R+jihPmzK75tLKDN4lEHbhVhk4gs3uzjHpzKwnz7gFx3AtMFU+EgHzK Sd4dlrq32AJ2jFWeW/32HI5gkgfymc0AZN75NhA+5C7NK/rCIqWlcwheRwYy91kXJKZWFU rxUViedNSj+bsw8P/x8PtP4nGbZqXb603KQUsx97M+8Uzrqmg+TAQHMNHQYmR1ptPG2GTB KYCOLed31d9xHB1PqWlk00WGVUKr+3oCYovC/aBwuAigv329aNvblmLciPqh61ewXQVhXR ybhp/jaZOPCTYnmpAQtqJtwacoNWPOvbr5sjTlB04UVjAfzfzgt3NPrCOr9+Cw== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1618676974; a=rsa-sha256; cv=none; b=hcDjo5tfcvzaSWeoNfRA6QJLBF9k1PS2HXYy920Xii/9xyryHVbJgOyxydYOvRUmTIcPHe M+lcQm7GdVp+CLqjcw9tn308KSYBkGYusSvCgmSgZrnJYCTdPAaY1BW4pxSanPc6tT4wRD sIBf1YFC7s9aHvpWXrzOMItjG0cIkirSFE5wcxOA+BzLs2aoMPWXjbUAGn4OY27yACui4s zt11IOzS9AOrc7hLpwxYLx4UjmE/9svCRsDW6N5fTQQZ+W7hj6gxKgb+ffqKAklZtXcINK XfMwb0SxCO0Mq88DLhxw6zqFRPThEbYIjLOJnDc1jWr8Ub7DaNAVjMH4nY12+g== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of guix-devel-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-devel-bounces@gnu.org X-Migadu-Spam-Score: -1.44 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of guix-devel-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-devel-bounces@gnu.org X-Migadu-Queue-Id: 6D41A1711B X-Spam-Score: -1.44 X-Migadu-Scanner: scn0.migadu.com X-TUID: 5V1Ox1sd9/PL --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hi Maxim, Maxim Cournoyer skribis: > I've rediscovered the little gem that is (guix services configurations), > and attempted to make it more generally useful by adding an option to > opt out of serialization (which is not well adapted for producing a list > of command line arguments from the configuration for example): In the meantime I saw you discuss this on #guile so maybe you=E2=80=99ve so= lved the issue now? If not, attached is a possible solution and example. It=E2=80=99s not perf= ect: in the example, you=E2=80=99ll get a warning about =E2=80=98serialize-integ= er=E2=80=99 being unbound, which is completely harmless but suboptimal. Not sure how to address that. HTH! Ludo=E2=80=99. --=-=-= Content-Type: text/x-patch Content-Disposition: inline diff --git a/gnu/services/configuration.scm b/gnu/services/configuration.scm index 90f12a8d39..20e1647335 100644 --- a/gnu/services/configuration.scm +++ b/gnu/services/configuration.scm @@ -109,6 +109,9 @@ (define (serialize-maybe-stem field-name val) (if (stem? val) (serialize-stem field-name val) "")))))))) +(define-syntax-parameter configuration-field-serialization? + (identifier-syntax #t)) + (define-syntax define-configuration (lambda (stx) (syntax-case stx () @@ -123,7 +126,8 @@ #'(field-type ...))) ((field-serializer ...) (map (lambda (type) - (id #'stem #'serialize- type)) + #`(and configuration-field-serialization? + #,(id #'stem #'serialize- type))) #'(field-type ...)))) #`(begin (define-record-type* #,(id #'stem #'< #'stem #'>) @@ -152,6 +156,16 @@ #,(id #'stem #'stem #'-fields)) conf)))))))) +(define-syntax-rule (without-field-serialization definition) + (syntax-parameterize ((configuration-field-serialization? + (identifier-syntax #f))) + definition + #t)) + +(without-field-serialization + (define-configuration foo + (bar (integer 123) "doc"))) + (define (serialize-package field-name val) "") --=-=-=--