From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id gMl+Nxzw2mBXxwAAgWs5BA (envelope-from ) for ; Tue, 29 Jun 2021 12:04:12 +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 CFkvMxzw2mBVFwAA1q6Kng (envelope-from ) for ; Tue, 29 Jun 2021 10:04:12 +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 24A8827941 for ; Tue, 29 Jun 2021 12:04:12 +0200 (CEST) Received: from localhost ([::1]:35096 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lyAbC-0003KW-Mp for larch@yhetil.org; Tue, 29 Jun 2021 06:04:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50262) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lyAb5-0003Hr-0N for guix-patches@gnu.org; Tue, 29 Jun 2021 06:04:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:42097) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lyAb4-0001lB-P5 for guix-patches@gnu.org; Tue, 29 Jun 2021 06:04:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lyAb4-0004Ha-Ig for guix-patches@gnu.org; Tue, 29 Jun 2021 06:04:02 -0400 Subject: bug#48976: [PATCH] services: configuration: Allow specifying prefix for serializer names. Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-To: guix-patches@gnu.org Resent-Date: Tue, 29 Jun 2021 10:04:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: cc-closed 48976 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Xinglu Chen Cc: 48976-done@debbugs.gnu.org, Maxim Cournoyer Mail-Followup-To: 48976@debbugs.gnu.org, ludo@gnu.org, public@yoctocell.xyz Received: via spool by 48976-done@debbugs.gnu.org id=D48976.162496101016417 (code D ref 48976); Tue, 29 Jun 2021 10:04:02 +0000 Received: (at 48976-done) by debbugs.gnu.org; 29 Jun 2021 10:03:30 +0000 Received: from localhost ([127.0.0.1]:53642 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lyAaX-0004Gj-TZ for submit@debbugs.gnu.org; Tue, 29 Jun 2021 06:03:30 -0400 Received: from eggs.gnu.org ([209.51.188.92]:52426) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lyAaV-0004GU-Oy for 48976-done@debbugs.gnu.org; Tue, 29 Jun 2021 06:03:28 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:49378) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lyAaQ-0001Mk-0E; Tue, 29 Jun 2021 06:03:22 -0400 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=42524 helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lyAaN-0000Rz-Pb; Tue, 29 Jun 2021 06:03:21 -0400 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= References: <78d519eab8503f4eadf9c57b9d3d4ee07de1450c.1623525052.git.public@yoctocell.xyz> Date: Tue, 29 Jun 2021 12:03:18 +0200 In-Reply-To: <78d519eab8503f4eadf9c57b9d3d4ee07de1450c.1623525052.git.public@yoctocell.xyz> (Xinglu Chen's message of "Sat, 12 Jun 2021 21:17:08 +0200") Message-ID: <87sg11t2c9.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable 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 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1624961052; 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: content-transfer-encoding:content-transfer-encoding:resent-to: 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; bh=eZRxlBfXo3qFmC+S+xVQA704Uq1kgTz8nw+ld+KKWOI=; b=IMtnoN6bT/wu75uuzdM0GT9+xXue7Dr3AKvEMrmxC3UdzXEV+z4ofUlWnVSFJYEdXdb3cS kF/Y2m1bALe9ZY9ZNxotrPZQ8dZGYjy9yNPmjB3aoKwzmuxBCclaOKp+nfHibzTjA1k/O/ eS50bimwnI8sEn4AgIfIC8lhrnjOl+J83tNl/zNO0ZtHLmSBqHTDs3wtHSqfCp0mb9YAKq 7la7UGJxV/QHc0j8CVXjPV/AumlFbAMdev+W0sRFPLV7DNlIqNdCsxguWQPK3ofQmdcS41 YWKITDq5YX0AVg8be64ip+Q32t42pPfiwSeCvqwJeUoCpR3vXkFbj+2n19h81A== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1624961052; a=rsa-sha256; cv=none; b=klzsOvX/sfL3QPZG+Z5vZ9n5rfFtJZBq91I2mE3DWL7yiu4QL30ygZSLlwSSW1xNtzvmlT +dg2CIjyLelw+Rf6+9gd9lPuSHV4v+w4g0etxkAImlzCY9+z3iN/3AqvMUMc3tQaN46KCD Gl1C1Jd8WTLjuXxRiI2E7y3+jBJBHNfGbJwPanC7Rm2v4QOU8MIrBIYKbSA+PtgkSNaENu 3Xyw57E4ddw87xzY6Y6IYTKwJNyv0Zp1b5hZQn/U46SH2M7+txK4AMnslsRbh5ojz2bTTi RRIKwQI2TtASD46P/EX2NZT5Uud8ucQU9yD6TdZlkS8aWu3YEkG7TRSR0UpSSw== 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-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Spam-Score: -1.42 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Queue-Id: 24A8827941 X-Spam-Score: -1.42 X-Migadu-Scanner: scn1.migadu.com X-TUID: bQW4VQEtFFSs Hi, Xinglu Chen skribis: > Sometimes two configurations might have the same types for their field va= lues, > but the values might be serialized in two completely different > ways (e.g. because the two programs have different configuration language= s). > > An example of this would be the =E2=80=98serialize-boolean=E2=80=99 proce= dure in (gnu services > mail) and (gnu services getmail). They both serialize a boolean value, b= ut > because the Dovecot=E2=80=99s configuration language has a different synt= ax to the > configuration language for Getmail, two different procedures have to be > defined. > > One way to workaround this would be to specify custom serializers for many > fields in order to separate the serialization of the values that have the= same > type but serialize in different ways. This could get very tedious, espec= ially > if there are many configurations in the same module. > > Another way would be to move one of the configurations to its own module,= like > what was done with (gnu services getmail). However, this would mean that > there would be multiple modules containing configurations for related > programs, e.g. we have (gnu services mail) and (gnu services getmail), it > doesn=E2=80=99t make much sense to keep the Getmail configuration in its = own module. > > This patch will allow one to write something like this: > > (define-configuration foo-configuration > (bar > (string "bob") > "Option bar.") > (prefix bar-)) > > and the value of the =E2=80=98bar=E2=80=99 field would be serialized usin= g a procedure named > =E2=80=98bar-serialize-string=E2=80=99 instead of just =E2=80=98serialize= -string=E2=80=99. > > * gnu/services/configuration.scm (define-maybe-helper): Accept =E2=80=98p= refix=E2=80=99 > argument for using serializer with custom prefix. > (define-maybe): Pattern match on =E2=80=98prefix=E2=80=99 literal. > (define-configuration-helper): Accept =E2=80=98prefix=E2=80=99 argument f= or using serializer > with custom prefix. > (define-configuration): Pattern match on =E2=80=98prefix=E2=80=99 literal. > * tests/services/configuration.scm ("serialize-configuration with prefix"= ): > New test. Looks reasonable to me. Applied, thanks! Ludo=E2=80=99.