From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id 7eKOGh1zrGP0JgAAbAwnHQ (envelope-from ) for ; Wed, 28 Dec 2022 17:47:25 +0100 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id gEKNGR1zrGN6HwEAauVa8A (envelope-from ) for ; Wed, 28 Dec 2022 17:47:25 +0100 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 105B89205 for ; Wed, 28 Dec 2022 17:47:24 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pAZZy-0000iC-Bz; Wed, 28 Dec 2022 11:46:58 -0500 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 ) id 1pAZZs-0000hm-9c for guix-devel@gnu.org; Wed, 28 Dec 2022 11:46:52 -0500 Received: from smtpm2.myservices.hosting ([185.26.105.233]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pAZZo-00059q-Ap for guix-devel@gnu.org; Wed, 28 Dec 2022 11:46:50 -0500 Received: from mail1.netim.hosting (unknown [185.26.106.172]) by smtpm2.myservices.hosting (Postfix) with ESMTP id 01A9520D1E for ; Wed, 28 Dec 2022 17:46:33 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by mail1.netim.hosting (Postfix) with ESMTP id B411080096 for ; Wed, 28 Dec 2022 17:46:33 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at mail1.netim.hosting Received: from mail1.netim.hosting ([127.0.0.1]) by localhost (mail1-1.netim.hosting [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id 1QCpTGnU3GcC for ; Wed, 28 Dec 2022 17:46:33 +0100 (CET) Received: from [192.168.1.239] (unknown [10.192.1.83]) (Authenticated sender: lumen@makinata.eu) by mail1.netim.hosting (Postfix) with ESMTPSA id 5278880093 for ; Wed, 28 Dec 2022 17:46:33 +0100 (CET) Message-ID: Date: Wed, 28 Dec 2022 16:46:32 +0000 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.6.0 Content-Language: en-US To: guix-devel@gnu.org From: mirai Subject: Expanding service procedure to accept additional arguments Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Received-SPF: pass client-ip=185.26.105.233; envelope-from=mirai@makinata.eu; helo=smtpm2.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 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: guix-devel@gnu.org X-Mailman-Version: 2.1.29 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-bounces+larch=yhetil.org@gnu.org X-Migadu-Country: US X-Migadu-Flow: FLOW_IN ARC-Seal: i=1; s=key1; d=yhetil.org; t=1672246044; a=rsa-sha256; cv=none; b=XuvFxmkZb5UpEj6d/DYkBpaQjIi4qXJVazO0u3B4dzzhXwZdp0HxGsT49jAgYc0hGgctsA /sqAFMk0Hh5jriccFXkeMQbsu9Jw2uZtzZGvbpnAPJ2tuPLOHQZtTBIwD1qwg1bv/i/wyZ H+jPbd2Q2Qfkm/J6UUNEETjleOPToeCNhhok5hL6OIMFifR1QiozFeUdT1JVUW4xkCcsTi 2xiJkWMimcBWSEJUUaOrMjTaOUOFMjse5aCB5xvKWFcPGfHCt2jRUv4b71H7sJLdPYW8xp FgC8oiOvbN87YxJYc59I/NBOgbKTY1eHfoEill89R3212WPTbvtG6F8oS6WtAQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; spf=pass (aspmx1.migadu.com: domain of "guix-devel-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-devel-bounces+larch=yhetil.org@gnu.org"; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1672246044; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=j+jBEQWz+D4RmZTbgtCN0FxXLuPRbR2dG0MIhXgSM5Y=; b=TV6t2d7FJk0y4/5xqa/Da6Ykmqbuz5tcRW9e6QmjJgn1eYcx1kFr2EryUWU6ymi1DV/r06 4tKGxA74NfXXnAyydnY+AnfFtYEWSLpiqwG/m/J85HYTOxpnm16wCyk96MDdCfl5bOUP1F RbhE9iGbx+nL11dbl2+8oYzeeTFT2xbg0sglvcEqKm6g38rPJ5ToO2vOx0UtnA3NZcw0Wr cWY7HcNezY+XZK2zRu6i1YdLNjdfX/HFGTVKhTUKOpMi/XMTdoZ+OFUO277f18wdjREJfy ppK9jDAC70SzCh0Dm56D2SPjjIfh0fQBU/tEkpAsgY66jeCXHDgwK62prUukfQ== X-Spam-Score: -3.13 X-Migadu-Queue-Id: 105B89205 Authentication-Results: aspmx1.migadu.com; dkim=none; spf=pass (aspmx1.migadu.com: domain of "guix-devel-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-devel-bounces+larch=yhetil.org@gnu.org"; dmarc=none X-Migadu-Scanner: scn0.migadu.com X-Migadu-Spam-Score: -3.13 X-TUID: nDft3MFMo4fK It is occasionally desired to have a service depend on additional shepherd services than the defaults listed in their definition. Examples where this can be seen is the shepherd-requirement field provided by nginx-configuration and opensmtpd-configuration, but these fields are record-type specific and not available for the other service types (unless patched in). An alternative to patching the original record-type is to define a custom service-type record-type and inheriting it which is somewhat clunky for what amounts to a setup-specific single line change: --8<---------------cut here---------------start------------->8--- (shepherd-service ... - (requirement `(...)) + (requirement `(... ,@shepherd-requirement)) --8<---------------cut here---------------end--------------->8--- Another type of extensibility that should be considered is the capability to add extra service-extensions to existing service-type records. These can be useful for setup-specific (i.e. not applicable in general to be included with Guix) scenarios, for example, to add an extra activation-service-type extension or have a special-files-service-type extension that the service-type usually does not have. The current approach that I'm aware of to achieve something similar is through simple-service, drawbacks being extra boilerplate code and a "disjoint" service whose connection to the "parent service" is not immediately apparent. --8<---------------cut here---------------start------------->8--- ;; Ideally this should go in radicale-service-type (simple-service 'chmod-radicale shepherd-root-service-type (list (shepherd-service (requirement '(user-homes)) (provision '(radicale-home)) (documentation "chmod g+rwx to user 'radicale' home.") (one-shot? #t) (start #~(lambda _ (chmod (passwd:dir (getpw "radicale")) #o770) #t))))) --8<---------------cut here---------------end--------------->8--- Instead, what if the service procedure could be changed to accept optional keyword arguments? Then one could express the extensions and dependencies as: --8<---------------cut here---------------start------------->8--- (services (service foo-service-type #:requirements '(networking nscd smtpd) #:extensions (list (service-extension bar-service-type (lambda _ ...)) (service-extension activation-service-type (lambda _ ...)))) --8<---------------cut here---------------end--------------->8--- Thoughts? Regards, Bruno