From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:bcc0::]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id fvmKH35pgGBCEwEAgWs5BA (envelope-from ) for ; Wed, 21 Apr 2021 20:05:50 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id UAMBGn5pgGCLcAAAbx9fmQ (envelope-from ) for ; Wed, 21 Apr 2021 18:05:50 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 25A571CC5A for ; Wed, 21 Apr 2021 20:05:50 +0200 (CEST) Received: from localhost ([::1]:34692 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lZHET-0006i7-5M for larch@yhetil.org; Wed, 21 Apr 2021 14:05:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55900) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lZHDm-0006hV-Od for guix-devel@gnu.org; Wed, 21 Apr 2021 14:05:08 -0400 Received: from mail-qv1-xf34.google.com ([2607:f8b0:4864:20::f34]:38706) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lZHDi-0003hL-Uj for guix-devel@gnu.org; Wed, 21 Apr 2021 14:05:06 -0400 Received: by mail-qv1-xf34.google.com with SMTP id dp18so16133684qvb.5 for ; Wed, 21 Apr 2021 11:05:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-transfer-encoding; bh=9OOvkt38xAwGRLsys7V24IOIiuMTvFw5vW5o/i5wgPI=; b=HSFDIZ4eBAUvNwXmyJSATqQev4rei2zyXOx7BMNE7CI2YqwIVk3ZkI6AKepthehNcd wBO81C3asM1oKZfZQeBF4rS/W+uK/+I2DAa5tboTv+tQk2nQ9klWdq7/RlCwb05PCsmi vEuN8nYvAKPsyoubsGz95hIojFcSfEd/olrDHA9h4WSzX5OCm9E8LJstNYPs1uVi4FWY fDymx1KG+D/gdvo1UTAd8nLLkf+33AgzhZBUHjHNY3VTzlidmTkaCaYGsX5uPtYgs6Kq 0f7uaJ3dxEhpVgUQ9VCWbVEGEoEFV2qd5uNlCCv5y5w0rD4jk1nvQdI6DMmm6Nu+X5HR p3dg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version:content-transfer-encoding; bh=9OOvkt38xAwGRLsys7V24IOIiuMTvFw5vW5o/i5wgPI=; b=S7qDc2sn8ufCYzTNbjfPIm1CGjfTcI/+9UuAmGqfiZ5WunHc34wtDDqKYbmxPicCIW kz7uBkyEoy6Qmqz230+uUq7fKvCl63xLVva5k8V1aE4WEnzHrkvBJHe7djHAtcQA0+6F 0n3NwxWtPGxZRZFnRZ6U2YA/gchSmD0d2B5/Q5eKBWilfckdxVYkiiS35w8dHxGci26S e1qsurZK/V1XR447Q5b3tntO+e7yHVtDeq4ml6K1MJvxiSFHvNMYtiaxtNWSPmyl9AqB 13CHz6dMjf/O4pHf1dIzLh1qcf2rD7zezj8afxotVkhD4bxzueJZzk/iZ/YlByqRvr02 o1EA== X-Gm-Message-State: AOAM5319pipZ7W8X7EkJ5tf65xbJ8TopZisvMnyae9TRLQAYXQrbrvio ZS7XpXhX/qwnaF0IDPDS/eJjosKJI61RJg== X-Google-Smtp-Source: ABdhPJytnoU8pBiyyGX53zcfzylFak2m4aXaKa7Tz1B5v83N3FbtqJacJXYXtejTdOCq1O5biFJHqg== X-Received: by 2002:a05:6214:204:: with SMTP id i4mr33841310qvt.47.1619028301997; Wed, 21 Apr 2021 11:05:01 -0700 (PDT) Received: from hurd (dsl-10-133-199.b2b2c.ca. [72.10.133.199]) by smtp.gmail.com with ESMTPSA id m16sm51768qkm.100.2021.04.21.11.05.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Apr 2021 11:05:01 -0700 (PDT) From: Maxim Cournoyer To: Xinglu Chen Subject: Re: Best practices for writing services References: <878s6kqydj.fsf@yoctocell.xyz> <87wnswcmxi.fsf@gmail.com> <87k0ov7w72.fsf@yoctocell.xyz> Date: Wed, 21 Apr 2021 14:05:00 -0400 In-Reply-To: <87k0ov7w72.fsf@yoctocell.xyz> (Xinglu Chen's message of "Wed, 21 Apr 2021 12:45:21 +0200") Message-ID: <8735vjcy43.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Received-SPF: pass client-ip=2607:f8b0:4864:20::f34; envelope-from=maxim.cournoyer@gmail.com; helo=mail-qv1-xf34.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: guix-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: guix-devel@gnu.org Errors-To: guix-devel-bounces+larch=yhetil.org@gnu.org Sender: "Guix-devel" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1619028350; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=9OOvkt38xAwGRLsys7V24IOIiuMTvFw5vW5o/i5wgPI=; b=MYhBESM/lfjoN4mGg5K/MqHoNYIN8Wkktzj6I4t6reYbLaLUFkQ3oVqc+pjBexpLZgwP4P uR9CurCnLMzZ6ygQ9sYpcqolKz7FqMgu9TImaqp5Bc02ayYGluvkufsBJcJ16b+Kt9EI61 42MZzk4HVTkIDVlu/NSCQjyKF2FgTFVKVn0qSX2f+mDegYfr83nGbt/a5ARsKKQqGW8uAO 7jymcVQoI4srDJSXn5kkRpMQiSZts1yTYtDX/QVkQpS69Wznf2HXZZWLZf7oSnepkN0e2n OTq9gtGo1eRscAKOielZ5hQhyBmX+SxQTk4IPcCSAf/whwYsxRAemte6X4CSBQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1619028350; a=rsa-sha256; cv=none; b=J+hyFaTcfc1OQu0bojQFqOcHki4vnNkEzrq9SheW6XtGAxhtGFmva6Uybt+DDNFtsb9sJA 6tmtybwrVNdJhv4VoSAl1dl0L7N62dZdqOO7m82r5bUj2Y775TfeVi6IqAbUyG2PTPM4mh eJqro9Qh0xjwZvSWBx010zP4A44QJugWGlzapM/O7VB+sI/T3F2ZsyOatn9hhoFS3e0Iif lNwQJDFCFjaOduH5H9ytbZOwkx5eeVS4ZlZ4beMkUHgxGDuoIohZseKLccl/Wt6yusy3lL +m/8WwUeVsfhCids4xR8N/tv6JIwLBRIggA4ELSt2psX19AimcYSHjCYMXqSSQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=HSFDIZ4e; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of guix-devel-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-devel-bounces@gnu.org X-Migadu-Spam-Score: -3.14 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=HSFDIZ4e; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of guix-devel-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-devel-bounces@gnu.org X-Migadu-Queue-Id: 25A571CC5A X-Spam-Score: -3.14 X-Migadu-Scanner: scn0.migadu.com X-TUID: focB1TfH/J8Y Hi Xinglu, Xinglu Chen writes: > Hi, > > On Tue, Apr 20 2021, Maxim Cournoyer wrote: > >> That's a very good question, which I asked myself recently when >> attempting to write my first non-trivial service for Guix >> (jami-daemon-service-type). I'd say 'define-configuration' is >> technically superior because of the automatic type checking it provides. >> It's also neat to be able to define the doc at one place and >> auto-generate it (although that's still manual for now). > > You mean that one has to manually evaluate the =E2=80=98generate-document= ation=E2=80=99 > sexp and paste the output of it in the manual? I thought it would > automatically update the manual when running =E2=80=98make=E2=80=99. ;) Yes, that's my current understanding of how things are. It could be changed, for sure. >> It has definitely been collecting some dust compared to the simpler >> approach using 'define-record-type*' directly, and the doc output it >> can generate doesn't match what is currently the norm in the manual, >> so it'd need a bit of a refresh. > > Yeah, I noticed that some sections in the manual looked a bit different > than the rest. > > One thing that I find a little annoying is that you have to specify a > default value for the fields. This doesn=E2=80=99t make much sense in so= me > cases, e.g. there is no good default value for =E2=80=98user.name =3D NAM= E=E2=80=99 in the > Git config, the user should have to specify that themselves. There's a 'define-maybe' that can be used to declare a field that can take more than one type, e.g.: (define-maybe string) Will generate a definition like so: --8<---------------cut here---------------start------------->8--- (define (maybe-string? val) (or (eq? val 'disabled) (string? val))) --8<---------------cut here---------------end--------------->8--- Which the validator of define-configuration will use if you specify a field with the type 'maybe-string'. 'disabled is a bit semantically broken in some cases ('unspecified' could be nicer), but it does the job. > Another thing is that I don=E2=80=99t always want to =E2=80=9Cserialize-= =E2=80=9D the value for a > field, so I sometimes end up defining a bunch of dummy serializers that > just return an empty string. Good point! I've tried addressing that, without success so far [0]. Maxim [0] https://lists.gnu.org/archive/html/guix-devel/2021-04/msg00184.html