From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:c151::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id C0tiLX3NVGCzQwAA0tVLHw (envelope-from ) for ; Fri, 19 Mar 2021 16:12:45 +0000 Received: from aspmx2.migadu.com ([2001:41d0:2:c151::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id WAbJKH3NVGCDcQAAB5/wlQ (envelope-from ) for ; Fri, 19 Mar 2021 16:12:45 +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 aspmx2.migadu.com (Postfix) with ESMTPS id 4486D1D3B3 for ; Fri, 19 Mar 2021 17:12:45 +0100 (CET) Received: from localhost ([::1]:43702 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lNHjw-0002pC-9O for larch@yhetil.org; Fri, 19 Mar 2021 12:12:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47302) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lNHjk-0002mr-NZ for guix-devel@gnu.org; Fri, 19 Mar 2021 12:12:33 -0400 Received: from mx1.dismail.de ([78.46.223.134]:39308) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lNHji-0000wk-8d for guix-devel@gnu.org; Fri, 19 Mar 2021 12:12:32 -0400 Received: from mx1.dismail.de (localhost [127.0.0.1]) by mx1.dismail.de (OpenSMTPD) with ESMTP id 91ea6077; Fri, 19 Mar 2021 17:12:26 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=dismail.de; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type; s=20190914; bh=fbRo5CWiAQvSGfKvNk2fayw6nuhQ+dPmok RP8nKGi2k=; b=YIh7sz/7QVKJS+0KMH2oAvAI0ZhwyJY1pBhL2P4JqXq0oeTaEA KkkNruo0UmYm3WS+06JJxfW9TWgaZPo6pOEq1Baj9fy3fejmD0dmSWk58x3I2RUi tjLn2oJlGHodoKMWc7pYnGkhmhTVh2YTpV1x/6URyI7zGYlVbx4SWE8ICdxdk+EG CDoo1lUt0Fd6ucXPteihSvtV4ovnMJKu+79OGYRCh6MmbAML7isfRq0w09mpgQuM waJybO8PvgkpBcBwieP6onKVs2jEIriM6s0zDkmK/OX0gK05NsTwjluTiHi8n6WL ZU0m5uKcNrMAV0IFjmCzym2B2dIv+UBn+VrQ== Received: from smtp2.dismail.de ( [10.240.26.12]) by mx1.dismail.de (OpenSMTPD) with ESMTP id ff47df8c; Fri, 19 Mar 2021 17:12:26 +0100 (CET) Received: from smtp2.dismail.de (localhost [127.0.0.1]) by smtp2.dismail.de (OpenSMTPD) with ESMTP id 02fb6535; Fri, 19 Mar 2021 17:12:25 +0100 (CET) Received: by dismail.de (OpenSMTPD) with ESMTPSA id addda613 (TLSv1.3:AEAD-AES256-GCM-SHA384:256:NO); Fri, 19 Mar 2021 17:12:24 +0100 (CET) From: Joshua Branson To: Xinglu Chen Cc: guix-devel@gnu.org Subject: Re: Best practices for writing services References: <878s6kqydj.fsf@yoctocell.xyz> Mail-Followup-To: Xinglu Chen , guix-devel@gnu.org Date: Fri, 19 Mar 2021 12:12:06 -0400 In-Reply-To: <878s6kqydj.fsf@yoctocell.xyz> (Xinglu Chen's message of "Thu, 18 Mar 2021 16:23:36 +0100") Message-ID: <87h7l7p1gp.fsf@dismail.de> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=78.46.223.134; envelope-from=jbranso@dismail.de; helo=mx1.dismail.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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, RCVD_IN_DNSWL_MED=-2.3, 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: , 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=1616170365; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=BMBAyfecAZaACPjUaP6p9n6DJOHJv3AbkcJo6ubSPtM=; b=KCTuWIwLUVB8a6qRcV3CGW4Zou24iyionXoahEykbmzlmjUovTRzPDfNKPbzNbo4uhdup4 VFDyeuBJzn29Nlegow/lE7dJZpP7kM/BMvlB1+MXVZEslvg68txYdsFINo3vHZb7xWD0mh 2XK4O0xRdmX1cY7VplPXjT9ubc1G0ueT7UVzvHFTvsbdCqCFLvldy7LczVPA/nSEWeVvWr Szbn8uzIMRXNe+zoCKAxDCM5Q0B5ZD7hbuaWd5eXMDCP1eejhcHcsmTqRZjqrUD3jPZ/PZ Vi1XLR0/tC/O/Np2EtfZLwLgvaxLr8v2Rb1QfpAK8is0pxmad3MoFBrsgT4geA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1616170365; a=rsa-sha256; cv=none; b=supW4Dk+MMmplDOEr1LU39Txjc+i9RtdazDAg/kIbNiC0UgKzSBds6hpnkl23+qmm7eThv AteurdcRBN8K7ONT6DRSJj+Tv40fSrg3bLvZ0PxpbOFCeQz63K19GPtHdUtHZiT4aIJPM3 BrM6wzqTVb8K6h5I7+QBcCYCyYsZVrwFyz1nEre3vlUZc36KBuYZ7TGsUv/wIj4+R61RNl N4en8wGckatUyiikEnonQDQfEpIrbegaSoPsaPgtChxAf0/snDRCAw7A7UyhjYmiB6OOa1 nGPvyOm4Lf5o9YSdlP4tpE6R5mcoCkBtKAw16I9n/qhKr/0Rmi5qGT+yC6oBag== ARC-Authentication-Results: i=1; aspmx2.migadu.com; dkim=pass header.d=dismail.de header.s=20190914 header.b="YIh7sz/7"; dmarc=pass (policy=reject) header.from=dismail.de; spf=pass (aspmx2.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.11 Authentication-Results: aspmx2.migadu.com; dkim=pass header.d=dismail.de header.s=20190914 header.b="YIh7sz/7"; dmarc=pass (policy=reject) header.from=dismail.de; spf=pass (aspmx2.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: 4486D1D3B3 X-Spam-Score: -3.11 X-Migadu-Scanner: scn0.migadu.com X-TUID: h/QZ/FtYrlR6 Xinglu Chen writes: > 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. Please note that I am a guix documentation contributor, and I am not quite a guix developer yet. :) Though I do have a patch pending on http://issues.guix.gnu.org/39136 (not certain why the 2/2 patch does not show, 'cause I saw that come through in my inbox). > > 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. I believe that the first method via define-record-type* seems to be the recommended method to do this. I only say that because I feel like more services are defined that way now. :) > 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 do like that generate-documentation procedure. Perhaps we could add that for the define-record-type* somehow... > > 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. You might try asking in irc in #guix too! I've been working on a sway service and an endlessh service in my hacking videos (https://video.hardlimit.com/accounts/joshua_branson/video-channels). I was running into issues, where I could compile the service, but trying to reconfigure my system would result in errors. The errors messages were a little vague. I will also say that the better method I have found in writing a guix service is to 1) write the service as simply as possible first. I personally would copy the simplest service that you can find in gnu/services/ and modify that via a M-x anzu-query-replace-regexp. If re-configuring works, make a commit. 2) If possible, containerize the service. If it works, make a commit. 3) Now start adding in all the features you left out before. -- Joshua Branson (joshuaBPMan in #guix) Sent from Emacs and Gnus https://gnucode.me https://video.hardlimit.com/accounts/joshua_branson/video-channels https://propernaming.org "You can have whatever you want, as long as you help enough other people get what they want." - Zig Ziglar