GNU bug report logs - #63985
[PATCH RFC 0/5] Generic INI serializer & SRFI-171 for define-configuration

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: guix-patches; Reported by: Bruno Victal <mirai@HIDDEN>; Keywords: patch; dated Fri, 9 Jun 2023 21:19:02 UTC; Maintainer for guix-patches is guix-patches@HIDDEN.

Message received at 63985 <at> debbugs.gnu.org:


Received: (at 63985) by debbugs.gnu.org; 25 Sep 2023 14:06:31 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Sep 25 10:06:31 2023
Received: from localhost ([127.0.0.1]:46369 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1qkmEJ-0002MJ-4c
	for submit <at> debbugs.gnu.org; Mon, 25 Sep 2023 10:06:31 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:54034)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <ludo@HIDDEN>) id 1qkmEG-0002M6-Mc
 for 63985 <at> debbugs.gnu.org; Mon, 25 Sep 2023 10:06:29 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <ludo@HIDDEN>)
 id 1qkmDy-0000fG-7J; Mon, 25 Sep 2023 10:06:10 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=MIME-Version:In-Reply-To:Date:References:Subject:To:
 From; bh=95GX6SXCZCEiZJByFahwarYSEKa0Z+rZqRiXdl9I2is=; b=mVSDQ3q9Oz0N2OPN/BBp
 W1WC8siRNcj958eNHyi6DIGnjWm0gnHV4U+A7BGsr/PAFHuFwi2PiApYFg+nEXAgvXDydfI0SqWPe
 r3dr5kRh2X4M1KVfT5jNSwRk2oqQbfrbBDdyBAERrothDQFNAWp03u1u2g+kjZ9Rg8jtw5r6q2fdT
 AxUxCtG0bg/KlnG2HkwM/0fPqE3KXrN6L4qsRvCmWxuo24IdhZZ1KEm+kv2DkhCJFq2NBOUSiQ6V6
 S+9oa2wEmEIW8tRIxh+9iGS6DELgkLVj7SlfS8c3RIAu5RYar9YB3TOueQCkDzlO5SWgn5lJmUn1N
 cMZH7rEm+XzQYg==;
From: =?utf-8?Q?Ludovic_Court=C3=A8s?= <ludo@HIDDEN>
To: Liliana Marie Prikler <liliana.prikler@HIDDEN>
Subject: Re: [bug#63985] [PATCH v3 00/11] Service subsystem improvements
References: <cover.1686343642.git.mirai@HIDDEN>
 <cover.1687816304.git.mirai@HIDDEN>
 <5613dc86-54ac-4bdb-b75a-400b1cb124bf@HIDDEN>
 <6445e508cbc8a9f92d3a54263193936d168cd7cf.camel@HIDDEN>
X-URL: http://www.fdn.fr/~lcourtes/
X-Revolutionary-Date: Quartidi 4 =?utf-8?Q?Vend=C3=A9miaire?= an 232 de la
 =?utf-8?Q?R=C3=A9volution=2C?= jour de la Colchique
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: Mon, 25 Sep 2023 16:06:03 +0200
In-Reply-To: <6445e508cbc8a9f92d3a54263193936d168cd7cf.camel@HIDDEN>
 (Liliana Marie Prikler's message of "Sat, 16 Sep 2023 23:55:59 +0200")
Message-ID: <87v8by5ovo.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 63985
Cc: 63985 <at> debbugs.gnu.org, Bruno Victal <mirai@HIDDEN>,
 maxim.cournoyer@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

Hello!

Liliana Marie Prikler <liliana.prikler@HIDDEN> skribis:

> I'm not sure whether serializer options really add much value.  You can
> use functional programming to define serializers for you and pass those
> options in a cleaner way IMHO.  The documentation should be updated as
> the changes are made.  As for the switch to SRFI 171, I'm not sure
> whether backwards compatibility with Guile 2.2 is a requirement
> somewhere; if it isn't, that change is probably fine.

Backward compatibility with 2.2 is not required in the service code.

(The places where compatibility with 2.2 or even 2.0 may be required are
some of the (guix build =E2=80=A6) modules and core (guix =E2=80=A6) module=
s, the latter
so that a very old Guix can still pull the new one.)

Ludo=E2=80=99.




Information forwarded to guix-patches@HIDDEN:
bug#63985; Package guix-patches. Full text available.

Message received at 63985 <at> debbugs.gnu.org:


Received: (at 63985) by debbugs.gnu.org; 23 Sep 2023 15:22:55 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Sep 23 11:22:55 2023
Received: from localhost ([127.0.0.1]:40323 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1qk4T9-0003xM-70
	for submit <at> debbugs.gnu.org; Sat, 23 Sep 2023 11:22:55 -0400
Received: from mail-lf1-x142.google.com ([2a00:1450:4864:20::142]:49461)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <liliana.prikler@HIDDEN>) id 1qk4T4-0003x7-Jj
 for 63985 <at> debbugs.gnu.org; Sat, 23 Sep 2023 11:22:53 -0400
Received: by mail-lf1-x142.google.com with SMTP id
 2adb3069b0e04-5041cc983f9so6079743e87.3
 for <63985 <at> debbugs.gnu.org>; Sat, 23 Sep 2023 08:22:39 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1695482553; x=1696087353; darn=debbugs.gnu.org;
 h=mime-version:user-agent:content-transfer-encoding:references
 :in-reply-to:date:cc:to:from:subject:message-id:from:to:cc:subject
 :date:message-id:reply-to;
 bh=fKrtwjof7UxFDgmEKKIzkDcLrtGAu/v/x1R0zNwoVHA=;
 b=hRQF4bMtzeE9ZE6+AXcDlZF1xCiSmxegOPP0WlL+B7St7q9LZjtiAEkaUg38i1jUHQ
 uDH+Gd7+oo+hA+QIlzignlusdjvpluzMO+8qYTls2GJd+VdGDQuy+t9VQMU9hy1fzlZb
 61T9FgXxTmFRfGLq0HKWkWKr2UEcJ24pa4Z4JSCf+J/RKVQr5wfX95cwFpz2cPPLxWE8
 FpAp8axrVqp64QWJqfCXgVoczH/5xy3cTsSNUO6K2E+F/KP0XuPNzCI7yww/ITrRa+oH
 pV05GVf1G1sjyep+fELXArDS8rxqzJGf6TjP6Uj17RQiPR78fwVOTSSjCwGaiJwOwCK0
 8hyA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1695482553; x=1696087353;
 h=mime-version:user-agent:content-transfer-encoding:references
 :in-reply-to:date:cc:to:from:subject:message-id:x-gm-message-state
 :from:to:cc:subject:date:message-id:reply-to;
 bh=fKrtwjof7UxFDgmEKKIzkDcLrtGAu/v/x1R0zNwoVHA=;
 b=MJgMLEZ6eMIBtqswqbWY1YLwJ6eBNsrEBQlN6e/CNk+mb1jBFvdDgAFRTOQtMZp3J0
 6ZbM8wyN/9GNWvVOa3nlUkATbH18XlumW12+4VuRpljBShKXCraMdKS2kMf3T6ArFSGC
 kvIsUxgQgAQJUGTFg2YOy7LxQc4hBVl+67Yihty7HVUXJtXjvQyZL58Ud7zSMUoTARCN
 FQ3hDdGkvYJcAHyievc1zOMEZuM1HxUsN3G3yfS0eGcsrAEgnENia7prDhcjK6479Kl8
 3UlnxAnmxzBvJotbbYHmUgxD5zeDm/dSMysGu7lQQD0hLxW+Ofud7dZTm0+Ay4Nf3sO4
 Z5DA==
X-Gm-Message-State: AOJu0YwAktlH9q61icinOFUQYoHm6idHa6shcr/BMRZWoCX2oY2bA5ZB
 3+DBqYfLrSFkaggV3FRFUag=
X-Google-Smtp-Source: AGHT+IEnCp60RBeTsaWgmdvsoIQc3FQsrhCGGoh3EG16N8o552QdBIAS2TuDCaM0skOtDpCZBrq8BQ==
X-Received: by 2002:a19:6756:0:b0:500:b88c:ea79 with SMTP id
 e22-20020a196756000000b00500b88cea79mr1908540lfj.54.1695482552996; 
 Sat, 23 Sep 2023 08:22:32 -0700 (PDT)
Received: from lumine.fritz.box (85-127-52-93.dsl.dynamic.surfer.at.
 [85.127.52.93]) by smtp.gmail.com with ESMTPSA id
 w22-20020a056402071600b0052e1783ab25sm3444311edx.70.2023.09.23.08.22.31
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Sat, 23 Sep 2023 08:22:32 -0700 (PDT)
Message-ID: <a8e9962227712364cdf992b2d470af93132080ea.camel@HIDDEN>
Subject: Re: [bug#63985] [PATCH v3 00/11] Service subsystem improvements
From: Liliana Marie Prikler <liliana.prikler@HIDDEN>
To: Bruno Victal <mirai@HIDDEN>
Date: Sat, 23 Sep 2023 17:22:29 +0200
In-Reply-To: <43394365-673f-4058-a11b-74cfef202e30@HIDDEN>
References: <cover.1686343642.git.mirai@HIDDEN>
 <cover.1687816304.git.mirai@HIDDEN>
 <5613dc86-54ac-4bdb-b75a-400b1cb124bf@HIDDEN>
 <6445e508cbc8a9f92d3a54263193936d168cd7cf.camel@HIDDEN>
 <43394365-673f-4058-a11b-74cfef202e30@HIDDEN>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
User-Agent: Evolution 3.46.4 
MIME-Version: 1.0
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 63985
Cc: 63985 <at> debbugs.gnu.org, ludo@HIDDEN, maxim.cournoyer@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Am Samstag, dem 23.09.2023 um 14:35 +0100 schrieb Bruno Victal:
> On 2023-09-16 22:55, Liliana Marie Prikler wrote:
> > I'm not sure whether serializer options really add much value.=C2=A0 Yo=
u
> > can use functional programming to define serializers for you and
> > pass those options in a cleaner way IMHO.=C2=A0 The documentation shoul=
d
> > be updated as the changes are made.=C2=A0 As for the switch to SRFI 171=
,
> > I'm not sure whether backwards compatibility with Guile 2.2 is a
> > requirement somewhere; if it isn't, that change is probably fine.
>=20
> Is SRFI-171 not available in Guile 2.2?
> Your last remark surprised me though: is Guix not running with Guile
> 3.0?  I was the impression that this was the case since otherwise
> wouldn't this imply that `spawn' & co. can't be used anywhere?
Nope, it was introduced with 3.0.  Again, "I'm not sure" meaning "I
don't know".  Would be nice to have another reviewer check this. =C2=A0
(Looking at CC:) Maxim? Ludo?

>=20
> > (=E2=80=A6) The question is how necessary it
> > will be for us to maintain our own INI format writer.=C2=A0
> > NetworkManager is one use case, but perhaps we have others (perhaps
> > even in the gnome world =E2=80=93 gdm maybe?)
>=20
> Certainly there are many applications that make use of INI-like files
> for configuration and for INI ones it would be convenient, though I
> should caution that there are many things that can look like INI but
> aren't:
>=20
> * NetworkManager accepts some entries that have append behavior via
> 'KW +=3D val' and have repetition. In some cases I think the ordering
> matters too. (Since our define-configuration definition for it
> doesn't attempt to fully cover every nook and cranny of it I think
> using INI here doesn't hurt.)
>=20
> * TOML
>=20
> * Files that can have leading entries but without a section. These
> can be thought to belong to some top level but invisible section yet
> the generic-ini doesn't handle these. (yet)
>=20
>=20
> There's some assumptions I made while writing generic-ini which make
> it not as generic as imparted by its name and as such, it can only be
> used in the following conditions:
>=20
> * The ordering of the entries and sections doesn't matter.
> * Every entry belongs to a section.
> * (=E2=80=A6 perhaps more? =E2=80=A6)
Some of these look like bugs, others are a result of trying to cover
too much.  Let's perhaps just cover the simple case of=20

[maybe a section]
<var> <op> <val>

where <op> will almost always be "=3D" rather than worrying about the
specification of e.g. TOML.  If needed, a TOML-specific module can
hopefully reuse the procedures by which we produce INI files.

> >=20
> > (=E2=80=A6) at the point you currently feel comfortable with
> > and work from there.
> >=20
> > WDYT?
>=20
> I'm inclined to write-off the generic-ini though as discussed above,
> there's some demand for some kind of INI format writer so personally
> I'd be OK with temporarily maintaining this writer if we can really
> make it an experiment/true to the word =E2=80=9Ctemporary=E2=80=9D thing.=
 This would
> mean that:
>=20
> * It should be only used internally by services living in Guix
> repository. I'm OK with going around and reworking/replacing usages
> of it when the time comes to retire it/when guile gets this INI thing
> natively. (i.e. #:export (=E2=80=A6) doesn't mean that I'm intending it t=
o
> be used outside of the repo with stability promises.)
>=20
>=20
> WDYT?
Do you have commit access?  The only real place where you can
experiment in the (guix) namespace is on feature branches and if you
feel like you need to experiment further, I'd recommend doing so.  If
not, you could roll out a channel with an extension like the one that
was uses for (guix home)=C2=B9.  You might also want to reach out to guix-
devel to try and explain your approach to everyone in terms of how it
would simplify writing services.

Cheers

=C2=B9 I think the Guix Home thing itself shows that you can put
technological previews to Guix itself and have them tested (and
depended on!) by many.  This may or may not be what you want, there
sadly isn't a "clean" option.




Information forwarded to guix-patches@HIDDEN:
bug#63985; Package guix-patches. Full text available.

Message received at 63985 <at> debbugs.gnu.org:


Received: (at 63985) by debbugs.gnu.org; 23 Sep 2023 13:35:41 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Sep 23 09:35:41 2023
Received: from localhost ([127.0.0.1]:37997 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1qk2nM-0006AF-If
	for submit <at> debbugs.gnu.org; Sat, 23 Sep 2023 09:35:40 -0400
Received: from smtpmciv1.myservices.hosting ([185.26.107.237]:44014)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <mirai@HIDDEN>) id 1qk2nF-0006A0-Mj
 for 63985 <at> debbugs.gnu.org; Sat, 23 Sep 2023 09:35:39 -0400
Received: from mail1.netim.hosting (unknown [185.26.106.173])
 by smtpmciv1.myservices.hosting (Postfix) with ESMTP id BCA8520DF8;
 Sat, 23 Sep 2023 15:35:10 +0200 (CEST)
Received: from localhost (localhost [127.0.0.1])
 by mail1.netim.hosting (Postfix) with ESMTP id DFAE280095;
 Sat, 23 Sep 2023 15:35:06 +0200 (CEST)
X-Virus-Scanned: Debian amavisd-new at mail1.netim.hosting
Received: from mail1.netim.hosting ([127.0.0.1])
 by localhost (mail1-2.netim.hosting [127.0.0.1]) (amavisd-new, port 10026)
 with ESMTP id R9cEFaLhYRS0; Sat, 23 Sep 2023 15:35:06 +0200 (CEST)
Received: from [192.168.1.116] (unknown [10.192.1.83])
 (Authenticated sender: lumen@HIDDEN)
 by mail1.netim.hosting (Postfix) with ESMTPSA id 5B3E380092;
 Sat, 23 Sep 2023 15:35:05 +0200 (CEST)
Message-ID: <43394365-673f-4058-a11b-74cfef202e30@HIDDEN>
Date: Sat, 23 Sep 2023 14:35:04 +0100
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
Subject: Re: [bug#63985] [PATCH v3 00/11] Service subsystem improvements
Content-Language: en-US
To: Liliana Marie Prikler <liliana.prikler@HIDDEN>
References: <cover.1686343642.git.mirai@HIDDEN>
 <cover.1687816304.git.mirai@HIDDEN>
 <5613dc86-54ac-4bdb-b75a-400b1cb124bf@HIDDEN>
 <6445e508cbc8a9f92d3a54263193936d168cd7cf.camel@HIDDEN>
From: Bruno Victal <mirai@HIDDEN>
In-Reply-To: <6445e508cbc8a9f92d3a54263193936d168cd7cf.camel@HIDDEN>
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 63985
Cc: 63985 <at> debbugs.gnu.org, ludo@HIDDEN, maxim.cournoyer@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

On 2023-09-16 22:55, Liliana Marie Prikler wrote:
> I'm not sure whether serializer options really add much value.  You can
> use functional programming to define serializers for you and pass those
> options in a cleaner way IMHO.  The documentation should be updated as
> the changes are made.  As for the switch to SRFI 171, I'm not sure
> whether backwards compatibility with Guile 2.2 is a requirement
> somewhere; if it isn't, that change is probably fine.

Is SRFI-171 not available in Guile 2.2?
Your last remark surprised me though: is Guix not running with Guile 3.0?
I was the impression that this was the case since otherwise wouldn't this
imply that `spawn' & co. can't be used anywhere?

> Even if Guile implemented SRFI 233 now, I'm not sure we could use it
> tomorrow.  And even once we can use SRFI 233, we can keep backwards-
> compatibility be re-exporting things. (…)

In that aspect I'm willing to be patient vs. maintaining a temporary
(read as: permanent) code though I think that it should be possible to
make it backwards-compatible, even if we completely gut out its innards
later and replace them with SRFI-233.

> (…) The question is how necessary it
> will be for us to maintain our own INI format writer.  NetworkManager
> is one use case, but perhaps we have others (perhaps even in the gnome
> world – gdm maybe?)

Certainly there are many applications that make use of INI-like files
for configuration and for INI ones it would be convenient, though I
should caution that there are many things that can look like INI but
aren't:

* NetworkManager accepts some entries that have append behavior via
'KW += val' and have repetition. In some cases I think the ordering
matters too. (Since our define-configuration definition for it
doesn't attempt to fully cover every nook and cranny of it I think
using INI here doesn't hurt.)

* TOML

* Files that can have leading entries but without a section. These
can be thought to belong to some top level but invisible section yet
the generic-ini doesn't handle these. (yet)


There's some assumptions I made while writing generic-ini which make
it not as generic as imparted by its name and as such, it can only be
used in the following conditions:

* The ordering of the entries and sections doesn't matter.
* Every entry belongs to a section.
* (… perhaps more? …)

>> Naturally these are no longer relevant if this generic-ini module
>> approach is abandoned.
> I think we can still upgrade this to define-configuration without a
> generic-ini, but see above.  That being said, we can certainly split> this into two series (…)

Sure.

> (…) at the point you currently feel comfortable with
> and work from there.
> 
> WDYT?

I'm inclined to write-off the generic-ini though as discussed above,
there's some demand for some kind of INI format writer so personally
I'd be OK with temporarily maintaining this writer if we can really
make it an experiment/true to the word “temporary” thing. This would
mean that:

* It should be only used internally by services living in Guix
repository. I'm OK with going around and reworking/replacing usages
of it when the time comes to retire it/when guile gets this INI thing
natively. (i.e. #:export (…) doesn't mean that I'm intending it to
be used outside of the repo with stability promises.)


WDYT?

-- 
Furthermore, I consider that nonfree software must be eradicated.

Cheers,
Bruno.




Information forwarded to guix-patches@HIDDEN:
bug#63985; Package guix-patches. Full text available.

Message received at 63985 <at> debbugs.gnu.org:


Received: (at 63985) by debbugs.gnu.org; 16 Sep 2023 21:56:20 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Sep 16 17:56:20 2023
Received: from localhost ([127.0.0.1]:48691 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1qhdH1-0003km-PZ
	for submit <at> debbugs.gnu.org; Sat, 16 Sep 2023 17:56:20 -0400
Received: from mail-ed1-x542.google.com ([2a00:1450:4864:20::542]:54356)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <liliana.prikler@HIDDEN>) id 1qhdGy-0003kS-2y
 for 63985 <at> debbugs.gnu.org; Sat, 16 Sep 2023 17:56:18 -0400
Received: by mail-ed1-x542.google.com with SMTP id
 4fb4d7f45d1cf-52a5c0d949eso3889903a12.0
 for <63985 <at> debbugs.gnu.org>; Sat, 16 Sep 2023 14:56:08 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1694901362; x=1695506162; darn=debbugs.gnu.org;
 h=mime-version:user-agent:content-transfer-encoding:references
 :in-reply-to:date:cc:to:from:subject:message-id:from:to:cc:subject
 :date:message-id:reply-to;
 bh=QkdKiA52I7Hgt7jsroPqx+AsUKj7Ib1XlI65Uw6Aoy8=;
 b=ndt4iDP6Trhc48C+RbDf7BpC73/PnLcPTNpLd2sLyzB0LHp+cpDPmc6FwMWqL6jDk7
 WkLUFQXKpEr3LZRa8VymT5f19Lxia+Z+K3rMHS1wgXmCZMO/S0B179y/hq23uRM+2lxX
 0rmiwS+dgsKctWF48IEAe1CZaOT2yujvCNO9hBgncKL/o+OIjmt7q5w+a5Y19KvgHA0n
 J9MXbQ88ivfGgO6hakkubcM3NBa17Xrmq+ooxzSsToDAEcGguu7q+ubVUJkiSwJagqoq
 QgKMS0kP1khL2UDFcBtr1qpbIOGiSPR9tkY5Mnk3Qe+8A1AIGvX3lDV1fW/wExYee8sD
 1EXQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1694901362; x=1695506162;
 h=mime-version:user-agent:content-transfer-encoding:references
 :in-reply-to:date:cc:to:from:subject:message-id:x-gm-message-state
 :from:to:cc:subject:date:message-id:reply-to;
 bh=QkdKiA52I7Hgt7jsroPqx+AsUKj7Ib1XlI65Uw6Aoy8=;
 b=qvc+lslxA1OE/d6zs9FAXpDaBGIxrilT2Hwyf8T/SOuyIZmeTOYezO+cigxGTjLRju
 /F34m2Wvc4nQQD3r9JMyBzh8sOd4SEx0nS3Zsn4x41Is7NPuStVhR7AYtKjAqDyKiIFF
 nv3/vZYfug35rn6XVO2joP1pfEncbMPmX5//ODDHq5JiP+Caj/Ho6P50KtzD73hegxuB
 p1LtsJHVkbjJxYuSfdWzqPE0HkFl7IvGIS2rT4zdBisIwcAAZO1sJ1Oc4Sf2SuSfJ15g
 beiYE9bMrdAVJJktAEDYLuIUegvFXFoRzNaEMoF+3xPi9tUFvJAEO10PkA4Jjjeb9hFq
 W2UQ==
X-Gm-Message-State: AOJu0YzPcq5buKJJyw/uufuYiB7oOdUxI0VWFX1dssX0rS/JgOjR7wbR
 5yRWWk1IGkDWeMVsMPkbZA4=
X-Google-Smtp-Source: AGHT+IHNsxMS9ZTYxkS3TtFFPGO0IiHrAbRsRJiQL+tZuskgvpZp9vm4ZJuyciJh2uQyAXyjz93Ngg==
X-Received: by 2002:a50:fe8e:0:b0:522:c1b1:8cb0 with SMTP id
 d14-20020a50fe8e000000b00522c1b18cb0mr4066049edt.33.1694901362061; 
 Sat, 16 Sep 2023 14:56:02 -0700 (PDT)
Received: from lumine.fritz.box (85-127-52-93.dsl.dynamic.surfer.at.
 [85.127.52.93]) by smtp.gmail.com with ESMTPSA id
 m9-20020aa7c2c9000000b0052576969ef8sm3901803edp.14.2023.09.16.14.56.00
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Sat, 16 Sep 2023 14:56:01 -0700 (PDT)
Message-ID: <6445e508cbc8a9f92d3a54263193936d168cd7cf.camel@HIDDEN>
Subject: Re: [bug#63985] [PATCH v3 00/11] Service subsystem improvements
From: Liliana Marie Prikler <liliana.prikler@HIDDEN>
To: Bruno Victal <mirai@HIDDEN>
Date: Sat, 16 Sep 2023 23:55:59 +0200
In-Reply-To: <5613dc86-54ac-4bdb-b75a-400b1cb124bf@HIDDEN>
References: <cover.1686343642.git.mirai@HIDDEN>
 <cover.1687816304.git.mirai@HIDDEN>
 <5613dc86-54ac-4bdb-b75a-400b1cb124bf@HIDDEN>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
User-Agent: Evolution 3.46.4 
MIME-Version: 1.0
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 63985
Cc: 63985 <at> debbugs.gnu.org, ludo@HIDDEN, maxim.cournoyer@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Am Samstag, dem 16.09.2023 um 22:22 +0100 schrieb Bruno Victal:
> Hi all,
>=20
> I've been pondering about the changes here and would like to comment
> on them:
>=20
> On 2023-06-26 22:57, Bruno Victal wrote:
> > Bruno Victal (11):
> > =C2=A0 services: configuration: Simplify normalize-extra-args.
> > =C2=A0 services: configuration: Use transducers within
> > =C2=A0=C2=A0=C2=A0 serialize-configuration.
> > =C2=A0 services: fstrim-service-type: Serialize with SRFI-171
> > transducers.
> > =C2=A0 doc: Rewrite define-configuration.
> > =C2=A0 services: configuration: Add serializer-options field.
>=20
> I think these changes are OK on their own since they add some extra
> flexibility to the serialize-configuration procedure and address a
> TODO item.
I'm not sure whether serializer options really add much value.  You can
use functional programming to define serializers for you and pass those
options in a cleaner way IMHO.  The documentation should be updated as
the changes are made.  As for the switch to SRFI 171, I'm not sure
whether backwards compatibility with Guile 2.2 is a requirement
somewhere; if it isn't, that change is probably fine.

> > =C2=A0 services: configuration: New generic-ini module.
> > =C2=A0 services: configuration: Add some commonly used predicates.
>=20
> IMO I'm afraid this might be somewhat short-sighted and would be
> better addressed directly in Guile by implementing SRFI-233, perhaps
> by doing some adaptations to the approach taken here.
Even if Guile implemented SRFI 233 now, I'm not sure we could use it
tomorrow.  And even once we can use SRFI 233, we can keep backwards-
compatibility be re-exporting things.  The question is how necessary it
will be for us to maintain our own INI format writer.  NetworkManager
is one use case, but perhaps we have others (perhaps even in the gnome
world =E2=80=93 gdm maybe?)

> > =C2=A0 services: NetworkManager: Use define-configuration and generic-
> > ini.>=C2=A0=C2=A0 services: NetworkManager: Prefer package over network=
-
> > manager.
> > =C2=A0 services: NetworkManager: add log-configuration field.
> > =C2=A0 services: NetworkManager: Add extra-options field.
>=20
> Naturally these are no longer relevant if this generic-ini module
> approach is abandoned.
I think we can still upgrade this to define-configuration without a
generic-ini, but see above.  That being said, we can certainly split
this into two series at the point you currently feel comfortable with
and work from there.

WDYT?




Information forwarded to guix-patches@HIDDEN:
bug#63985; Package guix-patches. Full text available.

Message received at 63985 <at> debbugs.gnu.org:


Received: (at 63985) by debbugs.gnu.org; 16 Sep 2023 21:23:19 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Sep 16 17:23:19 2023
Received: from localhost ([127.0.0.1]:48652 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1qhcl5-0002p2-De
	for submit <at> debbugs.gnu.org; Sat, 16 Sep 2023 17:23:19 -0400
Received: from smtpmciv3.myservices.hosting ([185.26.107.239]:38110)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <mirai@HIDDEN>) id 1qhcl3-0002ot-C4
 for 63985 <at> debbugs.gnu.org; Sat, 16 Sep 2023 17:23:18 -0400
Received: from mail1.netim.hosting (unknown [185.26.106.173])
 by smtpmciv3.myservices.hosting (Postfix) with ESMTP id D0000205DB;
 Sat, 16 Sep 2023 23:23:04 +0200 (CEST)
Received: from localhost (localhost [127.0.0.1])
 by mail1.netim.hosting (Postfix) with ESMTP id 0EEEB80092;
 Sat, 16 Sep 2023 23:23:04 +0200 (CEST)
X-Virus-Scanned: Debian amavisd-new at mail1.netim.hosting
Received: from mail1.netim.hosting ([127.0.0.1])
 by localhost (mail1-2.netim.hosting [127.0.0.1]) (amavisd-new, port 10026)
 with ESMTP id GODMOjWKmAC8; Sat, 16 Sep 2023 23:23:03 +0200 (CEST)
Received: from [192.168.1.116] (unknown [10.192.1.83])
 (Authenticated sender: lumen@HIDDEN)
 by mail1.netim.hosting (Postfix) with ESMTPSA id 659F880060;
 Sat, 16 Sep 2023 23:23:03 +0200 (CEST)
Message-ID: <5613dc86-54ac-4bdb-b75a-400b1cb124bf@HIDDEN>
Date: Sat, 16 Sep 2023 22:22:52 +0100
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
Subject: Re: [bug#63985] [PATCH v3 00/11] Service subsystem improvements
Content-Language: en-US
To: Bruno Victal <mirai@HIDDEN>
References: <cover.1686343642.git.mirai@HIDDEN>
 <cover.1687816304.git.mirai@HIDDEN>
From: Bruno Victal <mirai@HIDDEN>
In-Reply-To: <cover.1687816304.git.mirai@HIDDEN>
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 63985
Cc: 63985 <at> debbugs.gnu.org, ludo@HIDDEN, liliana.prikler@HIDDEN,
 maxim.cournoyer@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Hi all,

I've been pondering about the changes here and would like to comment
on them:

On 2023-06-26 22:57, Bruno Victal wrote:
> Bruno Victal (11):
>   services: configuration: Simplify normalize-extra-args.
>   services: configuration: Use transducers within
>     serialize-configuration.
>   services: fstrim-service-type: Serialize with SRFI-171 transducers.
>   doc: Rewrite define-configuration.
>   services: configuration: Add serializer-options field.

I think these changes are OK on their own since they add some extra
flexibility to the serialize-configuration procedure and address a
TODO item.

>   services: configuration: New generic-ini module.
>   services: configuration: Add some commonly used predicates.

IMO I'm afraid this might be somewhat short-sighted and would be
better addressed directly in Guile by implementing SRFI-233, perhaps
by doing some adaptations to the approach taken here.

>   services: NetworkManager: Use define-configuration and generic-ini.>   services: NetworkManager: Prefer package over network-manager.
>   services: NetworkManager: add log-configuration field.
>   services: NetworkManager: Add extra-options field.

Naturally these are no longer relevant if this generic-ini module
approach is abandoned.

Comments?


-- 
Furthermore, I consider that nonfree software must be eradicated.

Cheers,
Bruno.





Information forwarded to guix-patches@HIDDEN:
bug#63985; Package guix-patches. Full text available.

Message received at 63985 <at> debbugs.gnu.org:


Received: (at 63985) by debbugs.gnu.org; 27 Jun 2023 04:21:01 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Jun 27 00:21:00 2023
Received: from localhost ([127.0.0.1]:47390 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1qE0CK-0002U0-Kx
	for submit <at> debbugs.gnu.org; Tue, 27 Jun 2023 00:21:00 -0400
Received: from mail-ed1-f67.google.com ([209.85.208.67]:46500)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <liliana.prikler@HIDDEN>) id 1qE0CH-0002Td-NU
 for 63985 <at> debbugs.gnu.org; Tue, 27 Jun 2023 00:20:58 -0400
Received: by mail-ed1-f67.google.com with SMTP id
 4fb4d7f45d1cf-51d9865b848so2149677a12.1
 for <63985 <at> debbugs.gnu.org>; Mon, 26 Jun 2023 21:20:57 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20221208; t=1687839652; x=1690431652;
 h=mime-version:user-agent:content-transfer-encoding:references
 :in-reply-to:date:cc:to:from:subject:message-id:from:to:cc:subject
 :date:message-id:reply-to;
 bh=Ehro8qWm1zq/1pJN3SV1GU/h/4zVyY/qx5dw4+PHgrw=;
 b=Ltwj9EODkkbL6bMImPFIsFpNQCRvmtT++jmk3uJzqJlQD4HjdJTqxnk+iTd5Lb+Hi1
 HrYyOZfP8AZI7odvXmucNwLvW6lPvgLzrlhyan6jKEqs+koNBHOyBjsc9QSLMlUttCZt
 6NCbR4fgPER7rop0HVLWv5SrZc+gpBCvF2HDOnGx2ETKNEF+d7hfLX1Cgv6B8x41osRT
 OWeDAkM1HcmPZJhuAPHVtkbI1/jBEGlJnEEYLzX1ZuaG16o2VGKpVt3+CfyIi+1cfWgH
 Ij5BIY4NYIvFaah8Zko60faKRg4uZJPwzXHvchMrjob0qQyAllwsAl8m/UhNnzLAtUVh
 Qo+w==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20221208; t=1687839652; x=1690431652;
 h=mime-version:user-agent:content-transfer-encoding:references
 :in-reply-to:date:cc:to:from:subject:message-id:x-gm-message-state
 :from:to:cc:subject:date:message-id:reply-to;
 bh=Ehro8qWm1zq/1pJN3SV1GU/h/4zVyY/qx5dw4+PHgrw=;
 b=hdjo5RQ525UQufkJRffn8C1BsjuuFbzGMnP6cjJ1wf13Acjvnzf8p9vEuTuJrlgqWv
 6v7w6PJbdHWBX0tYsBiu0g6cZuu0Io1od3UurfbyFi7vMZUXpWktNdRAYzw6hjFRHrwO
 1CnwawAlNUaWLd2c2pFTtSo9OtLeI9HRZVcD/sod33NfYATJagw3Dm40h1iW/VDkBNmm
 O+qoAn7fj8oT8B3kHZrH/MZnOF2u1nKMl7NqDjYTFrYRrBQwhkmiPkvPpxBtKiPV2OJz
 6HGT4tIM2cduS0ixTiEvgx7eb68/sCNUVe/XMU3c3p/9L5LPAE4je60cxJRxEcMAgphg
 S3bA==
X-Gm-Message-State: AC+VfDxAvL6mV4LBwAwq+voN76vm1dvwgGU65fG8p/SAKU2yxk6bp+SM
 bU1nrKIbOLr0OWkeCOMLa60=
X-Google-Smtp-Source: ACHHUZ5+HeSP5mz9KCiWNAEGHhuP/HzTWH6w0VkiX8dWtJf0qgfSfZDjboLbf4NZNO/EeImclrMdZQ==
X-Received: by 2002:a17:907:7243:b0:988:fb2f:274e with SMTP id
 ds3-20020a170907724300b00988fb2f274emr18118729ejc.27.1687839651700; 
 Mon, 26 Jun 2023 21:20:51 -0700 (PDT)
Received: from lumine.fritz.box (85-127-52-93.dsl.dynamic.surfer.at.
 [85.127.52.93]) by smtp.gmail.com with ESMTPSA id
 ko9-20020a170907986900b0098692f1b803sm4007610ejc.166.2023.06.26.21.20.50
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Mon, 26 Jun 2023 21:20:51 -0700 (PDT)
Message-ID: <86f28484815295507242c7a2bc0cb67b2ec77637.camel@HIDDEN>
Subject: Re: [bug#63985] [PATCH v3 00/11] Service subsystem improvements
From: Liliana Marie Prikler <liliana.prikler@HIDDEN>
To: Bruno Victal <mirai@HIDDEN>, 63985 <at> debbugs.gnu.org
Date: Tue, 27 Jun 2023 06:20:50 +0200
In-Reply-To: <cover.1687816304.git.mirai@HIDDEN>
References: <cover.1686343642.git.mirai@HIDDEN>
 <cover.1687816304.git.mirai@HIDDEN>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
User-Agent: Evolution 3.46.4 
MIME-Version: 1.0
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 63985
Cc: ludo@HIDDEN, maxim.cournoyer@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Am Montag, dem 26.06.2023 um 22:57 +0100 schrieb Bruno Victal:
> ** Renamed fields: 'network-manager' to 'package'
>=20
> Naming the field 'package' is more informative & less confusing than
> a reduplication of the package-name with the field-name itself.
This goes against established practice in pretty much every other
service out there.  It'd also be way more painful to read if it was
applied broadly =E2=80=93 so many fields simply named "package" in your
configuration might be easier to grep, but certainly not easier to
understand.  As such, I'd suggest to revert this particular change.

As for the other changes I'll have a detailed look later.

Cheers




Information forwarded to guix-patches@HIDDEN:
bug#63985; Package guix-patches. Full text available.

Message received at 63985 <at> debbugs.gnu.org:


Received: (at 63985) by debbugs.gnu.org; 26 Jun 2023 22:07:02 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Jun 26 18:07:02 2023
Received: from localhost ([127.0.0.1]:47216 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1qDuMQ-0000Am-3w
	for submit <at> debbugs.gnu.org; Mon, 26 Jun 2023 18:07:02 -0400
Received: from smtpm1.myservices.hosting ([185.26.105.232]:59692)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <mirai@HIDDEN>) id 1qDuMO-0000Aa-Ob
 for 63985 <at> debbugs.gnu.org; Mon, 26 Jun 2023 18:07:01 -0400
Received: from mail1.netim.hosting (unknown [185.26.106.173])
 by smtpm1.myservices.hosting (Postfix) with ESMTP id ADCF520512
 for <63985 <at> debbugs.gnu.org>; Tue, 27 Jun 2023 00:06:59 +0200 (CEST)
Received: from localhost (localhost [127.0.0.1])
 by mail1.netim.hosting (Postfix) with ESMTP id 6D48480099;
 Mon, 26 Jun 2023 23:59:45 +0200 (CEST)
X-Virus-Scanned: Debian amavisd-new at mail1.netim.hosting
Received: from mail1.netim.hosting ([127.0.0.1])
 by localhost (mail1-2.netim.hosting [127.0.0.1]) (amavisd-new, port 10026)
 with ESMTP id m87NYcERUslH; Mon, 26 Jun 2023 23:59:45 +0200 (CEST)
Received: from guix-nuc.home.arpa (unknown [10.192.1.83])
 (Authenticated sender: lumen@HIDDEN)
 by mail1.netim.hosting (Postfix) with ESMTPSA id E8E8E80060;
 Mon, 26 Jun 2023 23:59:44 +0200 (CEST)
From: Bruno Victal <mirai@HIDDEN>
To: 63985 <at> debbugs.gnu.org
Subject: [PATCH v3 01/11] services: configuration: Simplify
 normalize-extra-args.
Date: Mon, 26 Jun 2023 22:59:27 +0100
Message-Id: <22471a74b258f7169961898eed9e18cee7504f60.1687816734.git.mirai@HIDDEN>
X-Mailer: git-send-email 2.39.2
In-Reply-To: <cover.1687816304.git.mirai@HIDDEN>
References: <cover.1687816304.git.mirai@HIDDEN>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 63985
Cc: Bruno Victal <mirai@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

* gnu/services/configuration.scm
(define-configuration-helper, normalize-extra-args): Use #f instead of %unset-value.
---
 gnu/services/configuration.scm | 26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/gnu/services/configuration.scm b/gnu/services/configuration.scm
index 367b85c1be..dafe72f4fe 100644
--- a/gnu/services/configuration.scm
+++ b/gnu/services/configuration.scm
@@ -190,32 +190,32 @@ (define (define-configuration-helper serialize? serializer-prefix syn)
   (define (normalize-extra-args s)
     "Extract and normalize arguments following @var{doc}."
     (let loop ((s s)
-               (sanitizer* %unset-value)
-               (serializer* %unset-value))
+               (sanitizer* #f)
+               (serializer* #f))
       (syntax-case s (sanitizer serializer empty-serializer)
         (((sanitizer proc) tail ...)
-         (if (maybe-value-set? sanitizer*)
-             (syntax-violation 'sanitizer "duplicate entry"
-                               #'proc)
+         (if sanitizer*
+             (syntax-violation 'sanitizer
+                               "duplicate entry" #'proc)
              (loop #'(tail ...) #'proc serializer*)))
         (((serializer proc) tail ...)
-         (if (maybe-value-set? serializer*)
-             (syntax-violation 'serializer "duplicate or conflicting entry"
-                               #'proc)
+         (if serializer*
+             (syntax-violation 'serializer
+                               "duplicate or conflicting entry" #'proc)
              (loop #'(tail ...) sanitizer* #'proc)))
         ((empty-serializer tail ...)
-         (if (maybe-value-set? serializer*)
+         (if serializer*
              (syntax-violation 'empty-serializer
                                "duplicate or conflicting entry" #f)
              (loop #'(tail ...) sanitizer* #'empty-serializer)))
         (()  ; stop condition
          (values (list sanitizer* serializer*)))
         ((proc)  ; TODO: deprecated, to be removed.
-         (null? (filter-map maybe-value-set? (list sanitizer* serializer*)))
+         (every not (list sanitizer* serializer*))
          (begin
            (warning #f (G_ "specifying serializers after documentation is \
 deprecated, use (serializer ~a) instead~%") (syntax->datum #'proc))
-           (values (list %unset-value #'proc)))))))
+           (values (list #f #'proc)))))))
 
   (syntax-case syn ()
     ((_ stem (field field-type+def doc extra-args ...) ...)
@@ -239,11 +239,11 @@ (define (define-configuration-helper serialize? serializer-prefix syn)
                      default-value))
                   #'((field-type def) ...)))
             ((field-sanitizer ...)
-             (map maybe-value #'(sanitizer* ...)))
+             #'(sanitizer* ...))
             ((field-serializer ...)
              (map (lambda (type proc)
                     (and serialize?
-                         (or (maybe-value proc)
+                         (or proc
                              (if serializer-prefix
                                  (id #'stem serializer-prefix #'serialize- type)
                                  (id #'stem #'serialize- type)))))

base-commit: ac86174e22fcd762893bd4515786b1376af9397b
-- 
2.39.2





Information forwarded to guix-patches@HIDDEN:
bug#63985; Package guix-patches. Full text available.

Message received at 63985 <at> debbugs.gnu.org:


Received: (at 63985) by debbugs.gnu.org; 26 Jun 2023 22:01:06 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Jun 26 18:01:06 2023
Received: from localhost ([127.0.0.1]:47204 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1qDuGf-0008TK-L3
	for submit <at> debbugs.gnu.org; Mon, 26 Jun 2023 18:01:06 -0400
Received: from smtpm2.myservices.hosting ([185.26.105.233]:34376)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <mirai@HIDDEN>) id 1qDuGS-0008Rw-Qj
 for 63985 <at> debbugs.gnu.org; Mon, 26 Jun 2023 18:00:53 -0400
Received: from mail1.netim.hosting (unknown [185.26.106.173])
 by smtpm2.myservices.hosting (Postfix) with ESMTP id 6769320E6F
 for <63985 <at> debbugs.gnu.org>; Tue, 27 Jun 2023 00:00:52 +0200 (CEST)
Received: from localhost (localhost [127.0.0.1])
 by mail1.netim.hosting (Postfix) with ESMTP id C28258009B;
 Tue, 27 Jun 2023 00:00:51 +0200 (CEST)
X-Virus-Scanned: Debian amavisd-new at mail1.netim.hosting
Received: from mail1.netim.hosting ([127.0.0.1])
 by localhost (mail1-2.netim.hosting [127.0.0.1]) (amavisd-new, port 10026)
 with ESMTP id 0OtqaWwF1hKi; Tue, 27 Jun 2023 00:00:51 +0200 (CEST)
Received: from guix-nuc.home.arpa (unknown [10.192.1.83])
 (Authenticated sender: lumen@HIDDEN)
 by mail1.netim.hosting (Postfix) with ESMTPSA id 5A4548009A;
 Tue, 27 Jun 2023 00:00:51 +0200 (CEST)
From: Bruno Victal <mirai@HIDDEN>
To: 63985 <at> debbugs.gnu.org
Subject: [PATCH v3 11/11] services: NetworkManager: Add extra-options field.
Date: Mon, 26 Jun 2023 22:59:37 +0100
Message-Id: <e4d3466b4105381f0497a4a8d8ec1adb7a40ef28.1687816734.git.mirai@HIDDEN>
X-Mailer: git-send-email 2.39.2
In-Reply-To: <cover.1687816304.git.mirai@HIDDEN>
References: <cover.1687816304.git.mirai@HIDDEN>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 63985
Cc: Bruno Victal <mirai@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

* gnu/services/networking.scm (network-manager-configuration)
[extra-options]: New field.
* doc/guix.texi (Networking Setup): Document it.
---
 doc/guix.texi               | 7 +++++++
 gnu/services/networking.scm | 9 +++++++++
 2 files changed, 16 insertions(+)

diff --git a/doc/guix.texi b/doc/guix.texi
index 76bd1b1413..a74718f216 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -20413,6 +20413,13 @@ Networking Setup
 (VPNs).  An example of this is the @code{network-manager-openvpn}
 package, which allows NetworkManager to manage VPNs @i{via} OpenVPN.
 
+@item @code{extra-options} (default: @code{'()}) (type: list-of-ini-entries)
+Additional options to be appended to @file{NetworkManager.conf} (run
+@samp{man networkmanager.conf} for more information).  It expects a list
+whose elements are lists of the form @code{'(@var{section} @var{key}
+@var{value})}, where @var{section} and @var{key} are symbols and
+@var{value} is a string.
+
 @end table
 @end deftp
 
diff --git a/gnu/services/networking.scm b/gnu/services/networking.scm
index 33ff5e040f..4cb1cd60cb 100644
--- a/gnu/services/networking.scm
+++ b/gnu/services/networking.scm
@@ -179,6 +179,7 @@ (define-module (gnu services networking)
             network-manager-configuration-log-configuration
             network-manager-configuration-dns
             network-manager-configuration-vpn-plugins
+            network-manager-configuration-extra-options
             network-manager-service-type
 
             connman-configuration
@@ -1340,6 +1341,14 @@ (define-configuration network-manager-configuration
 package, which allows NetworkManager to manage VPNs @i{via} OpenVPN."
    empty-serializer)
 
+  (extra-options
+   (list-of-ini-entries '())
+   "Additional options to be appended to @file{NetworkManager.conf}  (run
+@samp{man networkmanager.conf} for more information).
+It expects a list whose elements are lists of the form
+@code{'(@var{section} @var{key} @var{value})}, where @var{section} and
+@var{key} are symbols and @var{value} is a string.")
+
   ;; Deprecated options
   (iwd?
    (boolean #f)
-- 
2.39.2





Information forwarded to guix-patches@HIDDEN:
bug#63985; Package guix-patches. Full text available.

Message received at 63985 <at> debbugs.gnu.org:


Received: (at 63985) by debbugs.gnu.org; 26 Jun 2023 22:01:05 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Jun 26 18:01:05 2023
Received: from localhost ([127.0.0.1]:47201 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1qDuGe-0008T9-OI
	for submit <at> debbugs.gnu.org; Mon, 26 Jun 2023 18:01:05 -0400
Received: from smtpm5.myservices.hosting ([185.26.105.236]:55252)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <mirai@HIDDEN>) id 1qDuGM-0008RN-QT
 for 63985 <at> debbugs.gnu.org; Mon, 26 Jun 2023 18:00:48 -0400
Received: from mail1.netim.hosting (unknown [185.26.106.173])
 by smtpm5.myservices.hosting (Postfix) with ESMTP id 2991A20DB5
 for <63985 <at> debbugs.gnu.org>; Tue, 27 Jun 2023 00:00:45 +0200 (CEST)
Received: from localhost (localhost [127.0.0.1])
 by mail1.netim.hosting (Postfix) with ESMTP id 3CE728009B;
 Tue, 27 Jun 2023 00:00:45 +0200 (CEST)
X-Virus-Scanned: Debian amavisd-new at mail1.netim.hosting
Received: from mail1.netim.hosting ([127.0.0.1])
 by localhost (mail1-2.netim.hosting [127.0.0.1]) (amavisd-new, port 10026)
 with ESMTP id 6-L-W1LkITRE; Tue, 27 Jun 2023 00:00:44 +0200 (CEST)
Received: from guix-nuc.home.arpa (unknown [10.192.1.83])
 (Authenticated sender: lumen@HIDDEN)
 by mail1.netim.hosting (Postfix) with ESMTPSA id 501658009A;
 Tue, 27 Jun 2023 00:00:44 +0200 (CEST)
From: Bruno Victal <mirai@HIDDEN>
To: 63985 <at> debbugs.gnu.org
Subject: [PATCH v3 10/11] services: NetworkManager: add log-configuration
 field.
Date: Mon, 26 Jun 2023 22:59:36 +0100
Message-Id: <79ae045eeb94e92221fcff8272cae9673c376f9b.1687816734.git.mirai@HIDDEN>
X-Mailer: git-send-email 2.39.2
In-Reply-To: <cover.1687816304.git.mirai@HIDDEN>
References: <cover.1687816304.git.mirai@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 63985
Cc: Bruno Victal <mirai@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

* gnu/services/networking.scm (network-manager-log-level?)
(network-manager-log-domain?, network-manager-log-domains?): New predicate.
(serialize-network-manager-log-level, serialize-network-manager-log-domains):
New procedure.
(network-manager-log-configuration): New record type.
(network-manager-configuration)[log-configuration]: New field.
* doc/guix.texi (Networking Setup): Document it.
---
 doc/guix.texi               |  43 +++++++++++++++
 gnu/services/networking.scm | 107 ++++++++++++++++++++++++++++++++++++
 2 files changed, 150 insertions(+)

diff --git a/doc/guix.texi b/doc/guix.texi
index 974bfa3fb0..76bd1b1413 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -20361,6 +20361,10 @@ Networking Setup
 @code{'iwd} if you require authenticated access for encrypted WiFi or Ethernet
 networks.
 
+@item @code{log-configuration} (default: @code{(network-manager-log-configuration)})
+Logging configuration for NetworkManager.
+This is a @code{<network-manager-log-configuration>} record object.
+
 @item @code{dns} (default: @code{"default"})
 Processing mode for DNS, which affects how NetworkManager uses the
 @code{resolv.conf} configuration file.
@@ -20412,6 +20416,45 @@ Networking Setup
 @end table
 @end deftp
 
+@deftp {Data Type} network-manager-log-configuration
+Available @code{network-manager-log-configuration} fields are:
+
+@table @asis
+@item @code{level} (type: maybe-network-manager-log-level)
+The default logging verbosity level.  Valid values are (in increasing
+order of verbosity): @code{'off}, @code{'err}, @code{'warn},
+@code{'info}, @code{'debug} and @code{'trace}.
+
+@item @code{domains} (type: maybe-network-manager-log-domains)
+Log messages by topic.  The value for this field is a list of
+@var{domains} or pairs of @var{domains} and @var{levels} where the valid
+values for @var{levels} are the same as those described in the ``level''
+field and @var{domains} are any of: @code{'platform}, @code{'rfkill},
+@code{'ether}, @code{'wifi}, @code{'bt}, @code{'mb}, @code{'dhcp4},
+@code{'dhcp6}, @code{'ppp}, @code{'wifi-scan}, @code{'ip4}, @code{'ip6},
+@code{'autoip4}, @code{'dns}, @code{'vpn}, @code{'sharing},
+@code{'supplicant}, @code{'agents}, @code{'settings}, @code{'suspend},
+@code{'core}, @code{'device}, @code{'olpc}, @code{'wimax},
+@code{'infiniband}, @code{'firewall}, @code{'adsl}, @code{'bond},
+@code{'vlan}, @code{'bridge}, @code{'dbus-props}, @code{'team},
+@code{'concheck}, @code{'dcb}, @code{'dispatch}, @code{'audit},
+@code{'systemd}, @code{'vpn-plugin}, @code{'proxy}, @code{'none},
+@code{'all}, @code{'default}, @code{'dhcp} and @code{'ip}.  The log
+level can be overrided per-domain in a pair with a @var{level}.
+For example:
+@lisp
+(network-manager-log-configuration
+  (level 'warn)
+  (domains '(all (wifi . debug) (wifi-scan . off))))
+@end lisp
+
+@item @code{audit?} (type: maybe-boolean)
+Whether to send audit records to @command{auditd}.
+
+@end table
+@end deftp
+
+
 @cindex Connman
 @defvar connman-service-type
 This is the service type to run @url{https://01.org/connman,Connman},
diff --git a/gnu/services/networking.scm b/gnu/services/networking.scm
index 496ff0f0ec..33ff5e040f 100644
--- a/gnu/services/networking.scm
+++ b/gnu/services/networking.scm
@@ -78,7 +78,10 @@ (define-module (gnu services networking)
   #:use-module (srfi srfi-9)
   #:use-module (srfi srfi-26)
   #:use-module (srfi srfi-43)
+  #:use-module (srfi srfi-171)
+  #:use-module (ice-9 format)
   #:use-module (ice-9 match)
+  #:use-module (ice-9 string-fun)
   #:use-module (json)
   #:re-export (static-networking-service
                static-networking-service-type)
@@ -164,10 +167,16 @@ (define-module (gnu services networking)
             tor-hidden-service  ; deprecated
             tor-service-type
 
+            network-manager-log-configuration
+            network-manager-log-configuration?
+            network-manager-log-configuration-level
+            network-manager-log-configuration-domains?
+            network-manager-log-configuration-audit?
             network-manager-configuration
             network-manager-configuration?
             network-manager-configuration-package
             network-manager-configuration-shepherd-requirement
+            network-manager-configuration-log-configuration
             network-manager-configuration-dns
             network-manager-configuration-vpn-plugins
             network-manager-service-type
@@ -1158,6 +1167,92 @@ (define-record-type* <modem-manager-configuration>
 ;;; NetworkManager
 ;;;
 
+(define-maybe boolean)
+
+;; See the logging section at
+;; <https://networkmanager.dev/docs/api/latest/NetworkManager.conf.html> for
+;; the list of valid values for the predicates below.
+(define (network-manager-log-level? x)
+  (memq x '(off err warn info debug trace)))
+
+(define (network-manager-log-domain? x)
+  (memq x '(platform rfkill ether wifi bt mb dhcp4 dhcp6 ppp wifi-scan ip4 ip6
+                     autoip4 dns vpn sharing supplicant agents settings
+                     suspend core device olpc wimax infiniband firewall adsl
+                     bond vlan bridge dbus-props team concheck dcb dispatch
+                     audit systemd vpn-plugin proxy
+                     ;; Special NetworkManager domains:
+                     none all default dhcp ip)))
+
+(define (network-manager-log-domains? x)
+  (every
+   (match-lambda
+     (((? network-manager-log-domain?) . (? network-manager-log-level?)) #t)
+     ((? network-manager-log-domain?) #t)
+     (_ #f))
+   x))
+
+(define (serialize-network-manager-log-level field-name value)
+  `(logging level ,(format #f "~:@(~a~)" value)))
+
+(define (serialize-network-manager-log-domains field-name value)
+  (define (uglify-domain-symbol x)
+    (string-replace-substring (symbol->string x) "-" "_"))
+
+  (define serialize-entry
+    (match-lambda
+      (((= uglify-domain-symbol domain) . value)
+       (format #f "~:@(~a:~a~)" domain value))
+      ((= uglify-domain-symbol domain)
+       (format #f "~:@(~a~)" domain))))
+
+  (let ((serialized-value (list-transduce (compose (tmap serialize-entry)
+                                                   (tadd-between ","))
+                                          string-append value)))
+    `(logging domains ,serialized-value)))
+
+(define-maybe network-manager-log-level)
+(define-maybe network-manager-log-domains)
+
+;; This implicitly belongs to the INI "logging" section.
+(define-configuration network-manager-log-configuration
+  (level
+   maybe-network-manager-log-level
+   "The default logging verbosity level.  Valid values are (in increasing
+order of verbosity): @code{'off}, @code{'err}, @code{'warn}, @code{'info},
+@code{'debug} and @code{'trace}.")
+
+  (domains
+   maybe-network-manager-log-domains
+   "Log messages by topic. The value for this field is a list of @var{domains}
+or pairs of @var{domains} and @var{levels} where the valid values for
+@var{levels} are the same as those described in the ``level'' field and
+@var{domains} are any of: @code{'platform}, @code{'rfkill}, @code{'ether},
+@code{'wifi}, @code{'bt}, @code{'mb}, @code{'dhcp4}, @code{'dhcp6},
+@code{'ppp}, @code{'wifi-scan}, @code{'ip4}, @code{'ip6}, @code{'autoip4},
+@code{'dns}, @code{'vpn}, @code{'sharing}, @code{'supplicant}, @code{'agents},
+@code{'settings}, @code{'suspend}, @code{'core}, @code{'device}, @code{'olpc},
+@code{'wimax}, @code{'infiniband}, @code{'firewall}, @code{'adsl}, @code{'bond},
+@code{'vlan}, @code{'bridge}, @code{'dbus-props}, @code{'team}, @code{'concheck},
+@code{'dcb}, @code{'dispatch}, @code{'audit}, @code{'systemd},
+@code{'vpn-plugin}, @code{'proxy}, @code{'none}, @code{'all}, @code{'default},
+@code{'dhcp} and @code{'ip}.
+
+The log level can be overrided per-domain in a pair with a @var{level}.
+For example:
+@lisp
+(network-manager-log-configuration
+  (level 'warn)
+  (domains '(all (wifi . debug) (wifi-scan . off))))
+@end lisp")
+
+  (audit?
+   maybe-boolean
+   "Whether to send audit records to @command{auditd}."
+   (serializer generic-ini-serialize-boolean)
+   (serializer-options `(#:section logging
+                         #:field-name-transform ,(const 'audit)))))
+
 ;; TODO: deprecated field, remove later.
 (define (warn-iwd?-field-deprecation value)
   (when value
@@ -1181,6 +1276,18 @@ (define-configuration network-manager-configuration
 networks."
    empty-serializer)
 
+  (log-configuration
+   (network-manager-log-configuration (network-manager-log-configuration))
+   "Logging configuration for NetworkManager.  This is a
+@code{<network-manager-log-configuration>} record object."
+   (serializer
+    (lambda (_ value)
+      ;; Wrap the serialization of the log-configuration which is a list
+      ;; of INI entries in a ‘ini-entries’ object.
+      (ini-entries (list-transduce
+                    (base-transducer value) rcons
+                    network-manager-log-configuration-fields)))))
+
   (dns
    (string "default")
    "Processing mode for DNS, which affects how NetworkManager uses the
-- 
2.39.2





Information forwarded to guix-patches@HIDDEN:
bug#63985; Package guix-patches. Full text available.

Message received at 63985 <at> debbugs.gnu.org:


Received: (at 63985) by debbugs.gnu.org; 26 Jun 2023 22:00:48 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Jun 26 18:00:48 2023
Received: from localhost ([127.0.0.1]:47192 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1qDuGN-0008RZ-LZ
	for submit <at> debbugs.gnu.org; Mon, 26 Jun 2023 18:00:48 -0400
Received: from smtpmciv1.myservices.hosting ([185.26.107.237]:37982)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <mirai@HIDDEN>) id 1qDuGE-0008R9-GU
 for 63985 <at> debbugs.gnu.org; Mon, 26 Jun 2023 18:00:39 -0400
Received: from mail1.netim.hosting (unknown [185.26.106.173])
 by smtpmciv1.myservices.hosting (Postfix) with ESMTP id 00A4220E27
 for <63985 <at> debbugs.gnu.org>; Tue, 27 Jun 2023 00:00:31 +0200 (CEST)
Received: from localhost (localhost [127.0.0.1])
 by mail1.netim.hosting (Postfix) with ESMTP id 245D98009B;
 Tue, 27 Jun 2023 00:00:26 +0200 (CEST)
X-Virus-Scanned: Debian amavisd-new at mail1.netim.hosting
Received: from mail1.netim.hosting ([127.0.0.1])
 by localhost (mail1-2.netim.hosting [127.0.0.1]) (amavisd-new, port 10026)
 with ESMTP id aBm-A5OjAj0H; Tue, 27 Jun 2023 00:00:25 +0200 (CEST)
Received: from guix-nuc.home.arpa (unknown [10.192.1.83])
 (Authenticated sender: lumen@HIDDEN)
 by mail1.netim.hosting (Postfix) with ESMTPSA id 691588009A;
 Tue, 27 Jun 2023 00:00:25 +0200 (CEST)
From: Bruno Victal <mirai@HIDDEN>
To: 63985 <at> debbugs.gnu.org
Subject: [PATCH v3 08/11] services: NetworkManager: Use define-configuration
 and generic-ini.
Date: Mon, 26 Jun 2023 22:59:34 +0100
Message-Id: <daf3a3d209d6161b02e344f804b52b9cca9e477f.1687816734.git.mirai@HIDDEN>
X-Mailer: git-send-email 2.39.2
In-Reply-To: <cover.1687816304.git.mirai@HIDDEN>
References: <cover.1687816304.git.mirai@HIDDEN>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 63985
Cc: Bruno Victal <mirai@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

* gnu/services/networking.scm (<network-manager-configuration>): Define with
define-configuration.
(warn-iwd?-field-deprecation): Use regular define.
(network-manager-accounts): Use match-record.
(network-manager-environment): Subsume logic from vpn-plugin-directory.
(network-manager-shepherd-service): Subsume logic from
network-manager-activation.
(vpn-plugin-directory, network-manager-activation): Remove.
(network-manager-service-type): Adjust to changes listed above.
---
 gnu/services/networking.scm | 199 +++++++++++++++++++++++-------------
 1 file changed, 127 insertions(+), 72 deletions(-)

diff --git a/gnu/services/networking.scm b/gnu/services/networking.scm
index 5657b141d9..a4d3affa6c 100644
--- a/gnu/services/networking.scm
+++ b/gnu/services/networking.scm
@@ -41,6 +41,7 @@ (define-module (gnu services networking)
   #:use-module (gnu services)
   #:use-module (gnu services base)
   #:use-module (gnu services configuration)
+  #:use-module (gnu services configuration generic-ini)
   #:use-module (gnu services linux)
   #:use-module (gnu services shepherd)
   #:use-module (gnu services dbus)
@@ -1157,92 +1158,145 @@ (define-record-type* <modem-manager-configuration>
 ;;;
 
 ;; TODO: deprecated field, remove later.
-(define-with-syntax-properties (warn-iwd?-field-deprecation
-                                (value properties))
+(define (warn-iwd?-field-deprecation value)
   (when value
-    (warning (source-properties->location properties)
-             (G_ "the 'iwd?' field is deprecated, please use \
+    (warning (G_ "the 'iwd?' field is deprecated, please use \
 'shepherd-requirement' field instead~%")))
   value)
 
-(define-record-type* <network-manager-configuration>
-  network-manager-configuration make-network-manager-configuration
-  network-manager-configuration?
-  (network-manager network-manager-configuration-network-manager
-                   (default network-manager))
-  (shepherd-requirement network-manager-configuration-shepherd-requirement
-                        (default '(wpa-supplicant)))
-  (dns network-manager-configuration-dns
-       (default "default"))
-  (vpn-plugins network-manager-configuration-vpn-plugins ;list of file-like
-               (default '()))
-  (iwd? network-manager-configuration-iwd?  ; TODO: deprecated field, remove.
-        (default #f)
-        (sanitize warn-iwd?-field-deprecation)))
+(define-configuration network-manager-configuration
+  (network-manager
+   (package network-manager)
+   "The NetworkManager package to use."
+   empty-serializer)
+
+  (shepherd-requirement
+   (list-of-symbols '(wpa-supplicant))
+   "This option can be used to provide a list of symbols naming Shepherd
+services that this service will depend on, such as @code{'wpa-supplicant} or
+@code{'iwd} if you require authenticated access for encrypted WiFi or Ethernet
+networks."
+   empty-serializer)
+
+  (dns
+   (string "default")
+   "Processing mode for DNS, which affects how NetworkManager uses the
+@code{resolv.conf} configuration file.
+
+@table @samp
+@item default
+NetworkManager will update @code{resolv.conf} to reflect the nameservers
+provided by currently active connections.
+
+@item dnsmasq
+NetworkManager will run @code{dnsmasq} as a local caching nameserver, using a
+@dfn{conditional forwarding} configuration if you are connected to a VPN, and
+then update @code{resolv.conf} to point to the local nameserver.
+
+With this setting, you can share your network connection.  For example when
+you want to share your network connection to another laptop @i{via} an
+Ethernet cable, you can open @command{nm-connection-editor} and configure the
+Wired connection's method for IPv4 and IPv6 to be ``Shared to other computers''
+and reestablish the connection (or reboot).
+
+You can also set up a @dfn{host-to-guest connection} to QEMU VMs
+(@pxref{Installing Guix in a VM}).  With a host-to-guest connection, you can
+e.g.@: access a Web server running on the VM (@pxref{Web Services}) from a Web
+browser on your host system, or connect to the VM @i{via} SSH
+(@pxref{Networking Services, @code{openssh-service-type}}).  To set up a
+host-to-guest connection, run this command once:
 
-(define (network-manager-activation config)
-  ;; Activation gexp for NetworkManager
-  (match-record config <network-manager-configuration>
-    (network-manager dns vpn-plugins)
-    #~(begin
-        (use-modules (guix build utils))
-        (mkdir-p "/etc/NetworkManager/system-connections")
-        #$@(if (equal? dns "dnsmasq")
-               ;; create directory to store dnsmasq lease file
-               '((mkdir-p "/var/lib/misc"))
-               '()))))
+@example
+nmcli connection add type tun \
+ connection.interface-name tap0 \
+ tun.mode tap tun.owner $(id -u) \
+ ipv4.method shared \
+ ipv4.addresses 172.28.112.1/24
+@end example
 
-(define (vpn-plugin-directory plugins)
-  "Return a directory containing PLUGINS, the NM VPN plugins."
-  (directory-union "network-manager-vpn-plugins" plugins))
+Then each time you launch your QEMU VM (@pxref{Running Guix in a VM}), pass
+@option{-nic tap,ifname=tap0,script=no,downscript=no} to
+@command{qemu-system-...}.
+
+@item none
+NetworkManager will not modify @code{resolv.conf}.
+@end table"
+   (serializer-options '(#:section main)))
+
+  (vpn-plugins
+   (list-of-packages '())
+   "This is the list of available plugins for virtual private networks
+(VPNs).  An example of this is the @code{network-manager-openvpn}
+package, which allows NetworkManager to manage VPNs @i{via} OpenVPN."
+   empty-serializer)
+
+  ;; Deprecated options
+  (iwd?
+   (boolean #f)
+   "Deprecated."
+   (sanitizer warn-iwd?-field-deprecation)
+   (serializer-options '(#:section device))
+   (serializer
+    (lambda (_ value . rest)
+      (let ((value (if value "iwd" "wpa_supplicant")))
+        (apply generic-ini-serialize-string
+               'wifi.backend value rest)))))
+
+  (prefix generic-ini-))
+
+(define (network-manager-serialize-configuration config)
+  (mixed-text-file
+   "NetworkManager.conf"
+   (serialize-ini-configuration config
+                                network-manager-configuration-fields)))
 
 (define (network-manager-accounts config)
   "Return the list of <user-account> and <user-group> for CONFIG."
-  (define nologin
-    (file-append shadow "/sbin/nologin"))
-
-  (define accounts
-    (append-map (lambda (package)
-                  (map (lambda (name)
-                         (user-account (system? #t)
-                                       (name name)
-                                       (group "network-manager")
-                                       (comment "NetworkManager helper")
-                                       (home-directory "/var/empty")
-                                       (create-home-directory? #f)
-                                       (shell nologin)))
-                       (or (assoc-ref (package-properties package)
-                                      'user-accounts)
-                           '())))
-                (network-manager-configuration-vpn-plugins config)))
-
-  (match accounts
-    (()
-     '())
-    (_
-     (cons (user-group (name "network-manager") (system? #t))
-           accounts))))
+  (match-record config <network-manager-configuration>
+    (vpn-plugins)
+    (let* ((nologin (file-append shadow "/sbin/nologin"))
+           (accounts
+            (append-map (lambda (package)
+                          (map (lambda (name)
+                                 (user-account
+                                  (system? #t)
+                                  (name name)
+                                  (group "network-manager")
+                                  (comment "NetworkManager helper")
+                                  (home-directory "/var/empty")
+                                  (create-home-directory? #f)
+                                  (shell nologin)))
+                               (or (assoc-ref (package-properties package)
+                                              'user-accounts)
+                                   '())))
+                        vpn-plugins)))
+      (cond
+       ((null? accounts) '())
+       (else (cons (user-group (name "network-manager")
+                               (system? #t))
+                   accounts))))))
 
 (define (network-manager-environment config)
+  "Define NM_VPN_PLUGIN_DIR variable in the global environment such that
+\"nmcli connection import type openvpn file foo.ovpn\" works."
   (match-record config <network-manager-configuration>
-    (network-manager dns vpn-plugins)
-    ;; Define this variable in the global environment such that
-    ;; "nmcli connection import type openvpn file foo.ovpn" works.
-    `(("NM_VPN_PLUGIN_DIR"
-       . ,(file-append (vpn-plugin-directory vpn-plugins)
-                       "/lib/NetworkManager/VPN")))))
+    (vpn-plugins)
+    (let ((plugin-union (directory-union "network-manager-vpn-plugins"
+                                         vpn-plugins)))
+      `(("NM_VPN_PLUGIN_DIR" . ,(file-append plugin-union
+                                             "/lib/NetworkManager/VPN"))))))
 
 (define (network-manager-shepherd-service config)
   (match-record config <network-manager-configuration>
-    (network-manager shepherd-requirement dns vpn-plugins iwd?)
+    (network-manager shepherd-requirement dns iwd?)
     (let* ((iwd? (or iwd?  ; TODO: deprecated field, remove later.
                      (and shepherd-requirement
                           (memq 'iwd shepherd-requirement))))
-           (conf (plain-file "NetworkManager.conf"
-                             (string-append
-                              "[main]\ndns=" dns "\n"
-                              (if iwd? "[device]\nwifi.backend=iwd\n" ""))))
-           (vpn  (vpn-plugin-directory vpn-plugins)))
+           (conf (network-manager-serialize-configuration config))
+           (vpn-plugin-env (map (match-lambda
+                                  ((key . value)
+                                   #~(string-append #$key "=" #$value)))
+                                (network-manager-environment config))))
       (list (shepherd-service
              (documentation "Run the NetworkManager.")
              (provision '(NetworkManager networking))
@@ -1254,6 +1308,10 @@ (define (network-manager-shepherd-service config)
              (actions (list (shepherd-configuration-action conf)))
              (start
               #~(lambda _
+                  (mkdir-p "/etc/NetworkManager/system-connections")
+                  ;; Create directory to store dnsmasq lease file.
+                  #$@(if (equal? dns "dnsmasq")
+                         '((mkdir-p "/var/lib/misc")) '())
                   (let ((pid
                          (fork+exec-command
                           (list #$(file-append network-manager
@@ -1261,8 +1319,7 @@ (define (network-manager-shepherd-service config)
                                 (string-append "--config=" #$conf)
                                 "--no-daemon")
                           #:environment-variables
-                          (list (string-append "NM_VPN_PLUGIN_DIR=" #$vpn
-                                               "/lib/NetworkManager/VPN")
+                          (list #$@vpn-plugin-env
                                 ;; Override non-existent default users
                                 "NM_OPENVPN_USER="
                                 "NM_OPENVPN_GROUP="
@@ -1301,8 +1358,6 @@ (define network-manager-service-type
                                 network-manager-configuration-network-manager))
             (service-extension account-service-type
                                network-manager-accounts)
-            (service-extension activation-service-type
-                               network-manager-activation)
             (service-extension session-environment-service-type
                                network-manager-environment)
             ;; Add network-manager to the system profile.
-- 
2.39.2





Information forwarded to guix-patches@HIDDEN:
bug#63985; Package guix-patches. Full text available.

Message received at 63985 <at> debbugs.gnu.org:


Received: (at 63985) by debbugs.gnu.org; 26 Jun 2023 22:00:47 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Jun 26 18:00:47 2023
Received: from localhost ([127.0.0.1]:47190 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1qDuGN-0008RR-0b
	for submit <at> debbugs.gnu.org; Mon, 26 Jun 2023 18:00:47 -0400
Received: from smtpmciv3.myservices.hosting ([185.26.107.239]:50424)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <mirai@HIDDEN>) id 1qDuGC-0008Qn-I3
 for 63985 <at> debbugs.gnu.org; Mon, 26 Jun 2023 18:00:37 -0400
Received: from mail1.netim.hosting (unknown [185.26.106.173])
 by smtpmciv3.myservices.hosting (Postfix) with ESMTP id B7439203C4
 for <63985 <at> debbugs.gnu.org>; Tue, 27 Jun 2023 00:00:35 +0200 (CEST)
Received: from localhost (localhost [127.0.0.1])
 by mail1.netim.hosting (Postfix) with ESMTP id 1C7568009B;
 Tue, 27 Jun 2023 00:00:35 +0200 (CEST)
X-Virus-Scanned: Debian amavisd-new at mail1.netim.hosting
Received: from mail1.netim.hosting ([127.0.0.1])
 by localhost (mail1-2.netim.hosting [127.0.0.1]) (amavisd-new, port 10026)
 with ESMTP id vtDQBfPRZ3Qi; Tue, 27 Jun 2023 00:00:34 +0200 (CEST)
Received: from guix-nuc.home.arpa (unknown [10.192.1.83])
 (Authenticated sender: lumen@HIDDEN)
 by mail1.netim.hosting (Postfix) with ESMTPSA id 8FB448009A;
 Tue, 27 Jun 2023 00:00:34 +0200 (CEST)
From: Bruno Victal <mirai@HIDDEN>
To: 63985 <at> debbugs.gnu.org
Subject: [PATCH v3 09/11] services: NetworkManager: Prefer package over
 network-manager.
Date: Mon, 26 Jun 2023 22:59:35 +0100
Message-Id: <81521d94a397b288655c9bc8b68b9a0efe09bc38.1687816734.git.mirai@HIDDEN>
X-Mailer: git-send-email 2.39.2
In-Reply-To: <cover.1687816304.git.mirai@HIDDEN>
References: <cover.1687816304.git.mirai@HIDDEN>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 63985
Cc: Bruno Victal <mirai@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

* gnu/services/networking.scm (<network-manager-configuration>)
[package]: New field.
[network-manager]: Deprecate field.
(network-manager-environment, network-manager-shepherd)
(network-manager-service-type): Adjust to use 'package'.
* doc/guix.texi (Networking Setup): Replace mentions of network-manager with
package.
---
 doc/guix.texi               |  2 +-
 gnu/services/networking.scm | 41 +++++++++++++++++++++++++++++--------
 2 files changed, 33 insertions(+), 10 deletions(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index 2f7e734874..974bfa3fb0 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -20352,7 +20352,7 @@ Networking Setup
 Data type representing the configuration of NetworkManager.
 
 @table @asis
-@item @code{network-manager} (default: @code{network-manager})
+@item @code{package} (default: @code{network-manager})
 The NetworkManager package to use.
 
 @item @code{shepherd-requirement} (default: @code{'(wpa-supplicant)})
diff --git a/gnu/services/networking.scm b/gnu/services/networking.scm
index a4d3affa6c..496ff0f0ec 100644
--- a/gnu/services/networking.scm
+++ b/gnu/services/networking.scm
@@ -166,6 +166,7 @@ (define-module (gnu services networking)
 
             network-manager-configuration
             network-manager-configuration?
+            network-manager-configuration-package
             network-manager-configuration-shepherd-requirement
             network-manager-configuration-dns
             network-manager-configuration-vpn-plugins
@@ -1164,8 +1165,10 @@ (define (warn-iwd?-field-deprecation value)
 'shepherd-requirement' field instead~%")))
   value)
 
+(define-maybe/no-serialization package)
+
 (define-configuration network-manager-configuration
-  (network-manager
+  (package
    (package network-manager)
    "The NetworkManager package to use."
    empty-serializer)
@@ -1242,6 +1245,17 @@ (define-configuration network-manager-configuration
         (apply generic-ini-serialize-string
                'wifi.backend value rest)))))
 
+  (network-manager
+   maybe-package
+   "Deprecated. Use ``package'' field instead."
+   (sanitizer
+    (lambda (value)
+      (when (maybe-value-set? value)
+        (warning (G_ "the 'network-manager' field is deprecated, please use \
+'package' field instead~%")))
+      value))
+   empty-serializer)
+
   (prefix generic-ini-))
 
 (define (network-manager-serialize-configuration config)
@@ -1288,10 +1302,11 @@ (define (network-manager-environment config)
 
 (define (network-manager-shepherd-service config)
   (match-record config <network-manager-configuration>
-    (network-manager shepherd-requirement dns iwd?)
+    (package shepherd-requirement dns iwd?)
     (let* ((iwd? (or iwd?  ; TODO: deprecated field, remove later.
                      (and shepherd-requirement
                           (memq 'iwd shepherd-requirement))))
+           (package (maybe-value network-manager package))
            (conf (network-manager-serialize-configuration config))
            (vpn-plugin-env (map (match-lambda
                                   ((key . value)
@@ -1314,7 +1329,7 @@ (define (network-manager-shepherd-service config)
                          '((mkdir-p "/var/lib/misc")) '())
                   (let ((pid
                          (fork+exec-command
-                          (list #$(file-append network-manager
+                          (list #$(file-append package
                                                "/sbin/NetworkManager")
                                 (string-append "--config=" #$conf)
                                 "--no-daemon")
@@ -1332,7 +1347,7 @@ (define (network-manager-shepherd-service config)
                     ;; to finish starting-up. This is required otherwise
                     ;; services will fail since the network interfaces be
                     ;; absent until NetworkManager finishes setting them up.
-                    (system* #$(file-append network-manager "/bin/nm-online")
+                    (system* #$(file-append package "/bin/nm-online")
                              "--wait-for-startup" "--quiet")
                     ;; XXX: Finally, return the pid from running
                     ;; fork+exec-command to shepherd.
@@ -1342,10 +1357,18 @@ (define (network-manager-shepherd-service config)
 (define network-manager-service-type
   (let ((config->packages
          (lambda (config)
-          (match-record config <network-manager-configuration>
-            (network-manager vpn-plugins)
-            `(,network-manager ,@vpn-plugins)))))
-
+           (match-record config <network-manager-configuration>
+                         (package network-manager vpn-plugins)
+             (let ((package (or (maybe-value network-manager)
+                               package)))
+               `(,package ,@vpn-plugins)))))
+        ;; Handle network-manager field deprecation for
+        ;; polkit-service-type extension.
+        (network-manager-configuration-package*
+         (lambda (config)
+           (match-record config <network-manager-configuration>
+                         (package network-manager)
+             (maybe-value network-manager package)))))
     (service-type
      (name 'network-manager)
      (extensions
@@ -1355,7 +1378,7 @@ (define network-manager-service-type
             (service-extension polkit-service-type
                                (compose
                                 list
-                                network-manager-configuration-network-manager))
+                                network-manager-configuration-package*))
             (service-extension account-service-type
                                network-manager-accounts)
             (service-extension session-environment-service-type
-- 
2.39.2





Information forwarded to guix-patches@HIDDEN:
bug#63985; Package guix-patches. Full text available.

Message received at 63985 <at> debbugs.gnu.org:


Received: (at 63985) by debbugs.gnu.org; 26 Jun 2023 22:00:47 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Jun 26 18:00:47 2023
Received: from localhost ([127.0.0.1]:47187 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1qDuGM-0008RO-DS
	for submit <at> debbugs.gnu.org; Mon, 26 Jun 2023 18:00:46 -0400
Received: from smtpmciv1.myservices.hosting ([185.26.107.237]:37968)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <mirai@HIDDEN>) id 1qDuGA-0008Qe-FE
 for 63985 <at> debbugs.gnu.org; Mon, 26 Jun 2023 18:00:35 -0400
Received: from mail1.netim.hosting (unknown [185.26.106.173])
 by smtpmciv1.myservices.hosting (Postfix) with ESMTP id 775BD20CB0
 for <63985 <at> debbugs.gnu.org>; Tue, 27 Jun 2023 00:00:21 +0200 (CEST)
Received: from localhost (localhost [127.0.0.1])
 by mail1.netim.hosting (Postfix) with ESMTP id C61758009C;
 Tue, 27 Jun 2023 00:00:05 +0200 (CEST)
X-Virus-Scanned: Debian amavisd-new at mail1.netim.hosting
Received: from mail1.netim.hosting ([127.0.0.1])
 by localhost (mail1-2.netim.hosting [127.0.0.1]) (amavisd-new, port 10026)
 with ESMTP id xFp_QWaTk86t; Tue, 27 Jun 2023 00:00:05 +0200 (CEST)
Received: from guix-nuc.home.arpa (unknown [10.192.1.83])
 (Authenticated sender: lumen@HIDDEN)
 by mail1.netim.hosting (Postfix) with ESMTPSA id C99698009A;
 Tue, 27 Jun 2023 00:00:04 +0200 (CEST)
From: Bruno Victal <mirai@HIDDEN>
To: 63985 <at> debbugs.gnu.org
Subject: [PATCH v3 04/11] doc: Rewrite define-configuration.
Date: Mon, 26 Jun 2023 22:59:30 +0100
Message-Id: <3c9e04b336d5627af5167ff3b786918df724f3f6.1687816734.git.mirai@HIDDEN>
X-Mailer: git-send-email 2.39.2
In-Reply-To: <cover.1687816304.git.mirai@HIDDEN>
References: <cover.1687816304.git.mirai@HIDDEN>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 63985
Cc: Bruno Victal <mirai@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Rewrite this section to make it easier to document later syntactical
changes.

* doc/guix.texi (Complex Configurations): Rewrite define-configuration
documentation. Fix simple serializer example.
---
 doc/guix.texi | 102 +++++++++++++++++++++-----------------------------
 1 file changed, 42 insertions(+), 60 deletions(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index 853396f776..8355260378 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -41953,54 +41953,33 @@ Complex Configurations
 files, you can use the utilities defined in the @code{(gnu services
 configuration)} module.
 
-The main utility is the @code{define-configuration} macro, which you
-will use to define a Scheme record type (@pxref{Record Overview,,,
-guile, GNU Guile Reference Manual}).  The Scheme record will be
-serialized to a configuration file by using @dfn{serializers}, which are
-procedures that take some kind of Scheme value and returns a
-G-expression (@pxref{G-Expressions}), which should, once serialized to
-the disk, return a string.  More details are listed below.
+The main utility is the @code{define-configuration} macro, a helper
+used to define a Scheme record type (@pxref{Record Overview,,,
+guile, GNU Guile Reference Manual}).  The fields from this Scheme record
+can be serialized using @dfn{serializers}, which are procedures that take
+some kind of Scheme value and translates them into another Scheme value or
+@ref{G-Expressions}.
 
 @defmac define-configuration name clause1 clause2 @dots{}
 Create a record type named @code{@var{name}} that contains the
 fields found in the clauses.
 
-A clause can have one of the following forms:
+A clause has the following form:
 
 @example
 (@var{field-name}
- (@var{type} @var{default-value})
- @var{documentation})
-
-(@var{field-name}
- (@var{type} @var{default-value})
- @var{documentation}
- (serializer @var{serializer}))
-
-(@var{field-name}
- (@var{type})
- @var{documentation})
-
-(@var{field-name}
- (@var{type})
- @var{documentation}
- (serializer @var{serializer}))
-
-(@var{field-name}
- (@var{type})
+ @var{type-decl}
  @var{documentation}
- (sanitizer @var{sanitizer})
-
-(@var{field-name}
- (@var{type})
- @var{documentation}
- (sanitizer @var{sanitizer})
- (serializer @var{serializer}))
+ @var{option*}
+ @dots{})
 @end example
 
 @var{field-name} is an identifier that denotes the name of the field in
 the generated record.
 
+@var{type-decl} is either @code{@var{type}} for fields that require a
+value to be set or @code{(@var{type} @var{default})} otherwise.
+
 @var{type} is the type of the value corresponding to @var{field-name};
 since Guile is untyped, a predicate
 procedure---@code{@var{type}?}---will be called on the value
@@ -42018,6 +41997,28 @@ Complex Configurations
 @var{documentation} is a string formatted with Texinfo syntax which
 should provide a description of what setting this field does.
 
+@var{option*} is one of the following subclauses:
+
+@table @asis
+@item @code{empty-serializer}
+Exclude this field from serialization.
+
+@item @code{(serializer @var{serializer})}
+@var{serializer} is the name of a procedure which takes two arguments,
+the first is the name of the field, and the second is the value
+corresponding to the field.  The procedure should return a string or
+@ref{G-Expressions} that represents the content that will be serialized
+to the configuration file.  If none is specified, a procedure of the
+name @code{serialize-@var{type}} will be used.
+
+An example of a simple serializer procedure:
+@lisp
+(define (serialize-boolean field-name value)
+  (let ((value (if value "true" "false")))
+    #~(string-append '#$field-name #$value)))
+@end lisp
+
+@item @code{(sanitizer @var{sanitizer})}
 @var{sanitizer} is a procedure which takes one argument,
 a user-supplied value, and returns a ``sanitized'' value for the field.
 If no sanitizer is specified, a default sanitizer is used, which raises
@@ -42031,21 +42032,7 @@ Complex Configurations
         ((symbol? value) (symbol->string value))
         (else (error "bad value"))))
 @end lisp
-
-@var{serializer} is the name of a procedure which takes two arguments,
-the first is the name of the field, and the second is the value
-corresponding to the field.  The procedure should return a string or
-G-expression (@pxref{G-Expressions}) that represents the content that
-will be serialized to the configuration file.  If none is specified, a
-procedure of the name @code{serialize-@var{type}} will be used.
-
-A simple serializer procedure could look like this:
-
-@lisp
-(define (serialize-boolean field-name value)
-  (let ((value (if value "true" "false")))
-    #~(string-append #$field-name #$value)))
-@end lisp
+@end table
 
 In some cases multiple different configuration records might be defined
 in the same file, but their serializers for the same type might have to
@@ -42066,13 +42053,13 @@ Complex Configurations
 
 (define-configuration foo-configuration
   (label
-   (string)
+   string
    "The name of label.")
   (prefix foo-))
 
 (define-configuration bar-configuration
   (ip-address
-   (string)
+   string
    "The IPv4 address for this device.")
   (prefix bar-))
 @end lisp
@@ -42164,11 +42151,6 @@ Complex Configurations
 disk by using something like @code{mixed-text-file}.
 @end deffn
 
-@deffn {Procedure} empty-serializer field-name value
-A serializer that just returns an empty string.  The
-@code{serialize-package} procedure is an alias for this.
-@end deffn
-
 Once you have defined a configuration record, you will most likely also
 want to document it so that other people know to use it.  To help with
 that, there are two procedures, both of which are documented below.
@@ -42271,7 +42253,7 @@ Complex Configurations
 
 (define-configuration contact-configuration
   (name
-   (string)
+   string
    "The name of the contact."
    serialize-contact-name)
   (phone-number
@@ -42281,15 +42263,15 @@ Complex Configurations
    maybe-string
    "The person's email address.")
   (married?
-   (boolean)
+   boolean
    "Whether the person is married."))
 
 (define-configuration contacts-list-configuration
   (name
-   (string)
+   string
    "The name of the owner of this contact list.")
   (email
-   (string)
+   string
    "The owner's email address.")
   (contacts
    (list-of-contact-configurations '())
-- 
2.39.2





Information forwarded to guix-patches@HIDDEN:
bug#63985; Package guix-patches. Full text available.

Message received at 63985 <at> debbugs.gnu.org:


Received: (at 63985) by debbugs.gnu.org; 26 Jun 2023 22:00:36 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Jun 26 18:00:36 2023
Received: from localhost ([127.0.0.1]:47183 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1qDuGB-0008Qp-VU
	for submit <at> debbugs.gnu.org; Mon, 26 Jun 2023 18:00:36 -0400
Received: from smtpmciv1.myservices.hosting ([185.26.107.237]:37948)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <mirai@HIDDEN>) id 1qDuG5-0008QF-4d
 for 63985 <at> debbugs.gnu.org; Mon, 26 Jun 2023 18:00:31 -0400
Received: from mail1.netim.hosting (unknown [185.26.106.173])
 by smtpmciv1.myservices.hosting (Postfix) with ESMTP id 8116020E27
 for <63985 <at> debbugs.gnu.org>; Tue, 27 Jun 2023 00:00:12 +0200 (CEST)
Received: from localhost (localhost [127.0.0.1])
 by mail1.netim.hosting (Postfix) with ESMTP id 900DD8009B;
 Tue, 27 Jun 2023 00:00:00 +0200 (CEST)
X-Virus-Scanned: Debian amavisd-new at mail1.netim.hosting
Received: from mail1.netim.hosting ([127.0.0.1])
 by localhost (mail1-2.netim.hosting [127.0.0.1]) (amavisd-new, port 10026)
 with ESMTP id UcJKeTEHG0fw; Tue, 27 Jun 2023 00:00:00 +0200 (CEST)
Received: from guix-nuc.home.arpa (unknown [10.192.1.83])
 (Authenticated sender: lumen@HIDDEN)
 by mail1.netim.hosting (Postfix) with ESMTPSA id 108568009A;
 Tue, 27 Jun 2023 00:00:00 +0200 (CEST)
From: Bruno Victal <mirai@HIDDEN>
To: 63985 <at> debbugs.gnu.org
Subject: [PATCH v3 03/11] services: fstrim-service-type: Serialize with
 SRFI-171 transducers.
Date: Mon, 26 Jun 2023 22:59:29 +0100
Message-Id: <b4d185c94ecb211880e68f19fc694b00d399f9d0.1687816734.git.mirai@HIDDEN>
X-Mailer: git-send-email 2.39.2
In-Reply-To: <cover.1687816304.git.mirai@HIDDEN>
References: <cover.1687816304.git.mirai@HIDDEN>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 63985
Cc: Bruno Victal <mirai@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

* gnu/services/linux.scm (serialize-fstrim-configuration): Refactor to use
base-transducer.
---
 gnu/services/linux.scm | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/gnu/services/linux.scm b/gnu/services/linux.scm
index d105c42850..3cfa6d6855 100644
--- a/gnu/services/linux.scm
+++ b/gnu/services/linux.scm
@@ -40,6 +40,7 @@ (define-module (gnu services linux)
   #:use-module (srfi srfi-26)
   #:use-module (srfi srfi-34)
   #:use-module (srfi srfi-35)
+  #:use-module (srfi srfi-171)
   #:use-module (ice-9 format)
   #:use-module (ice-9 match)
   #:export (earlyoom-configuration
@@ -227,13 +228,9 @@ (define-configuration fstrim-configuration
   (prefix fstrim-))
 
 (define (serialize-fstrim-configuration config)
-  (concatenate
-   (filter list?
-           (map (lambda (field)
-                  ((configuration-field-serializer field)
-                   (configuration-field-name field)
-                   ((configuration-field-getter field) config)))
-                fstrim-configuration-fields))))
+  (list-transduce (compose (base-transducer config) tconcatenate)
+                  rcons
+                  fstrim-configuration-fields))
 
 (define (fstrim-mcron-job config)
   (match-record config <fstrim-configuration> (package schedule)
-- 
2.39.2





Information forwarded to guix-patches@HIDDEN:
bug#63985; Package guix-patches. Full text available.

Message received at 63985 <at> debbugs.gnu.org:


Received: (at 63985) by debbugs.gnu.org; 26 Jun 2023 22:00:36 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Jun 26 18:00:36 2023
Received: from localhost ([127.0.0.1]:47181 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1qDuGB-0008Ql-9g
	for submit <at> debbugs.gnu.org; Mon, 26 Jun 2023 18:00:35 -0400
Received: from smtpmciv4.myservices.hosting ([185.26.107.240]:44064)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <mirai@HIDDEN>) id 1qDuG4-0008QG-Bz
 for 63985 <at> debbugs.gnu.org; Mon, 26 Jun 2023 18:00:29 -0400
Received: from mail1.netim.hosting (unknown [185.26.106.173])
 by smtpmciv4.myservices.hosting (Postfix) with ESMTP id 64250207A8
 for <63985 <at> debbugs.gnu.org>; Tue, 27 Jun 2023 00:00:11 +0200 (CEST)
Received: from localhost (localhost [127.0.0.1])
 by mail1.netim.hosting (Postfix) with ESMTP id 451B2800A0;
 Tue, 27 Jun 2023 00:00:11 +0200 (CEST)
X-Virus-Scanned: Debian amavisd-new at mail1.netim.hosting
Received: from mail1.netim.hosting ([127.0.0.1])
 by localhost (mail1-2.netim.hosting [127.0.0.1]) (amavisd-new, port 10026)
 with ESMTP id 1BqnHD56ZU7V; Tue, 27 Jun 2023 00:00:10 +0200 (CEST)
Received: from guix-nuc.home.arpa (unknown [10.192.1.83])
 (Authenticated sender: lumen@HIDDEN)
 by mail1.netim.hosting (Postfix) with ESMTPSA id 8A6698009A;
 Tue, 27 Jun 2023 00:00:10 +0200 (CEST)
From: Bruno Victal <mirai@HIDDEN>
To: 63985 <at> debbugs.gnu.org
Subject: [PATCH v3 05/11] services: configuration: Add serializer-options
 field.
Date: Mon, 26 Jun 2023 22:59:31 +0100
Message-Id: <3ff11bf98a7658400615305609654432a4f30bb0.1687816734.git.mirai@HIDDEN>
X-Mailer: git-send-email 2.39.2
In-Reply-To: <cover.1687816304.git.mirai@HIDDEN>
References: <cover.1687816304.git.mirai@HIDDEN>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 63985
Cc: Bruno Victal <mirai@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Allow relaying additional arguments to a serialize-<type> procedure.

* gnu/services/configuration.scm (configuration-field)
<serializer-options>: New field.
(base-transducer, define-maybe-helper): Adjust to relay additional arguments.
(normalize-extra-args): Implement serializer-options literal.
* tests/services/configuration.scm: Add tests for serializer-options.
* doc/guix.texi (Complex Configurations): Document serializer-options.
---
 doc/guix.texi                    | 11 +++++
 gnu/services/configuration.scm   | 49 ++++++++++++-------
 tests/services/configuration.scm | 82 ++++++++++++++++++++++++++++++++
 3 files changed, 126 insertions(+), 16 deletions(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index 8355260378..14802e9366 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -42032,6 +42032,17 @@ Complex Configurations
         ((symbol? value) (symbol->string value))
         (else (error "bad value"))))
 @end lisp
+
+@item @code{(serializer-options @var{arglst})}
+@var{arglst} is a list of extra arguments that are relayed to the
+serializing procedure.  This allows for writing serialization
+procedures that take more than two arguments.
+
+An example of a serializer procedure that requires additional data:
+@lisp
+(define* (serialize-port field value #:key context)
+  #~(format #f "section=~a,port=~d" #$context #$value))
+@end lisp
 @end table
 
 In some cases multiple different configuration records might be defined
diff --git a/gnu/services/configuration.scm b/gnu/services/configuration.scm
index cd2cb8318b..4eee5a26c2 100644
--- a/gnu/services/configuration.scm
+++ b/gnu/services/configuration.scm
@@ -50,6 +50,7 @@ (define-module (gnu services configuration)
             configuration-field-error
             configuration-field-sanitizer
             configuration-field-serializer
+            configuration-field-serializer-options
             configuration-field-getter
             configuration-field-default-value-thunk
             configuration-field-documentation
@@ -127,6 +128,7 @@ (define-record-type* <configuration-field>
   (predicate configuration-field-predicate)
   (sanitizer configuration-field-sanitizer)
   (serializer configuration-field-serializer)
+  (serializer-options configuration-field-serializer-options)
   (default-value-thunk configuration-field-default-value-thunk)
   (documentation configuration-field-documentation))
 
@@ -144,9 +146,13 @@ (define (base-transducer config)
            ;; Only serialize fields whose value isn't '%unset-marker%.
            (tfilter-maybe-value config)
            (tmap (lambda (field)
-                   ((configuration-field-serializer field)
-                    (configuration-field-name field)
-                    ((configuration-field-getter field) config))))))
+                   (let ((serializer (configuration-field-serializer field))
+                         (field-name (configuration-field-name field))
+                         (value
+                          ((configuration-field-getter field) config))
+                         (serializer-options
+                          (configuration-field-serializer-options field)))
+                     (apply serializer field-name value serializer-options))))))
 
 (define (serialize-configuration config fields)
   #~(string-append
@@ -173,10 +179,9 @@ (define (define-maybe-helper serialize? prefix syn)
              (or (not (maybe-value-set? val))
                  (stem? val)))
            #,@(if serialize?
-                  (list #'(define (serialize-maybe-stem field-name val)
-                            (if (stem? val)
-                                (serialize-stem field-name val)
-                                "")))
+                  (list #'(define (serialize-maybe-stem field-name val . rest)
+                            (when (maybe-value-set? val)
+                              (apply serialize-stem field-name val rest))))
                   '()))))))
 
 (define-syntax define-maybe
@@ -210,38 +215,49 @@ (define (define-configuration-helper serialize? serializer-prefix syn)
     "Extract and normalize arguments following @var{doc}."
     (let loop ((s s)
                (sanitizer* #f)
-               (serializer* #f))
-      (syntax-case s (sanitizer serializer empty-serializer)
+               (serializer* #f)
+               (serializer-options* #f))
+      (syntax-case s (sanitizer serializer empty-serializer serializer-options)
         (((sanitizer proc) tail ...)
          (if sanitizer*
              (syntax-violation 'sanitizer
                                "duplicate entry" #'proc)
-             (loop #'(tail ...) #'proc serializer*)))
+             (loop #'(tail ...)
+                   #'proc serializer* serializer-options*)))
         (((serializer proc) tail ...)
          (if serializer*
              (syntax-violation 'serializer
                                "duplicate or conflicting entry" #'proc)
-             (loop #'(tail ...) sanitizer* #'proc)))
+             (loop #'(tail ...)
+                   sanitizer* #'proc serializer-options*)))
         ((empty-serializer tail ...)
          (if serializer*
              (syntax-violation 'empty-serializer
                                "duplicate or conflicting entry" #f)
-             (loop #'(tail ...) sanitizer* #'empty-serializer)))
+             (loop #'(tail ...)
+                   sanitizer* #'empty-serializer #f)))
+        (((serializer-options args) tail ...)
+         (if serializer-options*
+             (syntax-violation 'serializer-options
+                               "duplicate or conflicting entry" #f)
+             (loop #'(tail ...)
+                   sanitizer* serializer* #'args)))
         (()  ; stop condition
-         (values (list sanitizer* serializer*)))
+         (values (list sanitizer* serializer*
+                       (or serializer-options* #'(quote ())))))
         ((proc)  ; TODO: deprecated, to be removed.
-         (every not (list sanitizer* serializer*))
+         (every not (list sanitizer* serializer* serializer-options*))
          (begin
            (warning #f (G_ "specifying serializers after documentation is \
 deprecated, use (serializer ~a) instead~%") (syntax->datum #'proc))
-           (values (list #f #'proc)))))))
+           (values (list #f #'proc #'(quote ()))))))))
 
   (syntax-case syn ()
     ((_ stem (field field-type+def doc extra-args ...) ...)
      (with-syntax
          ((((field-type def) ...)
            (map normalize-field-type+def #'(field-type+def ...)))
-          (((sanitizer* serializer*) ...)
+          (((sanitizer* serializer* serializer-options*) ...)
            (map normalize-extra-args #'((extra-args ...) ...))))
        (with-syntax
            (((field-getter ...)
@@ -327,6 +343,7 @@ (define (define-configuration-helper serialize? serializer-prefix syn)
                        (or field-sanitizer
                            (id #'stem #'validate- #'stem #'- #'field)))
                       (serializer field-serializer)
+                      (serializer-options serializer-options*)
                       (default-value-thunk
                         (lambda ()
                           (if (maybe-value-set? (syntax->datum field-default))
diff --git a/tests/services/configuration.scm b/tests/services/configuration.scm
index 40a4e74b4d..8b1d1e4749 100644
--- a/tests/services/configuration.scm
+++ b/tests/services/configuration.scm
@@ -297,6 +297,88 @@ (define (sanitize-port value)
                     (lambda _ "lorem")
                     (sanitizer (lambda () #t)))))))
 
+(test-group "Serializer options"
+  (test-group "Serialize keyword arguments"
+    (define* (serialize-port field value #:key host)
+      (format #f "host=~a,port=~d" host value))
+
+    (define-configuration kwarg-config
+      (port
+       (port 80)
+       "Lorem Ipsum."
+       (serializer-options '(#:host "[2001:db8::1]"))))
+
+    (define-maybe port)
+    (define-configuration kwarg-maybe-config
+      (port
+       (maybe-port 80)
+       "Lorem Ipsum."
+       (serializer-options '(#:host "[2001:db8::1]"))))
+
+    (test-equal "keyword argument provided"
+      "host=[2001:db8::1],port=80"
+      (eval-gexp
+       (serialize-configuration (kwarg-config)
+                                kwarg-config-fields)))
+
+    (test-equal "keyword argument provided, maybe type"
+      "host=[2001:db8::1],port=80"
+      (eval-gexp
+       (serialize-configuration (kwarg-maybe-config)
+                                kwarg-maybe-config-fields))))
+
+  (test-group "Serialize optional arguments"
+    (define* (serialize-port field-name value #:optional override-name)
+      (format #f "~a=~d" (or override-name field-name) value))
+
+    (define-configuration with-optarg
+      (port
+       (port 80)
+       "Lorem Ipsum."
+       (serializer-options '(service-port))))
+
+    (define-configuration without-optarg
+      (port
+       (port 80)
+       "Lorem Ipsum."))
+
+    (test-equal "optional argument, provided"
+      "service-port=80"
+      (eval-gexp (serialize-configuration (with-optarg)
+                                          with-optarg-fields)))
+
+    (test-equal "optional argument, absent"
+      "port=80"
+      (eval-gexp (serialize-configuration (without-optarg)
+                                          without-optarg-fields))))
+
+  (test-group "Serialize optional & keyword arguments"
+    (define* (serialize-port field-name value #:optional override-name
+                             #:key host)
+      (format #f "host=~a,~a=~d" host (or override-name field-name) value))
+
+    (define-configuration mixed-args
+      (port
+       (port 80)
+       "Lorem Ipsum."
+       (serializer-options '(service-port #:host "example.com"))))
+
+    (define-configuration mixed-no-optarg
+      (port
+       (port 80)
+       "Lorem Ipsum."
+       (serializer-options '(#:host "example.com"))))
+
+    (test-equal "mixed arguments, optional provided"
+      "host=example.com,service-port=80"
+      (eval-gexp (serialize-configuration (mixed-args)
+                                          mixed-args-fields)))
+
+    (test-equal "mixed arguments, optional absent"
+      "host=example.com,port=80"
+      (eval-gexp (serialize-configuration (mixed-no-optarg)
+                                          mixed-no-optarg-fields)))))
+
 
 ;;;
 ;;; define-maybe macro.
-- 
2.39.2





Information forwarded to guix-patches@HIDDEN:
bug#63985; Package guix-patches. Full text available.

Message received at 63985 <at> debbugs.gnu.org:


Received: (at 63985) by debbugs.gnu.org; 26 Jun 2023 22:00:29 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Jun 26 18:00:29 2023
Received: from localhost ([127.0.0.1]:47177 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1qDuG4-0008QH-IL
	for submit <at> debbugs.gnu.org; Mon, 26 Jun 2023 18:00:29 -0400
Received: from smtpm1.myservices.hosting ([185.26.105.232]:58444)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <mirai@HIDDEN>) id 1qDuFx-0008Pt-7k
 for 63985 <at> debbugs.gnu.org; Mon, 26 Jun 2023 18:00:22 -0400
Received: from mail1.netim.hosting (unknown [185.26.106.173])
 by smtpm1.myservices.hosting (Postfix) with ESMTP id A97D520512
 for <63985 <at> debbugs.gnu.org>; Tue, 27 Jun 2023 00:00:20 +0200 (CEST)
Received: from localhost (localhost [127.0.0.1])
 by mail1.netim.hosting (Postfix) with ESMTP id 0CCB88009B;
 Tue, 27 Jun 2023 00:00:20 +0200 (CEST)
X-Virus-Scanned: Debian amavisd-new at mail1.netim.hosting
Received: from mail1.netim.hosting ([127.0.0.1])
 by localhost (mail1-2.netim.hosting [127.0.0.1]) (amavisd-new, port 10026)
 with ESMTP id 2l1PFbt-_Fo0; Tue, 27 Jun 2023 00:00:19 +0200 (CEST)
Received: from guix-nuc.home.arpa (unknown [10.192.1.83])
 (Authenticated sender: lumen@HIDDEN)
 by mail1.netim.hosting (Postfix) with ESMTPSA id 3BF1D8009A;
 Tue, 27 Jun 2023 00:00:19 +0200 (CEST)
From: Bruno Victal <mirai@HIDDEN>
To: 63985 <at> debbugs.gnu.org
Subject: [PATCH v3 07/11] services: configuration: Add some commonly used
 predicates.
Date: Mon, 26 Jun 2023 22:59:33 +0100
Message-Id: <e2927b18af2249d6759a09500022638770020490.1687816734.git.mirai@HIDDEN>
X-Mailer: git-send-email 2.39.2
In-Reply-To: <cover.1687816304.git.mirai@HIDDEN>
References: <cover.1687816304.git.mirai@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 63985
Cc: Bruno Victal <mirai@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

* gnu/services/configuration.scm (list-of-packages?, list-of-symbols?): New
predicate.
* gnu/services/audio.scm (list-of-symbol?): Remove.
* gnu/services/telephony.scm (string-list?): Remove.
(serialize-string-list): Rename to …
(serialize-list-of-strings): … this.
(account-fingerprint-list?, jami-account-list?): Use list-of.
* doc/guix.texi: Update it.
---
 doc/guix.texi                  |  4 ++--
 gnu/services/audio.scm         |  7 ++-----
 gnu/services/configuration.scm | 16 ++++++++++++++++
 gnu/services/telephony.scm     | 20 +++++++-------------
 4 files changed, 27 insertions(+), 20 deletions(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index 14802e9366..2f7e734874 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -27850,7 +27850,7 @@ Telephony Services
 connection to the Internet has been lost.  When left unspecified,
 the value from the account archive prevails.
 
-@item @code{bootstrap-hostnames} (type: maybe-string-list)
+@item @code{bootstrap-hostnames} (type: maybe-list-of-strings)
 A list of hostnames or IPs pointing to OpenDHT nodes, that should be
 used to initially join the OpenDHT network.  When left unspecified, the
 value from the account archive prevails.
@@ -34244,7 +34244,7 @@ Audio Services
 The group to run mpd as.
 
 The default @code{%mpd-group} is a system group with name ``mpd''.
-@item @code{shepherd-requirement} (default: @code{'()}) (type: list-of-symbol)
+@item @code{shepherd-requirement} (default: @code{'()}) (type: list-of-symbols)
 A list of symbols naming Shepherd services that this service
 will depend on.
 
diff --git a/gnu/services/audio.scm b/gnu/services/audio.scm
index 690409b7a1..89ab9c51c6 100644
--- a/gnu/services/audio.scm
+++ b/gnu/services/audio.scm
@@ -137,9 +137,6 @@ (define (uglify-field-name field-name)
                                    str)
                                #\-) "_")))
 
-(define list-of-symbol?
-  (list-of symbol?))
-
 ;; Helpers for deprecated field types, to be removed later.
 (define %lazy-group (make-symbol "%lazy-group"))
 
@@ -413,7 +410,7 @@ (define-configuration mpd-configuration
    (sanitizer mpd-group-sanitizer))
 
   (shepherd-requirement
-   (list-of-symbol '())
+   (list-of-symbols '())
    "This is a list of symbols naming Shepherd services that this service
 will depend on."
    empty-serializer)
@@ -711,7 +708,7 @@ (define-configuration/no-serialization mympd-configuration
     empty-serializer)
 
   (shepherd-requirement
-   (list-of-symbol '())
+   (list-of-symbols '())
    "This is a list of symbols naming Shepherd services that this service
 will depend on."
    empty-serializer)
diff --git a/gnu/services/configuration.scm b/gnu/services/configuration.scm
index 4eee5a26c2..fd9130b1ea 100644
--- a/gnu/services/configuration.scm
+++ b/gnu/services/configuration.scm
@@ -81,7 +81,9 @@ (define-module (gnu services configuration)
             interpose
             list-of
 
+            list-of-packages?
             list-of-strings?
+            list-of-symbols?
             alist?
             serialize-file-like
             text-config?
@@ -508,6 +510,10 @@ (define* (interpose ls  #:optional (delimiter "\n") (grammar 'infix))
                           (cons delimiter acc))))
               '() ls))
 
+
+;;;
+;;; Commonly used predicates
+
 (define (list-of pred?)
   "Return a procedure that takes a list and check if all the elements of
 the list result in @code{#t} when applying PRED? on them."
@@ -516,10 +522,20 @@ (define (list-of pred?)
           (every pred? x)
           #f)))
 
+(define list-of-packages?
+  (list-of package?))
 
 (define list-of-strings?
   (list-of string?))
 
+(define list-of-symbols?
+  (list-of symbol?))
+
+
+;;;
+;;; Special serializers
+;;;
+
 (define alist?
   (list-of pair?))
 
diff --git a/gnu/services/telephony.scm b/gnu/services/telephony.scm
index 56b7772f58..c9b5d6cd99 100644
--- a/gnu/services/telephony.scm
+++ b/gnu/services/telephony.scm
@@ -117,15 +117,10 @@ (define (string-or-computed-file? val)
   (or (string? val)
       (computed-file? val)))
 
-(define (string-list? val)
-  (and (list? val)
-       (and-map string? val)))
+(define account-fingerprint-list?
+  (list-of account-fingerprint?))
 
-(define (account-fingerprint-list? val)
-  (and (list? val)
-       (and-map account-fingerprint? val)))
-
-(define-maybe string-list)
+(define-maybe list-of-strings)
 
 (define-maybe/no-serialization account-fingerprint-list)
 
@@ -135,7 +130,7 @@ (define-maybe string)
 
 ;;; The following serializers are used to derive an account details alist from
 ;;; a <jami-account> record.
-(define (serialize-string-list _ val)
+(define (serialize-list-of-strings _ val)
   (string-join val ";"))
 
 (define (serialize-boolean _ val)
@@ -188,7 +183,7 @@ (define-configuration jami-account
 connection to the the Internet has been lost.  When left unspecified, the
 value from the account archive prevails.")
   (bootstrap-hostnames
-   maybe-string-list
+   maybe-list-of-strings
    "A list of hostnames or IPs pointing to OpenDHT nodes, that should be used
 to initially join the OpenDHT network.  When left unspecified, the value from
 the account archive prevails.")
@@ -220,9 +215,8 @@ (define (jami-account->alist jami-account-object)
 
   (list-transduce jami-account-transducer rcons jami-account-fields))
 
-(define (jami-account-list? val)
-  (and (list? val)
-       (and-map jami-account? val)))
+(define jami-account-list?
+  (list-of jami-account?))
 
 (define-maybe/no-serialization jami-account-list)
 
-- 
2.39.2





Information forwarded to guix-patches@HIDDEN:
bug#63985; Package guix-patches. Full text available.

Message received at 63985 <at> debbugs.gnu.org:


Received: (at 63985) by debbugs.gnu.org; 26 Jun 2023 22:00:22 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Jun 26 18:00:22 2023
Received: from localhost ([127.0.0.1]:47174 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1qDuFx-0008Pv-Ex
	for submit <at> debbugs.gnu.org; Mon, 26 Jun 2023 18:00:22 -0400
Received: from smtpm3.myservices.hosting ([185.26.105.234]:32906)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <mirai@HIDDEN>) id 1qDuFu-0008Pk-4i
 for 63985 <at> debbugs.gnu.org; Mon, 26 Jun 2023 18:00:19 -0400
Received: from mail1.netim.hosting (unknown [185.26.106.173])
 by smtpm3.myservices.hosting (Postfix) with ESMTP id 5B82D20FAB
 for <63985 <at> debbugs.gnu.org>; Tue, 27 Jun 2023 00:00:17 +0200 (CEST)
Received: from localhost (localhost [127.0.0.1])
 by mail1.netim.hosting (Postfix) with ESMTP id A1EB28009B;
 Tue, 27 Jun 2023 00:00:16 +0200 (CEST)
X-Virus-Scanned: Debian amavisd-new at mail1.netim.hosting
Received: from mail1.netim.hosting ([127.0.0.1])
 by localhost (mail1-2.netim.hosting [127.0.0.1]) (amavisd-new, port 10026)
 with ESMTP id yhy3_izi1NZy; Tue, 27 Jun 2023 00:00:15 +0200 (CEST)
Received: from guix-nuc.home.arpa (unknown [10.192.1.83])
 (Authenticated sender: lumen@HIDDEN)
 by mail1.netim.hosting (Postfix) with ESMTPSA id 023A98009A;
 Tue, 27 Jun 2023 00:00:14 +0200 (CEST)
From: Bruno Victal <mirai@HIDDEN>
To: 63985 <at> debbugs.gnu.org
Subject: [PATCH v3 06/11] services: configuration: New generic-ini module.
Date: Mon, 26 Jun 2023 22:59:32 +0100
Message-Id: <e0204bcb23b5a842683ff7929f59af4a3e06f5da.1687816734.git.mirai@HIDDEN>
X-Mailer: git-send-email 2.39.2
In-Reply-To: <cover.1687816304.git.mirai@HIDDEN>
References: <cover.1687816304.git.mirai@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 63985
Cc: Bruno Victal <mirai@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Implements a ‘serialize-ini-configuration’ procedure for serializing
record-types defined with define-configuration into generic INI files.

* gnu/services/configuration/generic-ini.scm: New module.
* tests/services/configuration/generic-ini.scm: Add tests for new module.
* Makefile.am: Register tests.
* gnu/local.mk: Register module.
---
 Makefile.am                                  |   1 +
 gnu/local.mk                                 |   1 +
 gnu/services/configuration/generic-ini.scm   | 165 +++++++++++++++++++
 tests/services/configuration/generic-ini.scm | 129 +++++++++++++++
 4 files changed, 296 insertions(+)
 create mode 100644 gnu/services/configuration/generic-ini.scm
 create mode 100644 tests/services/configuration/generic-ini.scm

diff --git a/Makefile.am b/Makefile.am
index a386e6033c..b6d048f140 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -553,6 +553,7 @@ SCM_TESTS =					\
   tests/services.scm				\
   tests/services/file-sharing.scm		\
   tests/services/configuration.scm		\
+  tests/services/configuration/generic-ini.scm	\
   tests/services/lightdm.scm			\
   tests/services/linux.scm			\
   tests/services/telephony.scm			\
diff --git a/gnu/local.mk b/gnu/local.mk
index e65888a044..796ac33107 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -670,6 +670,7 @@ GNU_SYSTEM_MODULES =				\
   %D%/services/cgit.scm			\
   %D%/services/ci.scm				\
   %D%/services/configuration.scm		\
+  %D%/services/configuration/generic-ini.scm	\
   %D%/services/cuirass.scm			\
   %D%/services/cups.scm				\
   %D%/services/databases.scm			\
diff --git a/gnu/services/configuration/generic-ini.scm b/gnu/services/configuration/generic-ini.scm
new file mode 100644
index 0000000000..4f83cce13a
--- /dev/null
+++ b/gnu/services/configuration/generic-ini.scm
@@ -0,0 +1,165 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2023 Bruno Victal <mirai@HIDDEN>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (gnu services configuration generic-ini)
+  #:use-module (gnu services configuration)
+  #:use-module (guix gexp)
+  #:use-module (srfi srfi-9)
+  #:use-module (srfi srfi-171)
+  #:use-module (srfi srfi-171 meta)
+  #:use-module (ice-9 match)
+  #:export (ini-entry?
+            list-of-ini-entries?
+
+            ini-entries
+            ini-entries?
+            entries
+
+            serialize-ini-configuration
+            generic-ini-serialize-string
+            generic-ini-serialize-boolean
+            generic-ini-serialize-ini-entry
+            generic-ini-serialize-list-of-ini-entries))
+
+;;;
+;;; Generic INI serializer
+;;;
+
+
+;;;
+;;; Predicates
+;;;
+
+;; This is the same format used in SRFI-233 but without comment support.
+(define ini-entry?
+  (match-lambda
+    (((? symbol?) (? symbol?) (? string?)) #t)
+    (_ #f)))
+
+(define list-of-ini-entries?
+  (list-of ini-entry?))
+
+;;
+;; Overall design document
+;;
+;; This module implements a generic INI serializer for a record-type defined
+;; using define-configuration.
+;; It expects that the serialize-<type> procedures return a list with
+;; three elements of the form:
+;;    (list section key value)
+;; Where ‘section’ and ‘key’ are symbols and ‘value’ is a string.
+;; For serializing procedures that have to return multiple entries at once,
+;; such as encountered when synthesizing configuration from a record object
+;; or “escape hatch fields”, it must wrap the result by calling ‘ini-entries’
+;; with a list of INI-entries as described above.
+;; This is implemented as a constructor for a SRFI-9 record type named
+;; “<ini-entries>”.
+;;
+;; The fields within define-configuration do not have to be ordered in,
+;; any way whatsoever as the ‘serialize-ini’ will group them up automatically.
+;; This implies that no assumptions should be made regarding the order of the
+;; values in the serializied INI output.
+;;
+;; Additional notes:
+;; Q: Why not replace rcons with string-append and forego the ungexp-splice?
+;; A: The transduction happens outside of the G-Exp while the final string-append
+;;    takes place in the G-Exp.
+;;
+;; Debugging tips: Open a REPL and try one transducer at a time from
+;; ‘ini-transducer’.
+;;
+
+;; A “bag” holding multiple ini-entries.
+(define-record-type <ini-entries>
+  (ini-entries val)
+  ini-entries?
+  (val entries))
+
+(define (add-section-header partition)
+  (let ((header (caar partition)))
+    (cons (list header)
+          partition)))
+
+(define serializer
+  (match-lambda
+    ((section)
+     #~(format #f "[~a]~%" '#$section))
+    ((section key value)
+     #~(format #f "~a=~a~%" '#$key #$value))
+    ;; Used for the newline between sections.
+    ('*section-separator* "\n")))
+
+(define ini-transducer
+  (compose (tpartition car)
+           (tmap add-section-header)
+           (tadd-between '(*section-separator*))
+           tconcatenate
+           (tmap serializer)))
+
+;; A selective version of ‘tconcatenate’ but for ‘<ini-entries>’ objects only.
+(define (tconcatenate-ini-entries reducer)
+  (case-lambda
+    (() '())
+    ((result) (reducer result))
+    ((result input)
+     (if (ini-entries? input)
+         (list-reduce (preserving-reduced reducer) result (entries input))
+         (reducer result input)))))
+
+;; A “first-pass” serialization is performed and sorted in order
+;; to group up the fields by “section” before passing through the
+;; transducer.
+(define (serialize-ini-configuration config fields)
+  (let* ((srfi-233-IR
+          ;; First pass: “serialize” into a (disordered) list of
+          ;; SRFI-233 entries.
+          (list-transduce (compose (base-transducer config)
+                                   tconcatenate-ini-entries)
+                          rcons fields))
+         (comparator (lambda (x y)
+                       ;; Sort the SRFI-233 entries by section.
+                       (string<=? (symbol->string (car x))
+                                  (symbol->string (car y)))))
+         (sorted-entries (sort srfi-233-IR comparator)))
+    #~(string-append
+       #$@(list-transduce ini-transducer rcons sorted-entries))))
+
+
+;;;
+;;; Serializers
+;;;
+
+;; These are “gratuitous” serializers that can be readily used by
+;; using the literal (prefix generic-ini-) within define-configuration.
+
+;; Notes: field-name-transform can be used to “uglify” a field-name,
+;; e.g. want-ipv6?  ->  want_ipv6
+(define* (generic-ini-serialize-string field-name value #:key section
+                                       (field-name-transform identity))
+  (list section (field-name-transform field-name) value))
+
+(define* (generic-ini-serialize-boolean field-name value #:key section
+                            (field-name-transform identity))
+  (list section (field-name-transform field-name)
+        (if value "true" "false")))
+
+(define (generic-ini-serialize-ini-entry field-name value)
+  value)
+
+(define (generic-ini-serialize-list-of-ini-entries field-name value)
+  (ini-entries value))
diff --git a/tests/services/configuration/generic-ini.scm b/tests/services/configuration/generic-ini.scm
new file mode 100644
index 0000000000..797a01af31
--- /dev/null
+++ b/tests/services/configuration/generic-ini.scm
@@ -0,0 +1,129 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2023 Bruno Victal <mirai@HIDDEN>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (tests services configuration generic-ini)
+  #:use-module (gnu services configuration)
+  #:use-module (gnu services configuration generic-ini)
+  #:use-module (guix diagnostics)
+  #:use-module (guix gexp)
+  #:use-module (guix store)
+  #:autoload (guix i18n) (G_)
+  #:use-module (srfi srfi-34)
+  #:use-module (srfi srfi-64)
+  #:use-module (srfi srfi-71))
+
+;;; Tests for the (gnu services configuration generic-ini) module.
+
+(test-begin "generic-ini serializer")
+
+
+(define expected-output "\
+[guardians]
+llamas=Tommy,Isabella
+donkeys=Franz,Olly
+
+[ranch]
+shepherd=Emma
+
+[shed]
+colours=Alizarin
+enabled=true
+capacity=50
+production=wool
+
+[vehicles]
+cars=313
+bikes=Amaryllis
+")
+
+
+;;;
+;;; Serializers
+;;;
+(define (strip-trailing-?-character field-name)
+  "Drop rightmost '?' character"
+  (let ((str (symbol->string field-name)))
+    (if (string-suffix? "?" str)
+        (string->symbol (string-drop-right str 1))
+        field-name)))
+
+(define* (serialize-string field-name value #:key section)
+  (list section field-name value))
+
+(define* (serialize-number field-name value #:key section)
+  (list section field-name (number->string value)))
+
+(define* (serialize-boolean field-name value #:key section)
+  (list section (strip-trailing-?-character field-name)
+        (if value "true" "false")))
+
+(define serialize-ini-entry
+  generic-ini-serialize-ini-entry)
+
+(define serialize-list-of-ini-entries
+  generic-ini-serialize-list-of-ini-entries)
+
+
+;;;
+;;; Record-type definition
+;;;
+
+(define-configuration foo-configuration
+  (production
+   (string "wool")
+   "Lorem Ipsum …"
+   (serializer-options '(#:section shed)))
+
+  (capacity
+   (number 50)
+   "Lorem Ipsum …"
+   (serializer-options '(#:section shed)))
+
+  (enabled?
+   (boolean #t)
+   "Lorem Ipsum …"
+   (serializer-options '(#:section shed)))
+
+  (shepherd
+   (string "Emma")
+   "Lorem Ipsum …"
+   (serializer-options '(#:section ranch)))
+
+  (raw-entry
+   (ini-entry '(shed colours "Alizarin"))
+   "Lorem Ipsum …")
+
+  (escape-hatch
+   (list-of-ini-entries '((vehicles bikes "Amaryllis")
+                          (vehicles cars "313")
+                          (guardians donkeys "Franz,Olly")
+                          (guardians llamas "Tommy,Isabella")))
+   "Lorem Ipsum …"))
+
+(test-equal "Well-formed INI output from serialize-ini"
+  expected-output
+  ;; Serialize the above into a string, properly resolving any potential
+  ;; nested G-Exps as well.
+  (let* ((serialized-ini
+          (serialize-ini-configuration (foo-configuration)
+                                       foo-configuration-fields))
+         (lowered conn (with-store store
+                         ((lower-gexp serialized-ini) store))))
+    (eval (lowered-gexp-sexp lowered) (current-module))))
+
+(test-end)
-- 
2.39.2





Information forwarded to guix-patches@HIDDEN:
bug#63985; Package guix-patches. Full text available.

Message received at 63985 <at> debbugs.gnu.org:


Received: (at 63985) by debbugs.gnu.org; 26 Jun 2023 22:00:02 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Jun 26 18:00:02 2023
Received: from localhost ([127.0.0.1]:47170 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1qDuFd-0008NY-DX
	for submit <at> debbugs.gnu.org; Mon, 26 Jun 2023 18:00:02 -0400
Received: from smtpm2.myservices.hosting ([185.26.105.233]:34198)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <mirai@HIDDEN>) id 1qDuFb-0008NK-BD
 for 63985 <at> debbugs.gnu.org; Mon, 26 Jun 2023 17:59:59 -0400
Received: from mail1.netim.hosting (unknown [185.26.106.173])
 by smtpm2.myservices.hosting (Postfix) with ESMTP id 86F0820F16
 for <63985 <at> debbugs.gnu.org>; Mon, 26 Jun 2023 23:59:58 +0200 (CEST)
Received: from localhost (localhost [127.0.0.1])
 by mail1.netim.hosting (Postfix) with ESMTP id 0228A8009B;
 Mon, 26 Jun 2023 23:59:55 +0200 (CEST)
X-Virus-Scanned: Debian amavisd-new at mail1.netim.hosting
Received: from mail1.netim.hosting ([127.0.0.1])
 by localhost (mail1-2.netim.hosting [127.0.0.1]) (amavisd-new, port 10026)
 with ESMTP id 22Uu61zbYXcM; Mon, 26 Jun 2023 23:59:54 +0200 (CEST)
Received: from guix-nuc.home.arpa (unknown [10.192.1.83])
 (Authenticated sender: lumen@HIDDEN)
 by mail1.netim.hosting (Postfix) with ESMTPSA id 6DB028009A;
 Mon, 26 Jun 2023 23:59:54 +0200 (CEST)
From: Bruno Victal <mirai@HIDDEN>
To: 63985 <at> debbugs.gnu.org
Subject: [PATCH v3 02/11] services: configuration: Use transducers within
 serialize-configuration.
Date: Mon, 26 Jun 2023 22:59:28 +0100
Message-Id: <aff5b56a37332c8dc302466fc3f2c03866458f24.1687816734.git.mirai@HIDDEN>
X-Mailer: git-send-email 2.39.2
In-Reply-To: <cover.1687816304.git.mirai@HIDDEN>
References: <cover.1687816304.git.mirai@HIDDEN>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 63985
Cc: Bruno Victal <mirai@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Introduces 'base-transducer', a SRFI-171 based transducer that can be used as a
starting point for writing custom configuration record serializing procedures.

This also fixes the symbol maybe-value serialization test case.

* gnu/services/configuration.scm (empty-serializer?): New predicate.
(base-transducer, tfilter-maybe-value): New procedure.
(serialize-configuration): Adapt to use base-transducer.

* gnu/services/telephony.scm (jami-account->alist): Use transducers to skip
fields that are unserializable or whose field maybe-value is unset.

* tests/services/configuration.scm: Remove test-expect-fail.
---
 gnu/services/configuration.scm   | 29 ++++++++++++++++++++++++-----
 gnu/services/telephony.scm       | 27 +++++++++++++--------------
 tests/services/configuration.scm |  6 +-----
 3 files changed, 38 insertions(+), 24 deletions(-)

diff --git a/gnu/services/configuration.scm b/gnu/services/configuration.scm
index dafe72f4fe..cd2cb8318b 100644
--- a/gnu/services/configuration.scm
+++ b/gnu/services/configuration.scm
@@ -42,6 +42,7 @@ (define-module (gnu services configuration)
   #:use-module (srfi srfi-26)
   #:use-module (srfi srfi-34)
   #:use-module (srfi srfi-35)
+  #:use-module (srfi srfi-171)
   #:export (configuration-field
             configuration-field-name
             configuration-field-type
@@ -59,6 +60,10 @@ (define-module (gnu services configuration)
             define-configuration/no-serialization
             no-serialization
 
+            empty-serializer?
+            tfilter-maybe-value
+            base-transducer
+
             serialize-configuration
             define-maybe
             define-maybe/no-serialization
@@ -125,13 +130,27 @@ (define-record-type* <configuration-field>
   (default-value-thunk configuration-field-default-value-thunk)
   (documentation configuration-field-documentation))
 
+(define (empty-serializer? field)
+  (eq? empty-serializer
+       (configuration-field-serializer field)))
+
+(define (tfilter-maybe-value config)
+  (tfilter (lambda (field)
+             (let ((field-value ((configuration-field-getter field) config)))
+               (maybe-value-set? field-value)))))
+
+(define (base-transducer config)
+  (compose (tremove empty-serializer?)
+           ;; Only serialize fields whose value isn't '%unset-marker%.
+           (tfilter-maybe-value config)
+           (tmap (lambda (field)
+                   ((configuration-field-serializer field)
+                    (configuration-field-name field)
+                    ((configuration-field-getter field) config))))))
+
 (define (serialize-configuration config fields)
   #~(string-append
-     #$@(map (lambda (field)
-               ((configuration-field-serializer field)
-                (configuration-field-name field)
-                ((configuration-field-getter field) config)))
-             fields)))
+     #$@(list-transduce (base-transducer config) rcons fields)))
 
 (define-syntax-rule (id ctx parts ...)
   "Assemble PARTS into a raw (unhygienic) identifier."
diff --git a/gnu/services/telephony.scm b/gnu/services/telephony.scm
index 23ccb8d403..56b7772f58 100644
--- a/gnu/services/telephony.scm
+++ b/gnu/services/telephony.scm
@@ -37,6 +37,7 @@ (define-module (gnu services telephony)
   #:use-module (srfi srfi-1)
   #:use-module (srfi srfi-2)
   #:use-module (srfi srfi-26)
+  #:use-module (srfi srfi-171)
   #:use-module (ice-9 format)
   #:use-module (ice-9 match)
   #:export (jami-account
@@ -204,22 +205,20 @@ (define (jami-account->alist jami-account-object)
       ('rendezvous-point? "Account.rendezVous")
       ('peer-discovery? "Account.peerDiscovery")
       ('bootstrap-hostnames "Account.hostname")
-      ('name-server-uri "RingNS.uri")
-      (_ #f)))
+      ('name-server-uri "RingNS.uri")))
 
-  (filter-map (lambda (field)
-                (and-let* ((name (field-name->account-detail
+  (define jami-account-transducer
+    (compose (tremove empty-serializer?)
+             (tfilter-maybe-value jami-account-object)
+             (tmap (lambda (field)
+                     (let* ((name (field-name->account-detail
                                   (configuration-field-name field)))
-                           (value ((configuration-field-serializer field)
-                                   name ((configuration-field-getter field)
-                                         jami-account-object)))
-                           ;; The define-maybe default serializer produces an
-                           ;; empty string for unspecified values.
-                           (value* (if (string-null? value)
-                                       #f
-                                       value)))
-                  (cons name value*)))
-              jami-account-fields))
+                            (value ((configuration-field-serializer field)
+                                    name ((configuration-field-getter field)
+                                          jami-account-object))))
+                       (cons name value))))))
+
+  (list-transduce jami-account-transducer rcons jami-account-fields))
 
 (define (jami-account-list? val)
   (and (list? val)
diff --git a/tests/services/configuration.scm b/tests/services/configuration.scm
index 8ad5907f37..40a4e74b4d 100644
--- a/tests/services/configuration.scm
+++ b/tests/services/configuration.scm
@@ -337,13 +337,9 @@ (define-maybe symbol)
 (define-configuration config-with-maybe-symbol
   (protocol maybe-symbol ""))
 
-;;; Maybe symbol values are currently seen as serializable, because the
-;;; unspecified value is '%unset-marker%, which is a symbol itself.
-;;; TODO: Remove expected fail marker after resolution.
-(test-expect-fail 1)
 (test-equal "symbol maybe value serialization, unspecified"
   ""
-  (gexp->approximate-sexp
+  (eval-gexp
    (serialize-configuration (config-with-maybe-symbol)
                             config-with-maybe-symbol-fields)))
 
-- 
2.39.2





Information forwarded to guix-patches@HIDDEN:
bug#63985; Package guix-patches. Full text available.

Message received at 63985 <at> debbugs.gnu.org:


Received: (at 63985) by debbugs.gnu.org; 26 Jun 2023 21:57:50 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Jun 26 17:57:50 2023
Received: from localhost ([127.0.0.1]:47165 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1qDuDV-0008KM-PW
	for submit <at> debbugs.gnu.org; Mon, 26 Jun 2023 17:57:50 -0400
Received: from smtpmciv5.myservices.hosting ([185.26.107.241]:56080)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <mirai@HIDDEN>) id 1qDuDT-0008KD-Rd
 for 63985 <at> debbugs.gnu.org; Mon, 26 Jun 2023 17:57:48 -0400
Received: from mail1.netim.hosting (unknown [185.26.106.173])
 by smtpmciv5.myservices.hosting (Postfix) with ESMTP id D736220E26
 for <63985 <at> debbugs.gnu.org>; Mon, 26 Jun 2023 23:57:45 +0200 (CEST)
Received: from localhost (localhost [127.0.0.1])
 by mail1.netim.hosting (Postfix) with ESMTP id 465248009A;
 Mon, 26 Jun 2023 23:57:45 +0200 (CEST)
X-Virus-Scanned: Debian amavisd-new at mail1.netim.hosting
Received: from mail1.netim.hosting ([127.0.0.1])
 by localhost (mail1-2.netim.hosting [127.0.0.1]) (amavisd-new, port 10026)
 with ESMTP id e-gX9WqmQxnj; Mon, 26 Jun 2023 23:57:44 +0200 (CEST)
Received: from guix-nuc.home.arpa (unknown [10.192.1.83])
 (Authenticated sender: lumen@HIDDEN)
 by mail1.netim.hosting (Postfix) with ESMTPSA id 9B64680099;
 Mon, 26 Jun 2023 23:57:44 +0200 (CEST)
From: Bruno Victal <mirai@HIDDEN>
To: 63985 <at> debbugs.gnu.org
Subject: [PATCH v3 00/11] Service subsystem improvements
Date: Mon, 26 Jun 2023 22:57:27 +0100
Message-Id: <cover.1687816304.git.mirai@HIDDEN>
X-Mailer: git-send-email 2.39.2
In-Reply-To: <cover.1686343642.git.mirai@HIDDEN>
References: <cover.1686343642.git.mirai@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
X-Debbugs-CC: liliana.prikler@HIDDEN, maxim.cournoyer@HIDDEN,
 ludo@HIDDEN
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 63985
Cc: Bruno Victal <mirai@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

This patch-series is an agglomeration of smaller but weakly-related
patch-series, done so in order to build up the case for the changes.
I structured the series in order to make it suitable for cherry-picking.


Summary of changes:

* Plumbing changes to serialize-configuration

By orienting it around SRFI-171 transducers, it's now easier
to build custom configuration serializing procedures.

* New define-configuration syntax: serializer-options

Serializers may now accept more than two arguments.

* New module (gnu services configuration generic-ini)

* Deduplicate often used predicates.

* network-manager-service-type cleanup & new fields.



Notable changes since v2:

* Documentation changes

The documentation for define-configuration was reworded to make later
syntax extensions easier to document.
In addition, the new 'serializer-options' is now documented.


* (gnu services configuration) changes

** New predicates.

Reduce code duplication by migrating some commonly used predicates into
this module.


* generic-ini changes

** Initial field testing

Some deficiencies were found & corrected while doing a first field
testing when network-manager-service-type was refactored to make use
of this module.

** generic-ini- serializers

** Handling of multiple entries

Implemented as a transducer, this is useful to deal with escape-hatch
fields.


* network-manager-service-type changes

** Use define-configuration for <network-manager-configuration>

** Refactored serialization process to use the new generic-ini module

** New configuration fields: log-configuration and extra-options

Provides an escape hatch for options not yet implemented in the
record type.

** Renamed fields: 'network-manager' to 'package'

Naming the field 'package' is more informative & less confusing than a
reduplication of the package-name with the field-name itself.



Omissions in generic-ini:

For now, I've omitted:
* Custom leading (presumed to be whitespace) characters for entries
  à la gitconfig, mostly beautifying purposes
* Configurable delimiter (\n, \r\n, \0, ...)
* Configurable Key-value separator (this is usually =)

These can be implemented later if required.



Notes:

The interface in (gnu services configuration generic-ini) is still in its
infancy and might require further adjustments/additions and I'm still
thinking about its potential generalizations to TOML & co.
For the time being I'd prefer not to promise any interface stability.



Nice to haves:

I didn't have much luck in replacing the memq approach in the predicate
with define-enumeration:

--8<---------------cut here---------------start------------->8---
;; This works.
(define (network-manager-log-level? x)
  (memq x '(off err warn info debug trace)))

;; This does not.
(define-enumeration network-manager-log-level?
  (off err warn info debug trace)
  network-manager-log-level-set)

;; While executing meta-command:
;; ERROR:
;;   1. &origin: "network-manager-log-level?"
;;   2. &message: "not a member of the set"
;;   3. &syntax:
;;      form: #f
;;      subform: #f
--8<---------------cut here---------------end--------------->8---

Would be nice to know what went wrong and whether an enumeration could
be used here instead.


Bruno Victal (11):
  services: configuration: Simplify normalize-extra-args.
  services: configuration: Use transducers within
    serialize-configuration.
  services: fstrim-service-type: Serialize with SRFI-171 transducers.
  doc: Rewrite define-configuration.
  services: configuration: Add serializer-options field.
  services: configuration: New generic-ini module.
  services: configuration: Add some commonly used predicates.
  services: NetworkManager: Use define-configuration and generic-ini.
  services: NetworkManager: Prefer package over network-manager.
  services: NetworkManager: add log-configuration field.
  services: NetworkManager: Add extra-options field.

 Makefile.am                                  |   1 +
 doc/guix.texi                                | 161 +++++----
 gnu/local.mk                                 |   1 +
 gnu/services/audio.scm                       |   7 +-
 gnu/services/configuration.scm               | 108 ++++--
 gnu/services/configuration/generic-ini.scm   | 165 +++++++++
 gnu/services/linux.scm                       |  11 +-
 gnu/services/networking.scm                  | 352 ++++++++++++++-----
 gnu/services/telephony.scm                   |  49 ++-
 tests/services/configuration.scm             |  88 ++++-
 tests/services/configuration/generic-ini.scm | 129 +++++++
 11 files changed, 861 insertions(+), 211 deletions(-)
 create mode 100644 gnu/services/configuration/generic-ini.scm
 create mode 100644 tests/services/configuration/generic-ini.scm


base-commit: ac86174e22fcd762893bd4515786b1376af9397b
-- 
2.39.2





Information forwarded to liliana.prikler@HIDDEN, maxim.cournoyer@HIDDEN, ludo@HIDDEN, guix-patches@HIDDEN:
bug#63985; Package guix-patches. Full text available.

Message received at 63985 <at> debbugs.gnu.org:


Received: (at 63985) by debbugs.gnu.org; 10 Jun 2023 20:17:07 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Jun 10 16:17:07 2023
Received: from localhost ([127.0.0.1]:36384 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1q851G-0006yJ-Si
	for submit <at> debbugs.gnu.org; Sat, 10 Jun 2023 16:17:07 -0400
Received: from smtpm3.myservices.hosting ([185.26.105.234]:57996)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <mirai@HIDDEN>) id 1q851C-0006xe-E3
 for 63985 <at> debbugs.gnu.org; Sat, 10 Jun 2023 16:17:04 -0400
Received: from mail1.netim.hosting (unknown [185.26.106.173])
 by smtpm3.myservices.hosting (Postfix) with ESMTP id C0C96210D0
 for <63985 <at> debbugs.gnu.org>; Sat, 10 Jun 2023 22:17:01 +0200 (CEST)
Received: from localhost (localhost [127.0.0.1])
 by mail1.netim.hosting (Postfix) with ESMTP id CF18D8009C;
 Sat, 10 Jun 2023 22:11:43 +0200 (CEST)
X-Virus-Scanned: Debian amavisd-new at mail1.netim.hosting
Received: from mail1.netim.hosting ([127.0.0.1])
 by localhost (mail1-2.netim.hosting [127.0.0.1]) (amavisd-new, port 10026)
 with ESMTP id fIACzOTXktnh; Sat, 10 Jun 2023 22:11:43 +0200 (CEST)
Received: from guix-nuc.home.arpa (unknown [10.192.1.83])
 (Authenticated sender: lumen@HIDDEN)
 by mail1.netim.hosting (Postfix) with ESMTPSA id 160B68009B;
 Sat, 10 Jun 2023 22:11:43 +0200 (CEST)
From: Bruno Victal <mirai@HIDDEN>
To: 63985 <at> debbugs.gnu.org
Subject: [PATCH RFC v2 5/5] services: configuration: New generic-ini module.
Date: Sat, 10 Jun 2023 21:10:56 +0100
Message-Id: <59632edef13e9ed3f922e67142a6288e995c5bef.1686427611.git.mirai@HIDDEN>
X-Mailer: git-send-email 2.39.2
In-Reply-To: <cover.1686343642.git.mirai@HIDDEN>
References: <cover.1686343642.git.mirai@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 63985
Cc: Bruno Victal <mirai@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Implements a ‘serialize-ini-configuration’ procedure for serializing
record-types defined with define-configuration into generic INI files.

* gnu/services/configuration/generic-ini.scm: New module.
* tests/services/configuration/generic-ini.scm: Add tests for new module.
* Makefile.am: Register tests.
* gnu/local.mk: Register module.
---
 Makefile.am                                  |   1 +
 gnu/local.mk                                 |   1 +
 gnu/services/configuration/generic-ini.scm   | 129 +++++++++++++++++++
 tests/services/configuration/generic-ini.scm | 103 +++++++++++++++
 4 files changed, 234 insertions(+)
 create mode 100644 gnu/services/configuration/generic-ini.scm
 create mode 100644 tests/services/configuration/generic-ini.scm

diff --git a/Makefile.am b/Makefile.am
index ab901df757..8dc9a3438b 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -552,6 +552,7 @@ SCM_TESTS =					\
   tests/services.scm				\
   tests/services/file-sharing.scm		\
   tests/services/configuration.scm		\
+  tests/services/configuration/generic-ini.scm	\
   tests/services/lightdm.scm			\
   tests/services/linux.scm			\
   tests/services/telephony.scm			\
diff --git a/gnu/local.mk b/gnu/local.mk
index ce16d37e2b..a05d70aff3 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -670,6 +670,7 @@ GNU_SYSTEM_MODULES =				\
   %D%/services/cgit.scm			\
   %D%/services/ci.scm				\
   %D%/services/configuration.scm		\
+  %D%/services/configuration/generic-ini.scm	\
   %D%/services/cuirass.scm			\
   %D%/services/cups.scm				\
   %D%/services/databases.scm			\
diff --git a/gnu/services/configuration/generic-ini.scm b/gnu/services/configuration/generic-ini.scm
new file mode 100644
index 0000000000..88d145bc50
--- /dev/null
+++ b/gnu/services/configuration/generic-ini.scm
@@ -0,0 +1,129 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2023 Bruno Victal <mirai@HIDDEN>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (gnu services configuration generic-ini)
+  #:use-module (gnu services configuration)
+  #:use-module (guix gexp)
+  #:use-module (srfi srfi-171)
+  #:use-module (ice-9 match)
+  #:export (ini-entry?
+            list-of-ini-entries?
+
+            serialize-ini-configuration))
+
+;;;
+;;; Generic INI serializer
+;;;
+
+
+;;;
+;;; Predicates
+;;;
+
+;; This is the same format used in SRFI-233 but without comment support.
+(define ini-entry?
+  (match-lambda
+    (((? symbol?) (? symbol?) (? string?)) #t)
+    (_ #f)))
+
+(define list-of-ini-entries?
+  (list-of ini-entry?))
+
+;;
+;; Overall design document
+;;
+;; This module implements a generic INI serializer for a record-type defined
+;; using define-configuration.
+;; It expects that the serialize-<type> procedures return a list with
+;; three elements of the form:
+;;    (list section key value)
+;; Where ‘section’ and ‘key’ are symbols and ‘value’ is a string.
+;; The fields within define-configuration do not have to be ordered in,
+;; any way whatsoever as the ‘serialize-ini’ will group them up automatically.
+;; This implies that no assumptions should be made regarding the order of the
+;; values in the serializied INI output.
+;;
+;; Additional notes:
+;; Q: Why not replace rcons with string-append and forego the ungexp-splice?
+;; A: The transduction happens outside of the G-Exp while the final string-append
+;;    takes place in the G-Exp.
+;;
+;; Debugging tips: Open a REPL and try one transducer at a time from
+;; ‘ini-transducer’.
+;;
+
+(define (add-section-header partition)
+  (let ((header (caar partition)))
+    (cons (list header)
+          partition)))
+
+(define serializer
+  (match-lambda
+    ((section)
+     #~(format #f "[~a]~%" '#$section))
+    ((section key value)
+     #~(format #f "~a=~a~%" '#$key #$value))
+    ;; Used for the newline between sections.
+    ('*section-separator* "\n")))
+
+(define ini-transducer
+  (compose (tpartition car)
+           (tmap add-section-header)
+           (tadd-between '(*section-separator*))
+           tconcatenate
+           (tmap serializer)))
+
+;; A “first-pass” serialization is performed and sorted in order
+;; to group up the fields by “section” before passing through the
+;; transducer.
+(define (serialize-ini-configuration config fields)
+  (let* ((srfi-233-IR
+          ;; First pass: “serialize” into a (disordered) list of
+          ;; SRFI-233 entries.
+          (list-transduce (base-transducer config) rcons fields))
+         (comparator (lambda (x y)
+                       ;; Sort the SRFI-233 entries by section.
+                       (string<=? (symbol->string (car x))
+                                  (symbol->string (car y)))))
+         (sorted-entries (sort srfi-233-IR comparator)))
+    #~(string-append
+       #$@(list-transduce ini-transducer rcons sorted-entries))))
+
+;; FIXME:RFC:
+;;       generic-ini- prefixed serializing procs?
+;;       (perhaps prefixed as generic-ini: ?)
+;; Example procedures:
+;;
+(define* (generic-ini-serialize-string field-name value #:key section)
+  (list section field-name value))
+
+;; field-name-transform can be used to “uglify” a field-name,
+;; e.g. want-ipv6?  ->  want_ipv6
+(define* (generic-ini-serialize-boolean field-name value #:key section
+                            (field-name-transform identity))
+  (list section (field-name-transform field-name)
+        (if value "true" "false")))
+
+
+;;; FIXME: delete this before inclusion, these are notes for the first RFC.
+;;;
+;;; Left out for now (but readily extendable):
+;;;  * Custom leading (presumed to be whitespace) characters for entries
+;;;    à la gitconfig, mostly pretty-printing purposes
+;;;  * Configurable delimiter (\n, \r\n, \0, ...)
+;;;  * Configurable Key-value separator (this is usually =)
diff --git a/tests/services/configuration/generic-ini.scm b/tests/services/configuration/generic-ini.scm
new file mode 100644
index 0000000000..3bdf0e12c2
--- /dev/null
+++ b/tests/services/configuration/generic-ini.scm
@@ -0,0 +1,103 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2023 Bruno Victal <mirai@HIDDEN>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (tests services configuration generic-ini)
+  #:use-module (gnu services configuration)
+  #:use-module (gnu services configuration generic-ini)
+  #:use-module (guix diagnostics)
+  #:use-module (guix gexp)
+  #:use-module (guix store)
+  #:autoload (guix i18n) (G_)
+  #:use-module (srfi srfi-34)
+  #:use-module (srfi srfi-64)
+  #:use-module (srfi srfi-71))
+
+;;; Tests for the (gnu services configuration generic-ini) module.
+
+(test-begin "generic-ini serializer")
+
+
+(define expected-output "\
+[ranch]
+shepherd=Emma
+
+[shed]
+enabled=true
+capacity=50
+production=wool
+")
+
+
+;;;
+;;; Serializers
+;;;
+(define (strip-trailing-?-character field-name)
+  "Drop rightmost '?' character"
+  (let ((str (symbol->string field-name)))
+    (if (string-suffix? "?" str)
+        (string->symbol (string-drop-right str 1))
+        field-name)))
+
+(define* (serialize-string field-name value #:key section)
+  (list section field-name value))
+
+(define* (serialize-number field-name value #:key section)
+  (list section field-name (number->string value)))
+
+(define* (serialize-boolean field-name value #:key section)
+  (list section (strip-trailing-?-character field-name)
+        (if value "true" "false")))
+
+
+;;;
+;;; Record-type definition
+;;;
+
+(define-configuration foo-configuration
+  (production
+   (string "wool")
+   "Lorem Ipsum …"
+   (serializer-options '(#:section shed)))
+
+  (capacity
+   (number 50)
+   "Lorem Ipsum …"
+   (serializer-options '(#:section shed)))
+
+  (enabled?
+   (boolean #t)
+   "Lorem Ipsum …"
+   (serializer-options '(#:section shed)))
+
+  (shepherd
+   (string "Emma")
+   "Lorem Ipsum …"
+   (serializer-options '(#:section ranch))))
+
+(test-equal "Well-formed INI output from serialize-ini"
+  expected-output
+  ;; Serialize the above into a string, properly resolving any potential
+  ;; nested G-Exps as well.
+  (let* ((serialized-ini
+          (serialize-ini-configuration (foo-configuration)
+                                       foo-configuration-fields))
+         (lowered conn (with-store store
+                         ((lower-gexp serialized-ini) store))))
+    (eval (lowered-gexp-sexp lowered) (current-module))))
+
+(test-end)
-- 
2.39.2





Information forwarded to guix-patches@HIDDEN:
bug#63985; Package guix-patches. Full text available.

Message received at 63985 <at> debbugs.gnu.org:


Received: (at 63985) by debbugs.gnu.org; 10 Jun 2023 20:17:03 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Jun 10 16:17:02 2023
Received: from localhost ([127.0.0.1]:36380 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1q851B-0006xT-Ro
	for submit <at> debbugs.gnu.org; Sat, 10 Jun 2023 16:17:02 -0400
Received: from smtpmciv5.myservices.hosting ([185.26.107.241]:50460)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <mirai@HIDDEN>) id 1q8519-0006xB-Ar
 for 63985 <at> debbugs.gnu.org; Sat, 10 Jun 2023 16:17:00 -0400
Received: from mail1.netim.hosting (unknown [185.26.106.173])
 by smtpmciv5.myservices.hosting (Postfix) with ESMTP id B499F20DD3
 for <63985 <at> debbugs.gnu.org>; Sat, 10 Jun 2023 22:16:58 +0200 (CEST)
Received: from localhost (localhost [127.0.0.1])
 by mail1.netim.hosting (Postfix) with ESMTP id 4BAF58009A;
 Sat, 10 Jun 2023 22:11:33 +0200 (CEST)
X-Virus-Scanned: Debian amavisd-new at mail1.netim.hosting
Received: from mail1.netim.hosting ([127.0.0.1])
 by localhost (mail1-2.netim.hosting [127.0.0.1]) (amavisd-new, port 10026)
 with ESMTP id E1PIExsNQxch; Sat, 10 Jun 2023 22:11:32 +0200 (CEST)
Received: from guix-nuc.home.arpa (unknown [10.192.1.83])
 (Authenticated sender: lumen@HIDDEN)
 by mail1.netim.hosting (Postfix) with ESMTPSA id B881380098;
 Sat, 10 Jun 2023 22:11:32 +0200 (CEST)
From: Bruno Victal <mirai@HIDDEN>
To: 63985 <at> debbugs.gnu.org
Subject: [PATCH RFC v2 4/5] services: configuration: Add serializer-options
 field.
Date: Sat, 10 Jun 2023 21:10:55 +0100
Message-Id: <38055b82cfb09cbadfb6eb06f45953fb4303846b.1686427611.git.mirai@HIDDEN>
X-Mailer: git-send-email 2.39.2
In-Reply-To: <cover.1686343642.git.mirai@HIDDEN>
References: <cover.1686343642.git.mirai@HIDDEN>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 63985
Cc: Bruno Victal <mirai@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Allow relaying additional arguments to a serialize-<type> procedure.

* gnu/services/configuration.scm (configuration-field)
<serializer-options>: New field.
(base-transducer, define-maybe-helper): Adjust to relay additional arguments.
(normalize-extra-args): Implement serializer-options literal.

* tests/services/configuration.scm: Add tests for serializer-options.
---
 gnu/services/configuration.scm   | 49 +++++++++++++++++++++-----------
 tests/services/configuration.scm | 34 ++++++++++++++++++++++
 2 files changed, 67 insertions(+), 16 deletions(-)

diff --git a/gnu/services/configuration.scm b/gnu/services/configuration.scm
index cd2cb8318b..4eee5a26c2 100644
--- a/gnu/services/configuration.scm
+++ b/gnu/services/configuration.scm
@@ -50,6 +50,7 @@ (define-module (gnu services configuration)
             configuration-field-error
             configuration-field-sanitizer
             configuration-field-serializer
+            configuration-field-serializer-options
             configuration-field-getter
             configuration-field-default-value-thunk
             configuration-field-documentation
@@ -127,6 +128,7 @@ (define-record-type* <configuration-field>
   (predicate configuration-field-predicate)
   (sanitizer configuration-field-sanitizer)
   (serializer configuration-field-serializer)
+  (serializer-options configuration-field-serializer-options)
   (default-value-thunk configuration-field-default-value-thunk)
   (documentation configuration-field-documentation))
 
@@ -144,9 +146,13 @@ (define (base-transducer config)
            ;; Only serialize fields whose value isn't '%unset-marker%.
            (tfilter-maybe-value config)
            (tmap (lambda (field)
-                   ((configuration-field-serializer field)
-                    (configuration-field-name field)
-                    ((configuration-field-getter field) config))))))
+                   (let ((serializer (configuration-field-serializer field))
+                         (field-name (configuration-field-name field))
+                         (value
+                          ((configuration-field-getter field) config))
+                         (serializer-options
+                          (configuration-field-serializer-options field)))
+                     (apply serializer field-name value serializer-options))))))
 
 (define (serialize-configuration config fields)
   #~(string-append
@@ -173,10 +179,9 @@ (define (define-maybe-helper serialize? prefix syn)
              (or (not (maybe-value-set? val))
                  (stem? val)))
            #,@(if serialize?
-                  (list #'(define (serialize-maybe-stem field-name val)
-                            (if (stem? val)
-                                (serialize-stem field-name val)
-                                "")))
+                  (list #'(define (serialize-maybe-stem field-name val . rest)
+                            (when (maybe-value-set? val)
+                              (apply serialize-stem field-name val rest))))
                   '()))))))
 
 (define-syntax define-maybe
@@ -210,38 +215,49 @@ (define (define-configuration-helper serialize? serializer-prefix syn)
     "Extract and normalize arguments following @var{doc}."
     (let loop ((s s)
                (sanitizer* #f)
-               (serializer* #f))
-      (syntax-case s (sanitizer serializer empty-serializer)
+               (serializer* #f)
+               (serializer-options* #f))
+      (syntax-case s (sanitizer serializer empty-serializer serializer-options)
         (((sanitizer proc) tail ...)
          (if sanitizer*
              (syntax-violation 'sanitizer
                                "duplicate entry" #'proc)
-             (loop #'(tail ...) #'proc serializer*)))
+             (loop #'(tail ...)
+                   #'proc serializer* serializer-options*)))
         (((serializer proc) tail ...)
          (if serializer*
              (syntax-violation 'serializer
                                "duplicate or conflicting entry" #'proc)
-             (loop #'(tail ...) sanitizer* #'proc)))
+             (loop #'(tail ...)
+                   sanitizer* #'proc serializer-options*)))
         ((empty-serializer tail ...)
          (if serializer*
              (syntax-violation 'empty-serializer
                                "duplicate or conflicting entry" #f)
-             (loop #'(tail ...) sanitizer* #'empty-serializer)))
+             (loop #'(tail ...)
+                   sanitizer* #'empty-serializer #f)))
+        (((serializer-options args) tail ...)
+         (if serializer-options*
+             (syntax-violation 'serializer-options
+                               "duplicate or conflicting entry" #f)
+             (loop #'(tail ...)
+                   sanitizer* serializer* #'args)))
         (()  ; stop condition
-         (values (list sanitizer* serializer*)))
+         (values (list sanitizer* serializer*
+                       (or serializer-options* #'(quote ())))))
         ((proc)  ; TODO: deprecated, to be removed.
-         (every not (list sanitizer* serializer*))
+         (every not (list sanitizer* serializer* serializer-options*))
          (begin
            (warning #f (G_ "specifying serializers after documentation is \
 deprecated, use (serializer ~a) instead~%") (syntax->datum #'proc))
-           (values (list #f #'proc)))))))
+           (values (list #f #'proc #'(quote ()))))))))
 
   (syntax-case syn ()
     ((_ stem (field field-type+def doc extra-args ...) ...)
      (with-syntax
          ((((field-type def) ...)
            (map normalize-field-type+def #'(field-type+def ...)))
-          (((sanitizer* serializer*) ...)
+          (((sanitizer* serializer* serializer-options*) ...)
            (map normalize-extra-args #'((extra-args ...) ...))))
        (with-syntax
            (((field-getter ...)
@@ -327,6 +343,7 @@ (define (define-configuration-helper serialize? serializer-prefix syn)
                        (or field-sanitizer
                            (id #'stem #'validate- #'stem #'- #'field)))
                       (serializer field-serializer)
+                      (serializer-options serializer-options*)
                       (default-value-thunk
                         (lambda ()
                           (if (maybe-value-set? (syntax->datum field-default))
diff --git a/tests/services/configuration.scm b/tests/services/configuration.scm
index 1db83bb273..d23a0cde89 100644
--- a/tests/services/configuration.scm
+++ b/tests/services/configuration.scm
@@ -297,6 +297,40 @@ (define (sanitize-port value)
                     (lambda _ "lorem")
                     (sanitizer (lambda () #t)))))))
 
+(test-group "Serializer keyword arguments"
+  (define* (serialize-port field value #:key host)
+    (format #f "host=~a,port=~d" host value))
+
+  (define-configuration kwarg-config
+    (port
+     (port 80)
+     "Lorem Ipsum."
+     (serializer-options '(#:host "[2001:db8::1]"))))
+
+  (test-equal "keyword argument provided"
+    "host=[2001:db8::1],port=80"
+    (eval-gexp
+     (serialize-configuration (kwarg-config)
+                              kwarg-config-fields))))
+
+(test-group "Serializer keyword arguments, define-maybe"
+  (define* (serialize-port field value #:key host)
+    (format #f "host=~a,port=~d" host value))
+
+  (define-maybe port)
+
+  (define-configuration kwarg-config
+    (port
+     (maybe-port 80)
+     "Lorem Ipsum."
+     (serializer-options '(#:host "[2001:db8::1]"))))
+
+  (test-equal "keyword argument provided, maybe type"
+    "host=[2001:db8::1],port=80"
+    (eval-gexp
+     (serialize-configuration (kwarg-config)
+                              kwarg-config-fields))))
+
 
 ;;;
 ;;; define-maybe macro.
-- 
2.39.2





Information forwarded to guix-patches@HIDDEN:
bug#63985; Package guix-patches. Full text available.

Message received at 63985 <at> debbugs.gnu.org:


Received: (at 63985) by debbugs.gnu.org; 10 Jun 2023 20:17:02 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Jun 10 16:17:01 2023
Received: from localhost ([127.0.0.1]:36378 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1q851B-0006xR-Bc
	for submit <at> debbugs.gnu.org; Sat, 10 Jun 2023 16:17:01 -0400
Received: from smtpm1.myservices.hosting ([185.26.105.232]:58258)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <mirai@HIDDEN>) id 1q8519-0006xA-5V
 for 63985 <at> debbugs.gnu.org; Sat, 10 Jun 2023 16:16:59 -0400
Received: from mail1.netim.hosting (unknown [185.26.106.173])
 by smtpm1.myservices.hosting (Postfix) with ESMTP id B3D1220A4A
 for <63985 <at> debbugs.gnu.org>; Sat, 10 Jun 2023 22:16:58 +0200 (CEST)
Received: from localhost (localhost [127.0.0.1])
 by mail1.netim.hosting (Postfix) with ESMTP id 0111480097;
 Sat, 10 Jun 2023 22:11:18 +0200 (CEST)
X-Virus-Scanned: Debian amavisd-new at mail1.netim.hosting
Received: from mail1.netim.hosting ([127.0.0.1])
 by localhost (mail1-2.netim.hosting [127.0.0.1]) (amavisd-new, port 10026)
 with ESMTP id z3ZtGnCiAB1i; Sat, 10 Jun 2023 22:11:17 +0200 (CEST)
Received: from guix-nuc.home.arpa (unknown [10.192.1.83])
 (Authenticated sender: lumen@HIDDEN)
 by mail1.netim.hosting (Postfix) with ESMTPSA id 7839780060;
 Sat, 10 Jun 2023 22:11:17 +0200 (CEST)
From: Bruno Victal <mirai@HIDDEN>
To: 63985 <at> debbugs.gnu.org
Subject: [PATCH RFC v2 2/5] services: configuration: Use transducers within
 serialize-configuration.
Date: Sat, 10 Jun 2023 21:10:53 +0100
Message-Id: <b378f1e2a5c9b8d642b8ebb3af5d3f55d2fb7974.1686427611.git.mirai@HIDDEN>
X-Mailer: git-send-email 2.39.2
In-Reply-To: <cover.1686343642.git.mirai@HIDDEN>
References: <cover.1686343642.git.mirai@HIDDEN>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 63985
Cc: Bruno Victal <mirai@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Introduces 'base-transducer', a SRFI-171 based transducer that can be used as a
starting point for writing custom configuration record serializing procedures.

This also fixes the symbol maybe-value serialization test case.

* gnu/services/configuration.scm (empty-serializer?): New predicate.
(base-transducer, tfilter-maybe-value): New procedure.
(serialize-configuration): Adapt to use base-transducer.

* gnu/services/telephony.scm (jami-account->alist): Use transducers to skip
fields that are unserializable or whose field maybe-value is unset.

* tests/services/configuration.scm: Remove test-expect-fail.
---
 gnu/services/configuration.scm   | 29 ++++++++++++++++++++++++-----
 gnu/services/telephony.scm       | 27 +++++++++++++--------------
 tests/services/configuration.scm |  4 ----
 3 files changed, 37 insertions(+), 23 deletions(-)

diff --git a/gnu/services/configuration.scm b/gnu/services/configuration.scm
index dafe72f4fe..cd2cb8318b 100644
--- a/gnu/services/configuration.scm
+++ b/gnu/services/configuration.scm
@@ -42,6 +42,7 @@ (define-module (gnu services configuration)
   #:use-module (srfi srfi-26)
   #:use-module (srfi srfi-34)
   #:use-module (srfi srfi-35)
+  #:use-module (srfi srfi-171)
   #:export (configuration-field
             configuration-field-name
             configuration-field-type
@@ -59,6 +60,10 @@ (define-module (gnu services configuration)
             define-configuration/no-serialization
             no-serialization
 
+            empty-serializer?
+            tfilter-maybe-value
+            base-transducer
+
             serialize-configuration
             define-maybe
             define-maybe/no-serialization
@@ -125,13 +130,27 @@ (define-record-type* <configuration-field>
   (default-value-thunk configuration-field-default-value-thunk)
   (documentation configuration-field-documentation))
 
+(define (empty-serializer? field)
+  (eq? empty-serializer
+       (configuration-field-serializer field)))
+
+(define (tfilter-maybe-value config)
+  (tfilter (lambda (field)
+             (let ((field-value ((configuration-field-getter field) config)))
+               (maybe-value-set? field-value)))))
+
+(define (base-transducer config)
+  (compose (tremove empty-serializer?)
+           ;; Only serialize fields whose value isn't '%unset-marker%.
+           (tfilter-maybe-value config)
+           (tmap (lambda (field)
+                   ((configuration-field-serializer field)
+                    (configuration-field-name field)
+                    ((configuration-field-getter field) config))))))
+
 (define (serialize-configuration config fields)
   #~(string-append
-     #$@(map (lambda (field)
-               ((configuration-field-serializer field)
-                (configuration-field-name field)
-                ((configuration-field-getter field) config)))
-             fields)))
+     #$@(list-transduce (base-transducer config) rcons fields)))
 
 (define-syntax-rule (id ctx parts ...)
   "Assemble PARTS into a raw (unhygienic) identifier."
diff --git a/gnu/services/telephony.scm b/gnu/services/telephony.scm
index 23ccb8d403..56b7772f58 100644
--- a/gnu/services/telephony.scm
+++ b/gnu/services/telephony.scm
@@ -37,6 +37,7 @@ (define-module (gnu services telephony)
   #:use-module (srfi srfi-1)
   #:use-module (srfi srfi-2)
   #:use-module (srfi srfi-26)
+  #:use-module (srfi srfi-171)
   #:use-module (ice-9 format)
   #:use-module (ice-9 match)
   #:export (jami-account
@@ -204,22 +205,20 @@ (define (jami-account->alist jami-account-object)
       ('rendezvous-point? "Account.rendezVous")
       ('peer-discovery? "Account.peerDiscovery")
       ('bootstrap-hostnames "Account.hostname")
-      ('name-server-uri "RingNS.uri")
-      (_ #f)))
+      ('name-server-uri "RingNS.uri")))
 
-  (filter-map (lambda (field)
-                (and-let* ((name (field-name->account-detail
+  (define jami-account-transducer
+    (compose (tremove empty-serializer?)
+             (tfilter-maybe-value jami-account-object)
+             (tmap (lambda (field)
+                     (let* ((name (field-name->account-detail
                                   (configuration-field-name field)))
-                           (value ((configuration-field-serializer field)
-                                   name ((configuration-field-getter field)
-                                         jami-account-object)))
-                           ;; The define-maybe default serializer produces an
-                           ;; empty string for unspecified values.
-                           (value* (if (string-null? value)
-                                       #f
-                                       value)))
-                  (cons name value*)))
-              jami-account-fields))
+                            (value ((configuration-field-serializer field)
+                                    name ((configuration-field-getter field)
+                                          jami-account-object))))
+                       (cons name value))))))
+
+  (list-transduce jami-account-transducer rcons jami-account-fields))
 
 (define (jami-account-list? val)
   (and (list? val)
diff --git a/tests/services/configuration.scm b/tests/services/configuration.scm
index 8ad5907f37..1db83bb273 100644
--- a/tests/services/configuration.scm
+++ b/tests/services/configuration.scm
@@ -337,10 +337,6 @@ (define-maybe symbol)
 (define-configuration config-with-maybe-symbol
   (protocol maybe-symbol ""))
 
-;;; Maybe symbol values are currently seen as serializable, because the
-;;; unspecified value is '%unset-marker%, which is a symbol itself.
-;;; TODO: Remove expected fail marker after resolution.
-(test-expect-fail 1)
 (test-equal "symbol maybe value serialization, unspecified"
   ""
   (gexp->approximate-sexp
-- 
2.39.2





Information forwarded to guix-patches@HIDDEN:
bug#63985; Package guix-patches. Full text available.

Message received at 63985 <at> debbugs.gnu.org:


Received: (at 63985) by debbugs.gnu.org; 10 Jun 2023 20:11:32 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Jun 10 16:11:31 2023
Received: from localhost ([127.0.0.1]:36372 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1q84vr-0006oP-Kg
	for submit <at> debbugs.gnu.org; Sat, 10 Jun 2023 16:11:31 -0400
Received: from smtpm1.myservices.hosting ([185.26.105.232]:57240)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <mirai@HIDDEN>) id 1q84vq-0006oG-3b
 for 63985 <at> debbugs.gnu.org; Sat, 10 Jun 2023 16:11:30 -0400
Received: from mail1.netim.hosting (unknown [185.26.106.173])
 by smtpm1.myservices.hosting (Postfix) with ESMTP id 5AB9D20A4A
 for <63985 <at> debbugs.gnu.org>; Sat, 10 Jun 2023 22:11:28 +0200 (CEST)
Received: from localhost (localhost [127.0.0.1])
 by mail1.netim.hosting (Postfix) with ESMTP id 8061A8009A;
 Sat, 10 Jun 2023 22:11:25 +0200 (CEST)
X-Virus-Scanned: Debian amavisd-new at mail1.netim.hosting
Received: from mail1.netim.hosting ([127.0.0.1])
 by localhost (mail1-2.netim.hosting [127.0.0.1]) (amavisd-new, port 10026)
 with ESMTP id gXkSwGsEGjMm; Sat, 10 Jun 2023 22:11:25 +0200 (CEST)
Received: from guix-nuc.home.arpa (unknown [10.192.1.83])
 (Authenticated sender: lumen@HIDDEN)
 by mail1.netim.hosting (Postfix) with ESMTPSA id 10A2380098;
 Sat, 10 Jun 2023 22:11:25 +0200 (CEST)
From: Bruno Victal <mirai@HIDDEN>
To: 63985 <at> debbugs.gnu.org
Subject: [PATCH RFC v2 3/5] services: fstrim-service-type: Serialize with
 SRFI-171 transducers.
Date: Sat, 10 Jun 2023 21:10:54 +0100
Message-Id: <bc2dc7ef8feba0432d54313e324bc2aa0e54bbdb.1686427611.git.mirai@HIDDEN>
X-Mailer: git-send-email 2.39.2
In-Reply-To: <cover.1686343642.git.mirai@HIDDEN>
References: <cover.1686343642.git.mirai@HIDDEN>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 63985
Cc: Bruno Victal <mirai@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

* gnu/services/linux.scm (serialize-fstrim-configuration): Refactor to use
base-transducer.
---
 gnu/services/linux.scm | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/gnu/services/linux.scm b/gnu/services/linux.scm
index d105c42850..3cfa6d6855 100644
--- a/gnu/services/linux.scm
+++ b/gnu/services/linux.scm
@@ -40,6 +40,7 @@ (define-module (gnu services linux)
   #:use-module (srfi srfi-26)
   #:use-module (srfi srfi-34)
   #:use-module (srfi srfi-35)
+  #:use-module (srfi srfi-171)
   #:use-module (ice-9 format)
   #:use-module (ice-9 match)
   #:export (earlyoom-configuration
@@ -227,13 +228,9 @@ (define-configuration fstrim-configuration
   (prefix fstrim-))
 
 (define (serialize-fstrim-configuration config)
-  (concatenate
-   (filter list?
-           (map (lambda (field)
-                  ((configuration-field-serializer field)
-                   (configuration-field-name field)
-                   ((configuration-field-getter field) config)))
-                fstrim-configuration-fields))))
+  (list-transduce (compose (base-transducer config) tconcatenate)
+                  rcons
+                  fstrim-configuration-fields))
 
 (define (fstrim-mcron-job config)
   (match-record config <fstrim-configuration> (package schedule)
-- 
2.39.2





Information forwarded to guix-patches@HIDDEN:
bug#63985; Package guix-patches. Full text available.

Message received at 63985 <at> debbugs.gnu.org:


Received: (at 63985) by debbugs.gnu.org; 10 Jun 2023 20:11:16 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Jun 10 16:11:16 2023
Received: from localhost ([127.0.0.1]:36369 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1q84vc-0006ns-4O
	for submit <at> debbugs.gnu.org; Sat, 10 Jun 2023 16:11:16 -0400
Received: from smtpm4.myservices.hosting ([185.26.105.235]:38800)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <mirai@HIDDEN>) id 1q84vY-0006nh-Ew
 for 63985 <at> debbugs.gnu.org; Sat, 10 Jun 2023 16:11:15 -0400
Received: from mail1.netim.hosting (unknown [185.26.106.173])
 by smtpm4.myservices.hosting (Postfix) with ESMTP id 367DF20D88
 for <63985 <at> debbugs.gnu.org>; Sat, 10 Jun 2023 22:11:10 +0200 (CEST)
Received: from localhost (localhost [127.0.0.1])
 by mail1.netim.hosting (Postfix) with ESMTP id 6654180097;
 Sat, 10 Jun 2023 22:11:10 +0200 (CEST)
X-Virus-Scanned: Debian amavisd-new at mail1.netim.hosting
Received: from mail1.netim.hosting ([127.0.0.1])
 by localhost (mail1-2.netim.hosting [127.0.0.1]) (amavisd-new, port 10026)
 with ESMTP id HWA0I_4yl2JV; Sat, 10 Jun 2023 22:11:10 +0200 (CEST)
Received: from guix-nuc.home.arpa (unknown [10.192.1.83])
 (Authenticated sender: lumen@HIDDEN)
 by mail1.netim.hosting (Postfix) with ESMTPSA id E2C0A80060;
 Sat, 10 Jun 2023 22:11:09 +0200 (CEST)
From: Bruno Victal <mirai@HIDDEN>
To: 63985 <at> debbugs.gnu.org
Subject: [PATCH RFC v2 1/5] services: configuration: Simplify
 normalize-extra-args.
Date: Sat, 10 Jun 2023 21:10:52 +0100
Message-Id: <23a11829a71737c7b7041fb47ea0b8a8431a698b.1686427611.git.mirai@HIDDEN>
X-Mailer: git-send-email 2.39.2
In-Reply-To: <cover.1686343642.git.mirai@HIDDEN>
References: <cover.1686343642.git.mirai@HIDDEN>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 63985
Cc: Bruno Victal <mirai@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

* gnu/services/configuration.scm
(define-configuration-helper, normalize-extra-args): Use #f instead of %unset-value.
---

Notable changes since RFC v1:

* Jami service now passes tests.
* Typo fixes.
* serializer-kwargs renamed to serializer-options.
* Changed INI example to something more innocuous.

 gnu/services/configuration.scm | 26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/gnu/services/configuration.scm b/gnu/services/configuration.scm
index 367b85c1be..dafe72f4fe 100644
--- a/gnu/services/configuration.scm
+++ b/gnu/services/configuration.scm
@@ -190,32 +190,32 @@ (define (define-configuration-helper serialize? serializer-prefix syn)
   (define (normalize-extra-args s)
     "Extract and normalize arguments following @var{doc}."
     (let loop ((s s)
-               (sanitizer* %unset-value)
-               (serializer* %unset-value))
+               (sanitizer* #f)
+               (serializer* #f))
       (syntax-case s (sanitizer serializer empty-serializer)
         (((sanitizer proc) tail ...)
-         (if (maybe-value-set? sanitizer*)
-             (syntax-violation 'sanitizer "duplicate entry"
-                               #'proc)
+         (if sanitizer*
+             (syntax-violation 'sanitizer
+                               "duplicate entry" #'proc)
              (loop #'(tail ...) #'proc serializer*)))
         (((serializer proc) tail ...)
-         (if (maybe-value-set? serializer*)
-             (syntax-violation 'serializer "duplicate or conflicting entry"
-                               #'proc)
+         (if serializer*
+             (syntax-violation 'serializer
+                               "duplicate or conflicting entry" #'proc)
              (loop #'(tail ...) sanitizer* #'proc)))
         ((empty-serializer tail ...)
-         (if (maybe-value-set? serializer*)
+         (if serializer*
              (syntax-violation 'empty-serializer
                                "duplicate or conflicting entry" #f)
              (loop #'(tail ...) sanitizer* #'empty-serializer)))
         (()  ; stop condition
          (values (list sanitizer* serializer*)))
         ((proc)  ; TODO: deprecated, to be removed.
-         (null? (filter-map maybe-value-set? (list sanitizer* serializer*)))
+         (every not (list sanitizer* serializer*))
          (begin
            (warning #f (G_ "specifying serializers after documentation is \
 deprecated, use (serializer ~a) instead~%") (syntax->datum #'proc))
-           (values (list %unset-value #'proc)))))))
+           (values (list #f #'proc)))))))
 
   (syntax-case syn ()
     ((_ stem (field field-type+def doc extra-args ...) ...)
@@ -239,11 +239,11 @@ (define (define-configuration-helper serialize? serializer-prefix syn)
                      default-value))
                   #'((field-type def) ...)))
             ((field-sanitizer ...)
-             (map maybe-value #'(sanitizer* ...)))
+             #'(sanitizer* ...))
             ((field-serializer ...)
              (map (lambda (type proc)
                     (and serialize?
-                         (or (maybe-value proc)
+                         (or proc
                              (if serializer-prefix
                                  (id #'stem serializer-prefix #'serialize- type)
                                  (id #'stem #'serialize- type)))))

base-commit: 767edbb6fe781d19c19971f2ccd3b0da8fd053fc
-- 
2.39.2





Information forwarded to guix-patches@HIDDEN:
bug#63985; Package guix-patches. Full text available.

Message received at 63985 <at> debbugs.gnu.org:


Received: (at 63985) by debbugs.gnu.org; 9 Jun 2023 21:27:01 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Jun 09 17:27:01 2023
Received: from localhost ([127.0.0.1]:32895 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1q7jdM-0000d4-TJ
	for submit <at> debbugs.gnu.org; Fri, 09 Jun 2023 17:27:01 -0400
Received: from smtpmciv2.myservices.hosting ([185.26.107.238]:35328)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <mirai@HIDDEN>) id 1q7jdL-0000cv-9J
 for 63985 <at> debbugs.gnu.org; Fri, 09 Jun 2023 17:26:59 -0400
Received: from mail1.netim.hosting (unknown [185.26.106.173])
 by smtpmciv2.myservices.hosting (Postfix) with ESMTP id D261D20E2B
 for <63985 <at> debbugs.gnu.org>; Fri,  9 Jun 2023 23:26:58 +0200 (CEST)
Received: from localhost (localhost [127.0.0.1])
 by mail1.netim.hosting (Postfix) with ESMTP id 2D0538009B;
 Fri,  9 Jun 2023 23:21:28 +0200 (CEST)
X-Virus-Scanned: Debian amavisd-new at mail1.netim.hosting
Received: from mail1.netim.hosting ([127.0.0.1])
 by localhost (mail1-2.netim.hosting [127.0.0.1]) (amavisd-new, port 10026)
 with ESMTP id 95vG5acq2eRl; Fri,  9 Jun 2023 23:21:27 +0200 (CEST)
Received: from guix-nuc.home.arpa (unknown [10.192.1.83])
 (Authenticated sender: lumen@HIDDEN)
 by mail1.netim.hosting (Postfix) with ESMTPSA id 93B7C80098;
 Fri,  9 Jun 2023 23:21:27 +0200 (CEST)
From: Bruno Victal <mirai@HIDDEN>
To: 63985 <at> debbugs.gnu.org
Subject: [PATCH RFC 4/5] services: configuration: Add serializer-kwargs field.
Date: Fri,  9 Jun 2023 22:20:59 +0100
Message-Id: <0714ce739dca87c02a3fd405a449876ed72eb511.1686345627.git.mirai@HIDDEN>
X-Mailer: git-send-email 2.39.2
In-Reply-To: <cover.1686343642.git.mirai@HIDDEN>
References: <cover.1686343642.git.mirai@HIDDEN>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 63985
Cc: Bruno Victal <mirai@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Allow relaying additional arguments to a serialize-<type> procedure.

* gnu/services/configuration.scm (configuration-field)
<serializer-kwargs>: New field.
(base-transducer, define-maybe-helper): Adjust to relay additional arguments.
(normalize-extra-args): Implement serializer-kwargs literal.

* tests/services/configuration.scm: Add tests for serializer-kwargs.
---
 gnu/services/configuration.scm   | 48 +++++++++++++++++++++-----------
 tests/services/configuration.scm | 34 ++++++++++++++++++++++
 2 files changed, 66 insertions(+), 16 deletions(-)

diff --git a/gnu/services/configuration.scm b/gnu/services/configuration.scm
index 0818b48bb5..b32a5a85ba 100644
--- a/gnu/services/configuration.scm
+++ b/gnu/services/configuration.scm
@@ -124,6 +124,7 @@ (define-record-type* <configuration-field>
   (predicate configuration-field-predicate)
   (sanitizer configuration-field-sanitizer)
   (serializer configuration-field-serializer)
+  (serializer-kwargs configuration-field-serializer-kwargs)
   (default-value-thunk configuration-field-default-value-thunk)
   (documentation configuration-field-documentation))
 
@@ -139,9 +140,13 @@ (define (base-transducer config)
                                           config)))
                         (maybe-value-set? field-value))))
            (tmap (lambda (field)
-                   ((configuration-field-serializer field)
-                    (configuration-field-name field)
-                    ((configuration-field-getter field) config))))))
+                   (let ((serializer (configuration-field-serializer field))
+                         (field-name (configuration-field-name field))
+                         (value
+                          ((configuration-field-getter field) config))
+                         (serializer-kwargs
+                          (configuration-field-serializer-kwargs field)))
+                     (apply serializer field-name value serializer-kwargs))))))
 
 (define (serialize-configuration config fields)
   #~(string-append
@@ -168,10 +173,9 @@ (define (define-maybe-helper serialize? prefix syn)
              (or (not (maybe-value-set? val))
                  (stem? val)))
            #,@(if serialize?
-                  (list #'(define (serialize-maybe-stem field-name val)
-                            (if (stem? val)
-                                (serialize-stem field-name val)
-                                "")))
+                  (list #'(define (serialize-maybe-stem field-name val . rest)
+                            (when (maybe-value-set? val)
+                              (apply serialize-stem field-name val rest))))
                   '()))))))
 
 (define-syntax define-maybe
@@ -205,38 +209,49 @@ (define (define-configuration-helper serialize? serializer-prefix syn)
     "Extract and normalize arguments following @var{doc}."
     (let loop ((s s)
                (sanitizer* #f)
-               (serializer* #f))
-      (syntax-case s (sanitizer serializer empty-serializer)
+               (serializer* #f)
+               (serializer-kwargs* #f))
+      (syntax-case s (sanitizer serializer empty-serializer serializer-kwargs)
         (((sanitizer proc) tail ...)
          (if sanitizer*
              (syntax-violation 'sanitizer
                                "duplicate entry" #'proc)
-             (loop #'(tail ...) #'proc serializer*)))
+             (loop #'(tail ...)
+                   #'proc serializer* serializer-kwargs*)))
         (((serializer proc) tail ...)
          (if serializer*
              (syntax-violation 'serializer
                                "duplicate or conflicting entry" #'proc)
-             (loop #'(tail ...) sanitizer* #'proc)))
+             (loop #'(tail ...)
+                   sanitizer* #'proc serializer-kwargs*)))
         ((empty-serializer tail ...)
          (if serializer*
              (syntax-violation 'empty-serializer
                                "duplicate or conflicting entry" #f)
-             (loop #'(tail ...) sanitizer* #'empty-serializer)))
+             (loop #'(tail ...)
+                   sanitizer* #'empty-serializer #f)))
+        (((serializer-kwargs args) tail ...)
+         (if serializer-kwargs*
+             (syntax-violation 'serializer-kwargs
+                               "duplicate or conflicting entry" #f)
+             (loop #'(tail ...)
+                   sanitizer* serializer* #'args)))
         (()  ; stop condition
-         (values (list sanitizer* serializer*)))
+         (values (list sanitizer* serializer*
+                       (or serializer-kwargs* #'(quote ())))))
         ((proc)  ; TODO: deprecated, to be removed.
-         (every not (list sanitizer* serializer*))
+         (every not (list sanitizer* serializer* serializer-kwargs*))
          (begin
            (warning #f (G_ "specifying serializers after documentation is \
 deprecated, use (serializer ~a) instead~%") (syntax->datum #'proc))
-           (values (list #f #'proc)))))))
+           (values (list #f #'proc #'(quote ()))))))))
 
   (syntax-case syn ()
     ((_ stem (field field-type+def doc extra-args ...) ...)
      (with-syntax
          ((((field-type def) ...)
            (map normalize-field-type+def #'(field-type+def ...)))
-          (((sanitizer* serializer*) ...)
+          (((sanitizer* serializer* serializer-kwargs*) ...)
            (map normalize-extra-args #'((extra-args ...) ...))))
        (with-syntax
            (((field-getter ...)
@@ -322,6 +337,7 @@ (define (define-configuration-helper serialize? serializer-prefix syn)
                        (or field-sanitizer
                            (id #'stem #'validate- #'stem #'- #'field)))
                       (serializer field-serializer)
+                      (serializer-kwargs serializer-kwargs*)
                       (default-value-thunk
                         (lambda ()
                           (if (maybe-value-set? (syntax->datum field-default))
diff --git a/tests/services/configuration.scm b/tests/services/configuration.scm
index 1db83bb273..ae1b194e81 100644
--- a/tests/services/configuration.scm
+++ b/tests/services/configuration.scm
@@ -297,6 +297,40 @@ (define (sanitize-port value)
                     (lambda _ "lorem")
                     (sanitizer (lambda () #t)))))))
 
+(test-group "Serializer keyword arguments"
+  (define* (serialize-port field value #:key host)
+    (format #f "host=~a,port=~d" host value))
+
+  (define-configuration kwarg-config
+    (port
+     (port 80)
+     "Lorem Ipsum."
+     (serializer-kwargs '(#:host "[2001:db8::1]"))))
+
+  (test-equal "keyword argument provided"
+    "host=[2001:db8::1],port=80"
+    (eval-gexp
+     (serialize-configuration (kwarg-config)
+                              kwarg-config-fields))))
+
+(test-group "Serializer keyword arguments, define-maybe"
+  (define* (serialize-port field value #:key host)
+    (format #f "host=~a,port=~d" host value))
+
+  (define-maybe port)
+
+  (define-configuration kwarg-config
+    (port
+     (maybe-port 80)
+     "Lorem Ipsum."
+     (serializer-kwargs '(#:host "[2001:db8::1]"))))
+
+  (test-equal "keyword argument provided, maybe type"
+    "host=[2001:db8::1],port=80"
+    (eval-gexp
+     (serialize-configuration (kwarg-config)
+                              kwarg-config-fields))))
+
 
 ;;;
 ;;; define-maybe macro.
-- 
2.39.2





Information forwarded to guix-patches@HIDDEN:
bug#63985; Package guix-patches. Full text available.

Message received at 63985 <at> debbugs.gnu.org:


Received: (at 63985) by debbugs.gnu.org; 9 Jun 2023 21:21:39 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Jun 09 17:21:39 2023
Received: from localhost ([127.0.0.1]:32884 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1q7jYA-0000Uz-KG
	for submit <at> debbugs.gnu.org; Fri, 09 Jun 2023 17:21:39 -0400
Received: from smtpm3.myservices.hosting ([185.26.105.234]:56450)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <mirai@HIDDEN>) id 1q7jY8-0000Ur-4c
 for 63985 <at> debbugs.gnu.org; Fri, 09 Jun 2023 17:21:37 -0400
Received: from mail1.netim.hosting (unknown [185.26.106.173])
 by smtpm3.myservices.hosting (Postfix) with ESMTP id 6F3DC21057
 for <63985 <at> debbugs.gnu.org>; Fri,  9 Jun 2023 23:21:35 +0200 (CEST)
Received: from localhost (localhost [127.0.0.1])
 by mail1.netim.hosting (Postfix) with ESMTP id ABB328009D;
 Fri,  9 Jun 2023 23:21:34 +0200 (CEST)
X-Virus-Scanned: Debian amavisd-new at mail1.netim.hosting
Received: from mail1.netim.hosting ([127.0.0.1])
 by localhost (mail1-2.netim.hosting [127.0.0.1]) (amavisd-new, port 10026)
 with ESMTP id u5xLINKXxdzr; Fri,  9 Jun 2023 23:21:34 +0200 (CEST)
Received: from guix-nuc.home.arpa (unknown [10.192.1.83])
 (Authenticated sender: lumen@HIDDEN)
 by mail1.netim.hosting (Postfix) with ESMTPSA id D75228009C;
 Fri,  9 Jun 2023 23:21:33 +0200 (CEST)
From: Bruno Victal <mirai@HIDDEN>
To: 63985 <at> debbugs.gnu.org
Subject: [PATCH RFC 5/5] services: configuration: New generic-ini module.
Date: Fri,  9 Jun 2023 22:21:00 +0100
Message-Id: <9906d692a359142a929634d9e6409164da257914.1686345627.git.mirai@HIDDEN>
X-Mailer: git-send-email 2.39.2
In-Reply-To: <cover.1686343642.git.mirai@HIDDEN>
References: <cover.1686343642.git.mirai@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 63985
Cc: Bruno Victal <mirai@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Implements a ‘serialize-ini-configuration’ procedure for serializing
record-types defined with define-configuration into generic INI files.

* gnu/services/configuration/generic-ini.scm: New module.
* tests/services/configuration/generic-ini.scm: Add tests for new module.
* Makefile.am: Register tests.
* gnu/local.mk: Register module.
---
 Makefile.am                                  |   1 +
 gnu/local.mk                                 |   1 +
 gnu/services/configuration/generic-ini.scm   | 129 +++++++++++++++++++
 tests/services/configuration/generic-ini.scm | 106 +++++++++++++++
 4 files changed, 237 insertions(+)
 create mode 100644 gnu/services/configuration/generic-ini.scm
 create mode 100644 tests/services/configuration/generic-ini.scm

diff --git a/Makefile.am b/Makefile.am
index ab901df757..8dc9a3438b 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -552,6 +552,7 @@ SCM_TESTS =					\
   tests/services.scm				\
   tests/services/file-sharing.scm		\
   tests/services/configuration.scm		\
+  tests/services/configuration/generic-ini.scm	\
   tests/services/lightdm.scm			\
   tests/services/linux.scm			\
   tests/services/telephony.scm			\
diff --git a/gnu/local.mk b/gnu/local.mk
index ce16d37e2b..a05d70aff3 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -670,6 +670,7 @@ GNU_SYSTEM_MODULES =				\
   %D%/services/cgit.scm			\
   %D%/services/ci.scm				\
   %D%/services/configuration.scm		\
+  %D%/services/configuration/generic-ini.scm	\
   %D%/services/cuirass.scm			\
   %D%/services/cups.scm				\
   %D%/services/databases.scm			\
diff --git a/gnu/services/configuration/generic-ini.scm b/gnu/services/configuration/generic-ini.scm
new file mode 100644
index 0000000000..338a35f90d
--- /dev/null
+++ b/gnu/services/configuration/generic-ini.scm
@@ -0,0 +1,129 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2023 Bruno Victal <mirai@HIDDEN>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (gnu services configuration generic-ini)
+  #:use-module (gnu services configuration)
+  #:use-module (guix gexp)
+  #:use-module (srfi srfi-171)
+  #:use-module (ice-9 match)
+  #:export (ini-entry?
+            list-of-ini-entries?
+
+            serialize-ini-configuration))
+
+;;;
+;;; Generic INI serializer
+;;;
+
+
+;;;
+;;; Predicates
+;;;
+
+;; This is the same format used in SRFI-233 but without comment support.
+(define ini-entry?
+  (match-lambda
+    (((? symbol) (? symbol) (? string)) #t)
+    (_ #f)))
+
+(define list-of-ini-entries
+  (list-of ini-entry?))
+
+;;
+;; Overall design document
+;;
+;; This module implements a generic INI serializer for a record-type defined
+;; using define-configuration.
+;; It expects that the serialize-<type> procedures return a list with
+;; three elements of the form:
+;;    (list section key value)
+;; Where ‘section’ and ‘key’ are symbols and ‘value’ is a string.
+;; The fields within define-configuration do not have to be ordered in,
+;; any way whatsoever as the ‘serialize-ini’ will group them up automatically.
+;; This implies that no assumptions should be made regarding the order of the
+;; values in the serializied INI output.
+;;
+;; Additional notes:
+;; Q: Why not replace rcons with string-append and forego the ungexp-splice?
+;; A: The transduction happens outside of the G-Exp while the final string-append
+;;    takes place in the G-Exp.
+;;
+;; Debugging tips: Open a REPL and try one transducer at a time from
+;; ‘ini-transducer’.
+;;
+
+(define (add-section-header partition)
+  (let ((header (caar partition)))
+    (cons (list header)
+          partition)))
+
+(define serializer
+  (match-lambda
+    ((section)
+     #~(format #f "[~a]~%" '#$section))
+    ((section key value)
+     #~(format #f "~a=~a~%" '#$key #$value))
+    ((? string? s)  ; used for the newline between sections
+     s)))
+
+(define ini-transducer
+  (compose (tpartition car)
+           (tmap add-section-header)
+           (tadd-between '("\n"))
+           tconcatenate
+           (tmap serializer)))
+
+;; A “first-pass” serialization is performed and sorted in order
+;; to group up the fields by “section” before passing through the
+;; transducer.
+(define (serialize-ini-configuration config fields)
+  (let* ((srfi-233-IR
+          ;; First pass: “serialize” into a (disordered) list of
+          ;; SRFI-233 entries.
+          (list-transduce (base-transducer config) rcons fields))
+         (comparator (lambda (x y)
+                       ;; Sort the SRFI-233 entries by section.
+                       (string<=? (symbol->string (car x))
+                                  (symbol->string (car y)))))
+         (sorted-entries (sort srfi-233-IR comparator)))
+    #~(string-append
+       #$@(list-transduce ini-transducer rcons sorted-entries))))
+
+;; FIXME:RFC:
+;;       generic-ini- prefixed serializing procs?
+;;       (perhaps prefixed as generic-ini: ?)
+;; Example procedures:
+;;
+(define* (generic-ini-serialize-string field-name value #:key section)
+  (list section field-name value))
+
+;; field-name-transform can be used to “uglify” a field-name,
+;; e.g. want-ipv6?  ->  want_ipv6
+(define* (generic-ini-serialize-boolean field-name value #:key section
+                            (field-name-transform identity))
+  (list section (field-name-transform field-name)
+        (if value "true" "false")))
+
+
+;;; FIXME: delete this before inclusion, these are notes for the first RFC.
+;;;
+;;; Left out for now (but readily extendable):
+;;;  * Custom leading (presumed to be whitespace) characters for entries
+;;;    à la gitconfig, mostly pretty-printing purposes
+;;;  * Configurable delimiter (\n, \r\n, \0, ...)
+;;;  * Configurable Key-value separator (this is usually =)
diff --git a/tests/services/configuration/generic-ini.scm b/tests/services/configuration/generic-ini.scm
new file mode 100644
index 0000000000..c04acdcd46
--- /dev/null
+++ b/tests/services/configuration/generic-ini.scm
@@ -0,0 +1,106 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2023 Bruno Victal <mirai@HIDDEN>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (tests services configuration generic-ini)
+  #:use-module (gnu services configuration)
+  #:use-module (gnu services configuration generic-ini)
+  #:use-module (guix diagnostics)
+  #:use-module (guix gexp)
+  #:use-module (guix store)
+  #:autoload (guix i18n) (G_)
+  #:use-module (srfi srfi-34)
+  #:use-module (srfi srfi-64)
+  #:use-module (srfi srfi-71))
+
+;;; Tests for the (gnu services configuration generic-ini) module.
+
+(test-begin "generic-ini serializer")
+
+
+(define expected-output "\
+[featured]
+favourite=true
+track=Deep affection
+artist=Magistina Saga
+album=Creaith Anthem
+
+[main]
+enabled=true
+")
+
+
+;;;
+;;; Serializers
+;;;
+(define (strip-trailing-?-character field-name)
+  "Drop rightmost '?' character"
+  (let ((str (symbol->string field-name)))
+    (if (string-suffix? "?" str)
+        (string->symbol (string-drop-right str 1))
+        field-name)))
+
+(define* (serialize-string field-name value #:key section)
+  (list section field-name value))
+
+(define* (serialize-boolean field-name value #:key section)
+  (list section (strip-trailing-?-character field-name)
+        (if value "true" "false")))
+
+
+;;;
+;;; Record-type definition
+;;;
+
+(define-configuration foo-configuration
+  (album
+   (string "Creaith Anthem")
+   "Lorem Ipsum …"
+   (serializer-kwargs '(#:section featured)))
+
+  (artist
+   (string "Magistina Saga")
+   "Lorem Ipsum …"
+   (serializer-kwargs '(#:section featured)))
+
+  (track
+   (string "Deep affection")
+   "Lorem Ipsum …"
+   (serializer-kwargs '(#:section featured)))
+
+  (favourite?
+   (boolean #t)
+   "Lorem Ipsum …"
+   (serializer-kwargs '(#:section featured)))
+
+  (enabled?
+   (boolean #t)
+   "Lorem Ipsum …"
+   (serializer-kwargs '(#:section main))))
+
+(test-equal "Well-formed INI output from serialize-ini"
+  expected-output
+  ;; Serialize the above into a string, properly resolving any potential
+  ;; nested G-Exps as well.
+  (let* ((serialized-ini
+          (serialize-ini-configuration (foo-configuration)
+                                       foo-configuration-fields))
+         (lowered conn (with-store store
+                         ((lower-gexp serialized-ini) store))))
+    (eval (lowered-gexp-sexp lowered) (current-module))))
+
+(test-end)
-- 
2.39.2





Information forwarded to guix-patches@HIDDEN:
bug#63985; Package guix-patches. Full text available.

Message received at 63985 <at> debbugs.gnu.org:


Received: (at 63985) by debbugs.gnu.org; 9 Jun 2023 21:21:34 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Jun 09 17:21:34 2023
Received: from localhost ([127.0.0.1]:32881 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1q7jY6-0000Uj-BN
	for submit <at> debbugs.gnu.org; Fri, 09 Jun 2023 17:21:34 -0400
Received: from smtpmciv3.myservices.hosting ([185.26.107.239]:44790)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <mirai@HIDDEN>) id 1q7jY4-0000UV-Kr
 for 63985 <at> debbugs.gnu.org; Fri, 09 Jun 2023 17:21:32 -0400
Received: from mail1.netim.hosting (unknown [185.26.106.173])
 by smtpmciv3.myservices.hosting (Postfix) with ESMTP id 1260B208D0
 for <63985 <at> debbugs.gnu.org>; Fri,  9 Jun 2023 23:21:31 +0200 (CEST)
Received: from localhost (localhost [127.0.0.1])
 by mail1.netim.hosting (Postfix) with ESMTP id 6852D8009C;
 Fri,  9 Jun 2023 23:21:23 +0200 (CEST)
X-Virus-Scanned: Debian amavisd-new at mail1.netim.hosting
Received: from mail1.netim.hosting ([127.0.0.1])
 by localhost (mail1-2.netim.hosting [127.0.0.1]) (amavisd-new, port 10026)
 with ESMTP id o20jgf_5watt; Fri,  9 Jun 2023 23:21:23 +0200 (CEST)
Received: from guix-nuc.home.arpa (unknown [10.192.1.83])
 (Authenticated sender: lumen@HIDDEN)
 by mail1.netim.hosting (Postfix) with ESMTPSA id F08C080098;
 Fri,  9 Jun 2023 23:21:22 +0200 (CEST)
From: Bruno Victal <mirai@HIDDEN>
To: 63985 <at> debbugs.gnu.org
Subject: [PATCH RFC 3/5] services: fstrim-service-type: Serialize with
 SRFI-171 transducers.
Date: Fri,  9 Jun 2023 22:20:58 +0100
Message-Id: <77911cd47e7ae77df6d614d7d07d78b5cf7781f0.1686345627.git.mirai@HIDDEN>
X-Mailer: git-send-email 2.39.2
In-Reply-To: <cover.1686343642.git.mirai@HIDDEN>
References: <cover.1686343642.git.mirai@HIDDEN>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 63985
Cc: Bruno Victal <mirai@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

* gnu/services/linux.scm (serialize-fstrim-configuration): Refactor to use
base-transducer.
---
 gnu/services/linux.scm | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/gnu/services/linux.scm b/gnu/services/linux.scm
index d105c42850..3cfa6d6855 100644
--- a/gnu/services/linux.scm
+++ b/gnu/services/linux.scm
@@ -40,6 +40,7 @@ (define-module (gnu services linux)
   #:use-module (srfi srfi-26)
   #:use-module (srfi srfi-34)
   #:use-module (srfi srfi-35)
+  #:use-module (srfi srfi-171)
   #:use-module (ice-9 format)
   #:use-module (ice-9 match)
   #:export (earlyoom-configuration
@@ -227,13 +228,9 @@ (define-configuration fstrim-configuration
   (prefix fstrim-))
 
 (define (serialize-fstrim-configuration config)
-  (concatenate
-   (filter list?
-           (map (lambda (field)
-                  ((configuration-field-serializer field)
-                   (configuration-field-name field)
-                   ((configuration-field-getter field) config)))
-                fstrim-configuration-fields))))
+  (list-transduce (compose (base-transducer config) tconcatenate)
+                  rcons
+                  fstrim-configuration-fields))
 
 (define (fstrim-mcron-job config)
   (match-record config <fstrim-configuration> (package schedule)
-- 
2.39.2





Information forwarded to guix-patches@HIDDEN:
bug#63985; Package guix-patches. Full text available.

Message received at 63985 <at> debbugs.gnu.org:


Received: (at 63985) by debbugs.gnu.org; 9 Jun 2023 21:21:32 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Jun 09 17:21:32 2023
Received: from localhost ([127.0.0.1]:32878 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1q7jY3-0000UT-UB
	for submit <at> debbugs.gnu.org; Fri, 09 Jun 2023 17:21:32 -0400
Received: from smtpmciv2.myservices.hosting ([185.26.107.238]:34304)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <mirai@HIDDEN>) id 1q7jY1-0000UL-S9
 for 63985 <at> debbugs.gnu.org; Fri, 09 Jun 2023 17:21:30 -0400
Received: from mail1.netim.hosting (unknown [185.26.106.173])
 by smtpmciv2.myservices.hosting (Postfix) with ESMTP id 307DB20E2B
 for <63985 <at> debbugs.gnu.org>; Fri,  9 Jun 2023 23:21:23 +0200 (CEST)
Received: from localhost (localhost [127.0.0.1])
 by mail1.netim.hosting (Postfix) with ESMTP id 6EF218009B;
 Fri,  9 Jun 2023 23:21:17 +0200 (CEST)
X-Virus-Scanned: Debian amavisd-new at mail1.netim.hosting
Received: from mail1.netim.hosting ([127.0.0.1])
 by localhost (mail1-2.netim.hosting [127.0.0.1]) (amavisd-new, port 10026)
 with ESMTP id UFaLkS3tMGwD; Fri,  9 Jun 2023 23:21:17 +0200 (CEST)
Received: from guix-nuc.home.arpa (unknown [10.192.1.83])
 (Authenticated sender: lumen@HIDDEN)
 by mail1.netim.hosting (Postfix) with ESMTPSA id 00E9880098;
 Fri,  9 Jun 2023 23:21:16 +0200 (CEST)
From: Bruno Victal <mirai@HIDDEN>
To: 63985 <at> debbugs.gnu.org
Subject: [PATCH RFC 2/5] services: configuration: Use transducers within
 serialize-configuration.
Date: Fri,  9 Jun 2023 22:20:57 +0100
Message-Id: <d4fdd34b6f54d21cddecbe62ee0878df7fd95941.1686345627.git.mirai@HIDDEN>
X-Mailer: git-send-email 2.39.2
In-Reply-To: <cover.1686343642.git.mirai@HIDDEN>
References: <cover.1686343642.git.mirai@HIDDEN>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 63985
Cc: Bruno Victal <mirai@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Introduces 'base-transducer', a SRFI-171 based transducer that can be used as a
starting point for writing custom configuration record serializing procedures.

This also fixes the symbol maybe-value serialization test case.

* gnu/services/configuration.scm (empty-serializer?): New predicate.
(base-transducer): New procedure.
(serialize-configuration): Adapt to use base-transducer.
* tests/services/configuration.scm: Remove test-expect-fail.
---
 gnu/services/configuration.scm   | 24 +++++++++++++++++++-----
 tests/services/configuration.scm |  4 ----
 2 files changed, 19 insertions(+), 9 deletions(-)

diff --git a/gnu/services/configuration.scm b/gnu/services/configuration.scm
index dafe72f4fe..0818b48bb5 100644
--- a/gnu/services/configuration.scm
+++ b/gnu/services/configuration.scm
@@ -42,6 +42,7 @@ (define-module (gnu services configuration)
   #:use-module (srfi srfi-26)
   #:use-module (srfi srfi-34)
   #:use-module (srfi srfi-35)
+  #:use-module (srfi srfi-171)
   #:export (configuration-field
             configuration-field-name
             configuration-field-type
@@ -59,6 +60,7 @@ (define-module (gnu services configuration)
             define-configuration/no-serialization
             no-serialization
 
+            base-transducer
             serialize-configuration
             define-maybe
             define-maybe/no-serialization
@@ -125,13 +127,25 @@ (define-record-type* <configuration-field>
   (default-value-thunk configuration-field-default-value-thunk)
   (documentation configuration-field-documentation))
 
+(define (empty-serializer? field)
+  (eq? empty-serializer
+       (configuration-field-serializer field)))
+
+(define (base-transducer config)
+  (compose (tremove empty-serializer?)
+           ;; Only serialize fields whose value isn't '%unset-marker%.
+           (tfilter (lambda (field)
+                      (let ((field-value ((configuration-field-getter field)
+                                          config)))
+                        (maybe-value-set? field-value))))
+           (tmap (lambda (field)
+                   ((configuration-field-serializer field)
+                    (configuration-field-name field)
+                    ((configuration-field-getter field) config))))))
+
 (define (serialize-configuration config fields)
   #~(string-append
-     #$@(map (lambda (field)
-               ((configuration-field-serializer field)
-                (configuration-field-name field)
-                ((configuration-field-getter field) config)))
-             fields)))
+     #$@(list-transduce (base-transducer config) rcons fields)))
 
 (define-syntax-rule (id ctx parts ...)
   "Assemble PARTS into a raw (unhygienic) identifier."
diff --git a/tests/services/configuration.scm b/tests/services/configuration.scm
index 8ad5907f37..1db83bb273 100644
--- a/tests/services/configuration.scm
+++ b/tests/services/configuration.scm
@@ -337,10 +337,6 @@ (define-maybe symbol)
 (define-configuration config-with-maybe-symbol
   (protocol maybe-symbol ""))
 
-;;; Maybe symbol values are currently seen as serializable, because the
-;;; unspecified value is '%unset-marker%, which is a symbol itself.
-;;; TODO: Remove expected fail marker after resolution.
-(test-expect-fail 1)
 (test-equal "symbol maybe value serialization, unspecified"
   ""
   (gexp->approximate-sexp
-- 
2.39.2





Information forwarded to guix-patches@HIDDEN:
bug#63985; Package guix-patches. Full text available.

Message received at 63985 <at> debbugs.gnu.org:


Received: (at 63985) by debbugs.gnu.org; 9 Jun 2023 21:21:12 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Jun 09 17:21:12 2023
Received: from localhost ([127.0.0.1]:32875 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1q7jXk-0000Tw-Ht
	for submit <at> debbugs.gnu.org; Fri, 09 Jun 2023 17:21:12 -0400
Received: from smtpmciv1.myservices.hosting ([185.26.107.237]:59346)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <mirai@HIDDEN>) id 1q7jXi-0000To-UQ
 for 63985 <at> debbugs.gnu.org; Fri, 09 Jun 2023 17:21:11 -0400
Received: from mail1.netim.hosting (unknown [185.26.106.173])
 by smtpmciv1.myservices.hosting (Postfix) with ESMTP id 36F1020CD0
 for <63985 <at> debbugs.gnu.org>; Fri,  9 Jun 2023 23:21:09 +0200 (CEST)
Received: from localhost (localhost [127.0.0.1])
 by mail1.netim.hosting (Postfix) with ESMTP id 7E79F8009B;
 Fri,  9 Jun 2023 23:21:09 +0200 (CEST)
X-Virus-Scanned: Debian amavisd-new at mail1.netim.hosting
Received: from mail1.netim.hosting ([127.0.0.1])
 by localhost (mail1-2.netim.hosting [127.0.0.1]) (amavisd-new, port 10026)
 with ESMTP id cshjM1svIMQ5; Fri,  9 Jun 2023 23:21:09 +0200 (CEST)
Received: from guix-nuc.home.arpa (unknown [10.192.1.83])
 (Authenticated sender: lumen@HIDDEN)
 by mail1.netim.hosting (Postfix) with ESMTPSA id B6D6080098;
 Fri,  9 Jun 2023 23:21:08 +0200 (CEST)
From: Bruno Victal <mirai@HIDDEN>
To: 63985 <at> debbugs.gnu.org
Subject: [PATCH RFC 1/5] services: configuration: Simplify
 normalize-extra-args.
Date: Fri,  9 Jun 2023 22:20:56 +0100
Message-Id: <ea63e4f3d57d58279fb9649eafaf507f69fd858f.1686345627.git.mirai@HIDDEN>
X-Mailer: git-send-email 2.39.2
In-Reply-To: <cover.1686343642.git.mirai@HIDDEN>
References: <cover.1686343642.git.mirai@HIDDEN>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 63985
Cc: Bruno Victal <mirai@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

* gnu/services/configuration.scm
(define-configuration-helper, normalize-extra-args): Use #f instead of %unset-value.
---
 gnu/services/configuration.scm | 26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/gnu/services/configuration.scm b/gnu/services/configuration.scm
index 367b85c1be..dafe72f4fe 100644
--- a/gnu/services/configuration.scm
+++ b/gnu/services/configuration.scm
@@ -190,32 +190,32 @@ (define (define-configuration-helper serialize? serializer-prefix syn)
   (define (normalize-extra-args s)
     "Extract and normalize arguments following @var{doc}."
     (let loop ((s s)
-               (sanitizer* %unset-value)
-               (serializer* %unset-value))
+               (sanitizer* #f)
+               (serializer* #f))
       (syntax-case s (sanitizer serializer empty-serializer)
         (((sanitizer proc) tail ...)
-         (if (maybe-value-set? sanitizer*)
-             (syntax-violation 'sanitizer "duplicate entry"
-                               #'proc)
+         (if sanitizer*
+             (syntax-violation 'sanitizer
+                               "duplicate entry" #'proc)
              (loop #'(tail ...) #'proc serializer*)))
         (((serializer proc) tail ...)
-         (if (maybe-value-set? serializer*)
-             (syntax-violation 'serializer "duplicate or conflicting entry"
-                               #'proc)
+         (if serializer*
+             (syntax-violation 'serializer
+                               "duplicate or conflicting entry" #'proc)
              (loop #'(tail ...) sanitizer* #'proc)))
         ((empty-serializer tail ...)
-         (if (maybe-value-set? serializer*)
+         (if serializer*
              (syntax-violation 'empty-serializer
                                "duplicate or conflicting entry" #f)
              (loop #'(tail ...) sanitizer* #'empty-serializer)))
         (()  ; stop condition
          (values (list sanitizer* serializer*)))
         ((proc)  ; TODO: deprecated, to be removed.
-         (null? (filter-map maybe-value-set? (list sanitizer* serializer*)))
+         (every not (list sanitizer* serializer*))
          (begin
            (warning #f (G_ "specifying serializers after documentation is \
 deprecated, use (serializer ~a) instead~%") (syntax->datum #'proc))
-           (values (list %unset-value #'proc)))))))
+           (values (list #f #'proc)))))))
 
   (syntax-case syn ()
     ((_ stem (field field-type+def doc extra-args ...) ...)
@@ -239,11 +239,11 @@ (define (define-configuration-helper serialize? serializer-prefix syn)
                      default-value))
                   #'((field-type def) ...)))
             ((field-sanitizer ...)
-             (map maybe-value #'(sanitizer* ...)))
+             #'(sanitizer* ...))
             ((field-serializer ...)
              (map (lambda (type proc)
                     (and serialize?
-                         (or (maybe-value proc)
+                         (or proc
                              (if serializer-prefix
                                  (id #'stem serializer-prefix #'serialize- type)
                                  (id #'stem #'serialize- type)))))

base-commit: c348b1be3891e6eb47bbdd9fc1587aba2b6ab0b7
-- 
2.39.2





Information forwarded to guix-patches@HIDDEN:
bug#63985; Package guix-patches. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 9 Jun 2023 21:18:49 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Jun 09 17:18:49 2023
Received: from localhost ([127.0.0.1]:32868 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1q7jVQ-0000PO-TS
	for submit <at> debbugs.gnu.org; Fri, 09 Jun 2023 17:18:49 -0400
Received: from lists.gnu.org ([209.51.188.17]:54216)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <mirai@HIDDEN>) id 1q7jVP-0000PF-As
 for submit <at> debbugs.gnu.org; Fri, 09 Jun 2023 17:18:47 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10])
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <mirai@HIDDEN>) id 1q7jVO-0005CP-Uo
 for guix-patches@HIDDEN; Fri, 09 Jun 2023 17:18:46 -0400
Received: from smtpm4.myservices.hosting ([185.26.105.235])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <mirai@HIDDEN>) id 1q7jVN-0006gA-5S
 for guix-patches@HIDDEN; Fri, 09 Jun 2023 17:18:46 -0400
Received: from mail1.netim.hosting (unknown [185.26.106.173])
 by smtpm4.myservices.hosting (Postfix) with ESMTP id 8D6CD20D86
 for <guix-patches@HIDDEN>; Fri,  9 Jun 2023 23:18:42 +0200 (CEST)
Received: from localhost (localhost [127.0.0.1])
 by mail1.netim.hosting (Postfix) with ESMTP id C8E8B80097;
 Fri,  9 Jun 2023 23:18:38 +0200 (CEST)
X-Virus-Scanned: Debian amavisd-new at mail1.netim.hosting
Received: from mail1.netim.hosting ([127.0.0.1])
 by localhost (mail1-2.netim.hosting [127.0.0.1]) (amavisd-new, port 10026)
 with ESMTP id MqEhTByOxNlt; Fri,  9 Jun 2023 23:18:38 +0200 (CEST)
Received: from guix-nuc.home.arpa (unknown [10.192.1.83])
 (Authenticated sender: lumen@HIDDEN)
 by mail1.netim.hosting (Postfix) with ESMTPSA id 39E4B80060;
 Fri,  9 Jun 2023 23:18:38 +0200 (CEST)
From: Bruno Victal <mirai@HIDDEN>
To: guix-patches@HIDDEN
Subject: [PATCH RFC 0/5] Generic INI serializer & SRFI-171 for
 define-configuration
Date: Fri,  9 Jun 2023 22:18:24 +0100
Message-Id: <cover.1686343642.git.mirai@HIDDEN>
X-Mailer: git-send-email 2.39.2
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
X-Debbugs-CC: ludo@HIDDEN, maxim.cournoyer@HIDDEN,
 liliana.prikler@HIDDEN
Content-Transfer-Encoding: 8bit
Received-SPF: pass client-ip=185.26.105.235; envelope-from=mirai@HIDDEN;
 helo=smtpm4.myservices.hosting
X-Spam_score_int: -18
X-Spam_score: -1.9
X-Spam_bar: -
X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001,
 SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: -1.3 (-)
X-Debbugs-Envelope-To: submit
Cc: Bruno Victal <mirai@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.3 (--)

This RFC patch series (more like 3 patch series for the price of 1)
implements the following:

* Serializer Keyword arguments parameter in define-configuration.
  Allows for serializing procedures to be specified as:
    (define* (serialize-string field-name value #:key …)
      …)
  Examples in the unit tests.

* Express serialize-configuration with SRFI-171 transducers.
  The ‘base-transducer’ can be used to craft more specialized
  configuration record serializers.

* Generic INI serializer.
  This procedure can be used for crafting INI files from a
  record-type defined with define-configuration.
  Example for generic-ini in action can be found in the unit test.


These changes are motivated in part by a (in progress) refactoring of
the NetworkManager service-type.

Notes:
* I've left Generic-INI and serializer-kwargs undocumented since this
  is at its RFC stage.
* The (gnu services configuration generic-ini) module contains some trailing
  notes that should be removed before merging in.
* jami-account->alist explicitly checks for the empty-string.
  (which I consider to be a serialization “artifact” arising from define-maybe)
  This is the only (relevant) test that failed and will need to be investigated.

Bruno Victal (5):
  services: configuration: Simplify normalize-extra-args.
  services: configuration: Use transducers within
    serialize-configuration.
  services: fstrim-service-type: Serialize with SRFI-171 transducers.
  services: configuration: Add serializer-kwargs field.
  services: configuration: New generic-ini module.

 Makefile.am                                  |   1 +
 gnu/local.mk                                 |   1 +
 gnu/services/configuration.scm               |  86 +++++++++----
 gnu/services/configuration/generic-ini.scm   | 129 +++++++++++++++++++
 gnu/services/linux.scm                       |  11 +-
 tests/services/configuration.scm             |  38 +++++-
 tests/services/configuration/generic-ini.scm | 106 +++++++++++++++
 7 files changed, 333 insertions(+), 39 deletions(-)
 create mode 100644 gnu/services/configuration/generic-ini.scm
 create mode 100644 tests/services/configuration/generic-ini.scm


base-commit: c348b1be3891e6eb47bbdd9fc1587aba2b6ab0b7
-- 
2.39.2





Acknowledgement sent to Bruno Victal <mirai@HIDDEN>:
New bug report received and forwarded. Copy sent to ludo@HIDDEN, maxim.cournoyer@HIDDEN, liliana.prikler@HIDDEN, guix-patches@HIDDEN. Full text available.
Report forwarded to ludo@HIDDEN, maxim.cournoyer@HIDDEN, liliana.prikler@HIDDEN, guix-patches@HIDDEN:
bug#63985; Package guix-patches. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Mon, 25 Sep 2023 14:15:01 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.