From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id AIQ1MjgVQ2FDTAEAgWs5BA (envelope-from ) for ; Thu, 16 Sep 2021 11:58:16 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id WCD6LTgVQ2E7WQAAB5/wlQ (envelope-from ) for ; Thu, 16 Sep 2021 09:58:16 +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 E739914D51 for ; Thu, 16 Sep 2021 11:58:15 +0200 (CEST) Received: from localhost ([::1]:41342 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mQo9n-0004ac-2X for larch@yhetil.org; Thu, 16 Sep 2021 05:58:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38100) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQo92-00048H-UM for guix-devel@gnu.org; Thu, 16 Sep 2021 05:57:29 -0400 Received: from mail-lf1-x131.google.com ([2a00:1450:4864:20::131]:35347) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mQo8v-0003EQ-Ik for guix-devel@gnu.org; Thu, 16 Sep 2021 05:57:26 -0400 Received: by mail-lf1-x131.google.com with SMTP id m3so14405919lfu.2 for ; Thu, 16 Sep 2021 02:57:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=trop-in.20210112.gappssmtp.com; s=20210112; h=from:to:subject:in-reply-to:references:date:message-id:mime-version; bh=Wnv6Bf6P6/fT+ONbL+a3ox+IKma56xpmTiAmEzggzno=; b=AyLEXVEShHDrf+XLr074kLEdKOVaZ8KimtlksrinS3MX3Kvx3wefB7aN7jXvnd6XX+ X/Vtc2ZB/UDJEzjdOjefIeYqtYe+uFFb74iIPHviHJFzZrH4QGJiJS1LtwxdLLxHt7Qt 7viuD1XYVBPWV5XVi62qVwhtU8iJXdKL69sxcIX3JcJpsWyqbQB3Io5T6ACRzs9usu7f cQF3Hze73KrXuRhWBxt1/apBo4XjqXfzTpxCjjeouHWxjDFyWaqzcpENdo2tLVC/CWu+ jG5giwMdMIwjubJyLoviHl5XhskNWZrIT4oZwSFocav8PQmO1xZNJbu48ii7cjC/iYq2 mQug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:in-reply-to:references:date :message-id:mime-version; bh=Wnv6Bf6P6/fT+ONbL+a3ox+IKma56xpmTiAmEzggzno=; b=vI29JNlPI/zKga4Qd9DzcFrfPMQ0RIDTDgoceoJsln/olC6LtN/M+pww49fhOF8UFf 7xoOoChjb7dyaeoLqnNYi0RW1F5CtidI6kqCqqNP34G3l/b3/QKj52/Fl0RJtXWuLy21 O0Ar27DG2yTJyz1jCmHjeZR/8Tytc4CO5xNOOIi+vUIb8ZB2t9Q57cvOBD4dfVoWys5u CkEqTi1x0gU5oD4ShSsyqPXdB06FH8FsnAfqMbHUfQW74CXY44tQn8VacqgmV6PiG4NM aE4t22PR9Yyd4u6wUG4sQRu1IKFt8ecn2LYJSvUiwGyA2OYbjS+luRpv3TX3Nmng1kbZ Vx5Q== X-Gm-Message-State: AOAM532KkL5qj0hG4EKfIPnLwwBb5F1z8opQb48PeDD7010TZf/KnkAg 0I0Kjq0rAa3Sd8EtSOmBnDhojBNWKU80kg== X-Google-Smtp-Source: ABdhPJwluZcUmqqrCcFi1n9XPdsNxucZ7tB9mKaxE0btCKPYSVty2bYOh/J8040wO81gsJf2L0cFEQ== X-Received: by 2002:ac2:4bc1:: with SMTP id o1mr3481823lfq.116.1631786238846; Thu, 16 Sep 2021 02:57:18 -0700 (PDT) Received: from localhost ([109.252.93.92]) by smtp.gmail.com with ESMTPSA id z3sm218568lfh.18.2021.09.16.02.57.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Sep 2021 02:57:18 -0700 (PDT) From: Andrew Tropin To: Xinglu Chen , guix-devel@gnu.org Subject: Re: On the naming of System and Home services modules. In-Reply-To: <87pmtarnrh.fsf@yoctocell.xyz> References: <87zgsei5ta.fsf@trop.in> <87pmtarnrh.fsf@yoctocell.xyz> Date: Thu, 16 Sep 2021 12:57:14 +0300 Message-ID: <87zgscx2px.fsf@trop.in> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" Received-SPF: none client-ip=2a00:1450:4864:20::131; envelope-from=andrew@trop.in; helo=mail-lf1-x131.google.com X-Spam_score_int: 0 X-Spam_score: 0.0 X-Spam_bar: / X-Spam_report: (0.0 / 5.0 requ) DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=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=1631786296; 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:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=Wnv6Bf6P6/fT+ONbL+a3ox+IKma56xpmTiAmEzggzno=; b=crHGNVK22ZFahPa5qj2S/s+qSv/yJ8NdBl8TyEyTXcl1TeSxaU07QbqEkGVkj4bf9Rp9Ct /fx+Ob/zIae5pfxTGu+dKQ53kf/FyVXlB3syOPUzahrDLcvW7Ipu+BZLm5rhBhjuzYMYqM mAH+ELTc+dvrYjxrqydK1g9kXrXbMf2FN0Wb8o7fxWgxfYog2OsjCdjOh6ywlNqn/PNIdY vXAPs/dWKr3FBvZusRQX3tiNkmfznCS9uVKIByvPkt9ThxWwRbZyii+O+DQLTzlFvc3cSI SSpGZyFrfDjw+KhLbQvdu1blFEQOAku1V4/5QAAUMeqbW+4BIwb+vquFXZk/Ig== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1631786296; a=rsa-sha256; cv=none; b=ZJsR8QnXqcZxv/w/SsELwA3KQ7ihoIJPNpC2DY1ooRGusVs+zTaUmyOhJXpPGJ2RxfjIcD +5FxjgJnkJ9fP0DztR0EoQqtwtFRee2oMO08aTGJ7NPW5ETQ79RhrT/VseG03BNMdlWSUC jbKL55bzmIEPTEMuQ3Nv2AQm+TvHpMQb32E3MjbWLm9i+ijbjyeBWuC+dYgj37z5oXnQ26 YTacJ8DdMOHPOL3NjrLo4V5/bOOC2BN90ztbPHG47o2oFAsHqxmNXDggz/sLUe14UrarnR HkgWfCR45SlPm/P0pboK3Xdzf0zm10HU5fZyo6vayut6/FEoi4/MyN/xv5w/xQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=trop-in.20210112.gappssmtp.com header.s=20210112 header.b=AyLEXVES; dmarc=none; 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: -4.70 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=trop-in.20210112.gappssmtp.com header.s=20210112 header.b=AyLEXVES; dmarc=none; 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: E739914D51 X-Spam-Score: -4.70 X-Migadu-Scanner: scn1.migadu.com X-TUID: 38HIRlP1jIfz --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 2021-09-15 15:06, Xinglu Chen wrote: > On Wed, Sep 15 2021, Andrew Tropin wrote: > >> This topic was raised a few times during development of Guix Home >> project and also during the review of wip-guix-home branch. I made a >> separate thread to do an exhaustive discussion of it. >> >> * Services and Confusion >> It's an optional section, you can skip it, but I still find it somehow >> related to the topic. >> >> I want to re-raise the issue related to system services concept. When >> I started using Guix I found system services to be confusing, >> originally I thought it's a way to declare services managed by init >> system, but later I realised that only some of system services becomes >> Shepherd services and many of them doesn't. It's not a unique problem >> I see this issue appear again and again in different Guix chats and >> communities. >> >> - System services :: just building blocks, nodes of DAG representing >> a system, which after folding, results in a complete operating system >> or other artifact. >> - Shepherd services :: long-living processes/daemons managed by init >> system or user-space Shepherd. It's what people used to refer as service= s. >> >> It will be very hard and costly to rename system services to something >> less confusing, but at least let's try to keep those concepts as >> distinct as possible. Probably originally system and Shepherd >> services were closely related, but not now, so let's express it very >> clearly in docs/chats/mailing lists. >> >> Another player on this field is "home services", which is a similar to >> system services, but used for describing a separate DAG, which after >> folding, results in home environment (artifact containing user's >> program configurations and profile with packages declared by user). >> >> * Putting Home Services to ~(gnu services ...)~ >> In the thread https://issues.guix.gnu.org/49419#18 Ludovic suggested: >> >>> Regarding module names: what about putting everything in the (gnu >>> home =E2=80=A6) name space. For services, I wonder if we could simply = use >>> (gnu services home), for the essential services, and other (gnu >>> services =E2=80=A6) module, but that assumes some code can be shared be= tween >>> System and Home. Thoughts? >> >> ** Shortcomings >> While it's a nice idea, I see some shortcomings here: >> >> *** Code Reuse >> Mcron, Shepherd and a few other fundamental pieces are reused between >> Guix Home and Guix System, but it's easily done by exporting a few >> symbols from related modules. >> >> Records even for the same services have slightly different fields and >> because of macro nature can't be reused between Home and System >> services. In more details I mentioned this problem here: >> https://lists.sr.ht/~abcdw/rde-devel/%3C87y2cqifpx.fsf%40yoctocell.xyz%3= E#%3C878s4l8kai.fsf@trop.in%3E > > Some services might be useful to have in both Guix System and Guix Home; > for instance, Guix System currently has a service for configuring > Syncthing, and I think it makes sense to also have one for Guix Home, > this would mean that people not using Guix System (me :-)) could also > have Guix manage Syncthing. With the current approach, we would have to > copy and paste quite a bit of code, and if the Syncthing service for > Guix System changes, then the one for Guix Home might have to change as > well. > We can extract parts, which have to be in sync between home service and system service and just use them in both. I don't see how placing home service in the same module will decrease the amount of "copy-paste". If you talk about "shared" fields for configuration records, it's probably true, but I don't see any good solution yet. I'm unhappy that records are implemented with macros, because it complicates the extensibility of the mechanism, wrapping them in more macros doesn't make thing better IMO. >=20 > I have thought about a =E2=80=98define-configuration=E2=80=99 macro that = would > generate one configuration record for Guix system and optionally, one > for Guix Home. For example > > (define-configuration syncthing-configuration > ...) > > would work as it currently does, and > > (define-configuration syncthing-configuration > ... > (home-service? #t)) > > would generate a record and a > record. > > There is the problem of and > not having the same fields. To solve > this, Each clause could have an =E2=80=98home-service?=E2=80=99 field, an= d the code > would look like > > (define-configuration syncthing-configuration > (package > (package syncthing) > "Syncthing package to use.") > (arguments > (list-of-strings =E2=80=99()) > "Command line arguments to pass to the Syncthing package.") > (log-flags > (integer 0) > "Sum of logging flags.") > (user > (maybe-string 'disabled) > "The user as which the Syncthing service is to be run." > (home-service? #f)) ; not for Guix Home > (group > (string "users") > "The group as which the Syncthing service is to be run." > (home-service? #f)) ; likewise ^^ > (home > (maybe-string 'disabled) > "Common configuration and data directory.") > (home-service? #t)) > > This would mean that would have all the > fields, but would have all but the =E2=80= =98user=E2=80=99 > and =E2=80=98group=E2=80=99 fields. > > We could also have a =E2=80=98define-home-configuration=E2=80=99 macro th= at would create > a record and optionally, a > record. Then =E2=80=98home-service?=E2=80=99 would = be > =E2=80=98system-service?=E2=80=99 instead. > > Maybe it=E2=80=99s too complicated and not worth it, but it=E2=80=99s jus= t an idea I > have had. > define-configuration is already a quite complicated macro, but maybe something like that will work, still unhappy with tons of macros for implementing records in scheme (: > >> The intersection of home and system services should be very low, so >> there is not much benifit here as well. > > Quite the opposite, I think it would be great if home and system > services could integrate more with each other. The system and home services can't really integrate with each other at least because of extension mechanism. > In NixOS, the NixOS modules and Home Manager modules feel like two > very distinct things, and it=E2=80=99s not really easy to share things be= tween > them. > Yes, but with Guix System and Guix Home it's easier to keep them in sync and share code between them because they are both a part of the same repo. Going back to intersection: Yes, there are some services that are common to Guix Home and System: mcron, shepherd and maybe a few more, but most of the `guix system search .` is not relevant for user. Everything that can be implemented as a home service should implement as a home service in most cases. There are two case, where you can bring an argument against it, but I'll propose solutions upfront: =2D As admin I want to add a service in operating-system, but it's only available as a home service. I think we can do something like that:=20=20 #+begin_src scheme (operating-system (services (list (service guix-home `(("USERNAME1" ,(generate-home-environment with-needed-services))))))) #+end_src =2D I want to start the home service on boot. Probably, something like linger systemd will be needed here for Shepherd, still seems very possible to implement. https://www.freedesktop.org/software/systemd/man/loginctl.html#enable-linge= r%20USER%E2%80%A6 Yes, probably there are cases where we will need to have both system and home services, but I expect this number to be very low and everything else will fall in one category of services, this is what I mean by small intersection. As an exercise try to name 10 services, which doesn't belong to only one category. >=20 > A while ago, someone on IRC mentioned that it would be nice to have > Mcron in Guix System run Mcron jobs that were specified in Guix Home. > The rationale is that Guix Home for a user will not activate---run > user Shepherd, thus running Mcron---until that user logs in. This > means that Bob=E2=80=99s Mcron jobs will only run when Bob is logged in. = The > Mcron jobs in specified in Guix System will run regardless if the user > that those jobs belong to logs in. But if Bob wants their Mcron jobs > to run regardless if he logs in, he needs root access to be able to > add jobs to his Guix System config and run =E2=80=98guix system reconfigu= re=E2=80=99. > This does mean that the sysadmin has to add =E2=80=98mcron-service-type= =E2=80=99 to > the =E2=80=98services=E2=80=99 field of the record, th= ough. > Covered by linger idea mentioned above. The downside is it won't be visible in root's herd cli, but it also fixable either by extending shepherd or by using su to run herd from specific user. >> Utilitary functions like serialization helpers and so on can be >> declared in a shared module and reused between System and Home >> services. >> >> Recaping the section: All the necessarry code already reused, the >> future home/system services are not expected to share much code, >> different utilitary functions can be shared via (gnu services utils) >> or (gnu services configuration) modules. >> >> *** Confusion >> I already mentioned that I see a lot of confusion between System and >> Shepherd services and I expect some confusion between home and system >> services, it will be especially true if we place them in the same >> namespace. >> >> People will be trying to use home services inside operating systems, >> #+begin_src scheme >> (operating-system >> (services >> (list (service home-mcron-service-type ...)))) >> #+end_src >> >> and configuration record for system services inside home services. >> #+begin_src scheme >> (home-environment >> ... (service home-mcron-service-type >> (mcron-configuration ...))) >> #+end_src > > With the above proposal, the user would use =E2=80=98home-mcron-configura= tion=E2=80=99 > for home service, so I don=E2=80=99t think this should be a problem. And= as > Maxime mentioned, we could have a =E2=80=98validate=E2=80=99 field which = would give a > friendly error message if the wrong configuration record was given. > >> ** Summary >> Let's keep System and Home services separate for the sake of clarity, >> reuse code via shared modules or just exports in (gnu services ...). >> >> * Putting Home Services to ~(gnu home services ...)~ >> Another idea I saw is to move: >> ~(gnu home-services)~ -> ~(gnu home services)~ >> ~(gnu home-services gnupg)~ -> ~(gnu home services gnupg)~ >> ... >> >> Sounds reasonable, I'll just mention the ideas behind ~home-services~ >> name. >> >> System services have following naming conventions for the public API: >> >> in ~(gnu services CATEGORY)~ there are ~APP-service-type~, >> ~APP-configuration~ and other related symbols. >> >> Not to be confused, I decided to prefix all service types and >> configurations with ~home-~, so the exported symbols looks like: >> ~home-APP-service-type~ and ~home-APP-configuration~. >> >> The same rule applies for module names: We do the same way as system >> services do, but with ~home-~ prefix: ~(gnu services CATEGORY)~ for >> system, ~(gnu home-services CATEGORY)~ for home. >> >> All namespaces containing ~system~ now becomes ~home~: ~(gnu system)~ and >> ~(gnu home)~ respectively. >> >> I find such approach to be consistent and doesn't see to much reasons >> to change it. >> >> However, ~(gnu home services ...)~ also looks cool, but it would be a >> little inconsistent with system services, which will have one level of >> nestiness less: ~(gnu services)~. >> >> IMO, ~(gnu home services ...)~ would be a good choice if we use ~(gnu >> system services)~ for system services. > > Yeah, having both (gnu system service) and (gnu home service) could make > sense, but since we only have (gnu services), I don=E2=80=99t think it ma= kes > much sense. > Just to clarify, by ..., I meant submodules, so it will be (gnu system services version-control) and (gnu home services version-control) for example. For now it's just: (gnu services version-control) and (gnu home-services version-control), which I find okeish. > >> * Conclusion >> I'm quite satisfied with current state of naming, but probably I miss >> some points and, also, maybe there are some other good or even better >> naming schemes. In case there is a better naming approach, we can >> decide on using it, It would be not an easy change, but until >> wip-guix-home branch is not merged, it still easier to do this than do >> it later. >> >> LMKWYT. --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEKEGaxlA4dEDH6S/6IgjSCVjB3rAFAmFDFPoACgkQIgjSCVjB 3rC9cA//TdE47TnrPlmbbDnSrmDmbdY44k9kCyqIiOQ3XtajwzbPdszyobPRTHB4 PEgYxqnD3JgtV97HWZZQ3lHS6I36HcJ0Hx3t2TB3gO7w/VFTf2Pdbdvl7MB85IWB zr1aWN6aMOiUzez4XoZNUjnZfK4oHX9hAF7ykH0BUtit2ezQMecPF7ntpnp2xf69 f3kBbGXBbWqxc3sHkF4Afh7Aq0p/mVvL/yVZ59RjgrbpkkjnLFdQPeXCmlabMA7e CF8P0d34KWbSzxUo/AhMned03favsIfAaV0QE+ZRGQVJH+KDOK5RRr6lwqxSCsJB VeLMVCJd6HrESufmTtdGYA2uoIn13wk5FEvZ8ch7CcgSkUXpx7/IpxkeMNj/e1N7 IsjBFgDOLzFJH0tWYYKCwN1BJ8dfMVaSizNgihMa1k5reZJp637um0PklDBe2gLB Fr7a3RLPDu1FHcLpUBHiG5wnsxdT+Y8ShJgOmxRjJK8YXcxo3TF6GCZRAKBVGIGA i1yOhCn13/pXuiI9fYCDVWxBv9Tkg+riY+tF+pnbc6HWHVySu0ymt0z1ObbYfVO3 GtdkZJ6pZC+YDFJaTVZCAv4VV7N0xhVVBFtNuVFatZ4cVTXzTm0AMwywmV9+68Qi vmwdp7vGFDluBKpQSbwXIw9QkWR6t/YcJhzjNSAWNzPpyH0MFEY= =xGqo -----END PGP SIGNATURE----- --=-=-=--