From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms9.migadu.com with LMTPS id QA3rA39XJGRILgEASxT56A (envelope-from ) for ; Wed, 29 Mar 2023 17:21:35 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id WCHtAn9XJGT+egAAG6o9tA (envelope-from ) for ; Wed, 29 Mar 2023 17:21:35 +0200 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 CA2FDBF8F for ; Wed, 29 Mar 2023 17:21:34 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1phXbr-0007FV-MQ; Wed, 29 Mar 2023 11:21:11 -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 ) id 1phXbq-0007FG-Bb for guix-devel@gnu.org; Wed, 29 Mar 2023 11:21:10 -0400 Received: from smtpmciv1.myservices.hosting ([185.26.107.237]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1phXbo-0006i1-5h; Wed, 29 Mar 2023 11:21:09 -0400 Received: from mail1.netim.hosting (unknown [185.26.106.173]) by smtpmciv1.myservices.hosting (Postfix) with ESMTP id 505A520D58; Wed, 29 Mar 2023 17:21:03 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by mail1.netim.hosting (Postfix) with ESMTP id CBF358009A; Wed, 29 Mar 2023 17:21:03 +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 c6dWjh4-o5st; Wed, 29 Mar 2023 17:21:03 +0200 (CEST) Received: from [192.168.1.239] (unknown [10.192.1.83]) (Authenticated sender: lumen@makinata.eu) by mail1.netim.hosting (Postfix) with ESMTPSA id C54D180098; Wed, 29 Mar 2023 17:21:02 +0200 (CEST) Message-ID: <07fc2e40-7e23-a7cb-469d-95aae6614ff5@makinata.eu> Date: Wed, 29 Mar 2023 16:21:02 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.9.0 Subject: Re: Automatically mapping services from System to Home Content-Language: en-US To: =?UTF-8?Q?Ludovic_Court=c3=a8s?= , Sergey Trofimov Cc: 62401@debbugs.gnu.org, paren@disroot.org, andrew@trop.in, guix-devel@gnu.org References: <20230323081026.13850-1-sarg@sarg.org.ru> <87edp8g88j.fsf@gnu.org> From: Bruno Victal In-Reply-To: <87edp8g88j.fsf@gnu.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=185.26.107.237; envelope-from=mirai@makinata.eu; helo=smtpmciv1.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, NICE_REPLY_A=-0.001, 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-Flow: FLOW_IN X-Migadu-Country: US 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=1680103294; 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; bh=dZ3Bm2eUX3IJl+UFyboHmXc7s7Iw5HWDECQxovL+2Qc=; b=eOPqkUFLh4NHcz12dkH1QqmhIKh5WDee8qtRPp8kp0GDEwjRXN4gNjaLXNyE2OSfFFEH/2 /6XHyf+N2LehG+elYTvG24Pm2sqExD2qWCk4/4mwMlEH1XJ0Q8cWKX6jVdcvcFDShuQI/c rCa6WOwmYIFpUpUvKead48py8BdXOXicCONrHVfUkyGCviFsCw290AiaYc+IuzACsflfLl wNHk6jk3Zzbs91NB4NSUEdtQRq3hiRFmz3vKbw3oC1Zc0kJ9cSv36/Oys5oZiTo+20AUli yyHsjQTkyNxwZ6Jm4RppQe8PBlRAD8geGdWHsCN6KjF0WwecHXDOyn0gxtuGxQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1680103294; a=rsa-sha256; cv=none; b=tugC5T4tTAh+MeSjrbExf9kUL66qBGjXDdQiyCO5aiiweh+SWxsCfXnqJ6B+kNnXzXfaxx nDxw8mMQk90f1jKN76Te6tv/MGc6P0QdARDyUEZoBmqU7DJK3iNGaFKwwGv123/HvXZ0jw 9///ZwRkEJVtga9AA0nhEOXYQ99svC9dw9wxlyOtxY753F7d0y8KE3a6bdknP0dRiO3pEn 9L3W5rE0coCmj+y/e7XhNEojSWWEDxnBy0neFU4FmOm3pKMmGwSo1yonvFVh4U/Ii2QiXr bYESLhBfmsJSoVOJnjRbQK3p0RWMtWk/a1c0W+tEX+HZxV0ouGLL0UJ8+1lx8g== X-Migadu-Spam-Score: -1.53 X-Migadu-Scanner: scn1.migadu.com X-Migadu-Queue-Id: CA2FDBF8F 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-Spam-Score: -1.53 X-TUID: wLW+CJJ5yjYf Hi Ludo’, On 2023-03-28 17:18, Ludovic Courtès wrote: > One idea I toyed with is automatic translation of service types from > System to Home. The service itself would look like this: > > --8<---------------cut here---------------start------------->8--- > (define-module (gnu home services syncthing) > #:use-module (gnu home services) > #:use-module (gnu services syncthing) > #:export (home-syncthing-service-type) > #:re-export (syncthing-configuration > syncthing-configuration?)) > > (define home-syncthing-service-type > (system-service-type->home-service-type syncthing-service-type)) > --8<---------------cut here---------------end--------------->8--- > > The code to do that is attached below. The key here is that we’d define > mappings, like: > > (define-service-type-mapping > shepherd-root-service-type => home-shepherd-service-type) > > The rest of the service type graph would be automatically constructed > from this. > > I feel like it would be worth pursuing this path so that there’s as > little duplication as possible between Home and System. > > OTOH, it doesn’t take care of things like #:user in > ‘make-forkexec-constructor’ calls and the like. > I've been thinking that shepherd services should, in general, come with a preamble in their configuration record-types. (perhaps à la SRFI-136 parent-style records?) Below is a non-exhaustive list of “things” that should almost always be configurable, unless it's reasonable to omit it: --8<---------------cut here---------------start------------->8--- ;; These fields were listed based on “experience” in reworking, ;; repurposing and adding new (system) services within Guix. (define-configuration example-configuration ;; Allow the package to be overridden. (package file-like "Lorem ipsum …") ;; Note that they're not strings. This allows for tailoring ;; the user-account used by the service (e.g. adding extra groups ;; for the daemon to have access to other directories, etc. (user user-account "Lorem ipsum …") ;; ^^^^^ Ditto. (group user-group "Lorem ipsum …") (shepherd-requirement ; or shepherd-requirements, the former already has some presence in Guix ; but could be phased-out in favor of the plural form list-of-symbols "Lorem ipsum …") ;; Uncommonly seen among services ;; but mpd-service-type is an example where this is important. (environment-variables list-of-env-vars "Lorem ipsum …") --8<---------------cut here---------------end--------------->8--- Tossing another idea in the air, with define-configuration could perhaps be enriched with additional parameters to hint that certain fields should be treated differently depending on “context”? Naturally the service code will have to be adjusted to use these hints, but overall it should result in a much cleaner way to guide serializations and service-extension pruning. It could be something of the sort: --8<---------------cut here---------------start------------->8--- (define-configuration example-configuration … (user user-account "Lorem ipsum …" (attributes 'system-service) …) ;; or (define-configuration example-configuration … (user user-account "Lorem ipsum …" system-only …) ;; or (define-configuration example-configuration … (user user-account "Lorem ipsum …" (system #t) (home #f) …) --8<---------------cut here---------------end--------------->8--- Cheers, Bruno