unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Best practices for writing services
@ 2021-03-18 15:23 Xinglu Chen
  2021-03-19 16:12 ` Joshua Branson
  2021-04-21  3:54 ` Maxim Cournoyer
  0 siblings, 2 replies; 12+ messages in thread
From: Xinglu Chen @ 2021-03-18 15:23 UTC (permalink / raw)
  To: guix-devel

Hi Guix,

I am going to write an mcron service for `guix home`[1][2] and before
proceding, I would like to get some suggestions on what the best
practices are for writing services in Guix.

Currently there seems to be two main ways to do this, the first one
is the define one or more records for the configuration field of a
service using `define-record-type*`, see the tor service in (gnu
services networking) for example.  The other method is to use
`define-configuration` to declare the configuration fields of a service,
see the transmission service in (gnu services file-sharing) for example.

The first method seems to be the more common one but the developer
usually has to write a lot of things manually.  The "real" configuration
file for the program or is usually created by concatenating a bunch of
strings and the developer has to write documentation for all the
configuration fields manually.

The second method removes quite a lot of boilerplate and the developer
will define different serializers that convert scheme syntax like lists,
alist, boolean... to the "real" configuration syntax of the program.  It
also does some automatic typechecking to some degree and allows the
developer to write docstrings for each configuration field.  There is
then a procedure called `generate-documentation` which can automatically
generate texinfo documenation from the docstrings.

I couldn't find any information in the manual regarding what conventions
should be used when writing services for Guix and would like to hear
from more experienced Guix hackers what the best practices are.

[1]: https://yhetil.org/guix-devel/878s6u2pco.fsf@trop.in
[2]: https://lists.sr.ht/~abcdw/rde-devel/%3C87h7l9r9xm.fsf%40yoctocell.xyz%3E


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2021-04-26 20:46 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-18 15:23 Best practices for writing services Xinglu Chen
2021-03-19 16:12 ` Joshua Branson
2021-03-19 17:01   ` Xinglu Chen
2021-04-21  3:54 ` Maxim Cournoyer
2021-04-21 10:45   ` Xinglu Chen
2021-04-21 18:05     ` Maxim Cournoyer
2021-04-22  7:27       ` Xinglu Chen
2021-04-23  4:42         ` Maxim Cournoyer
2021-04-23  6:04           ` Xinglu Chen
2021-04-21 22:10     ` raingloom
2021-04-22  7:19       ` Xinglu Chen
2021-04-26 20:29         ` raingloom

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).