unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Xinglu Chen <public@yoctocell.xyz>
To: Andrew Tropin <andrew@trop.in>, guix-devel@gnu.org
Subject: Re: On the naming of System and Home services modules.
Date: Sun, 19 Sep 2021 16:54:31 +0200	[thread overview]
Message-ID: <87zgs81uqg.fsf@yoctocell.xyz> (raw)
In-Reply-To: <87zgsb8mfo.fsf@trop.in>

[-- Attachment #1: Type: text/plain, Size: 12601 bytes --]

On Fri, Sep 17 2021, Andrew Tropin wrote:

> On 2021-09-17 11:28, Xinglu Chen wrote:
>
>> On Thu, Sep 16 2021, Andrew Tropin wrote:
>>
>>>>> * 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 …) name space.  For services, I wonder if we could simply use
>>>>>> (gnu services home), for the essential services, and other (gnu
>>>>>> services …) module, but that assumes some code can be shared between
>>>>>> 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%3E#%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.
>>
>> Since we don’t have a way to avoid using macros for records, resisting
>> macros probably won’t really help much.  :-)
>>
>
> The fact that we already use them doesn't mean that we need to use more
> macros, IMO it's a good idea to keep the amount of macros as small as
> possible.
>
>>>> I have thought about a ‘define-configuration’ 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 <syncthing-configuration> record and a
>>>> <home-syncthing-configuration> record.
>>>>
>>>> There is the problem of <syncthing-configuration> and
>>>> <home-syncthing-configuration> not having the same fields.  To solve
>>>> this, Each clause could have an ‘home-service?’ field, and the code
>>>> would look like
>>>>
>>>>   (define-configuration syncthing-configuration
>>>>     (package
>>>>      (package syncthing)
>>>>      "Syncthing package to use.")
>>>>     (arguments
>>>>      (list-of-strings ’())
>>>>      "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 <syncthing-configuration> would have all the
>>>> fields, but <home-syncthing-configuration> would have all but the ‘user’
>>>> and ‘group’ fields.
>>>>
>>>> We could also have a ‘define-home-configuration’ macro that would create
>>>> a <home-NAME-configuration> record and optionally, a
>>>> <NAME-configuration> record.  Then ‘home-service?’ would be
>>>> ‘system-service?’ instead.
>>>>
>>>> Maybe it’s too complicated and not worth it, but it’s just 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’s not really easy to share things between
>>>> 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.
>>
>> Not really sure what you mean by this, but the above proposal would
>> create a <NAME-configuration> and a <home-NAME-configuration> record.
>
> If something can be both home and system service we can prefer to
> implement home service, because it can be used on both Guix System and
> foreign distros.

That could work, but a lot of problems/questions would also pop up; see
some examples below.

> Yes, I got your idea.
>
>>> There are two case, where you can bring an argument against it, but
>>> I'll propose solutions upfront:
>>>
>>> - 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:  
>>>
>>> #+begin_src scheme
>>> (operating-system
>>>   (services
>>>    (list (service guix-home
>>>                   `(("USERNAME1" ,(generate-home-environment
>>>                                    with-needed-services)))))))
>>> #+end_src
>>>
>>> - 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-linger%20USER%E2%80%A6
>>
>> That would be nice to have.
>>
>>> 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.
>>
>> Well, there are quite a few that I can think of
>>
>> * The ones we have already mentioned: Mcron, Shepherd, and Syncthing.
>>
>> * Unattended-upgrade.
>>
>> * Rsync/state management.
>>
>> * guix-publish: As a normal user, I should be able to run a ‘guix
>>   publish’ service, to share substitutes with others, without needing
>>   root access.
>>
>> * Mail related services: Getmail/Fetchmail/Isync can be used by a normal
>>   user for fetching their mail from some remote server.  These programs
>>   can also be used by a server that hosts a Patchwork instance to track
>>   patches sent to a mailing list.  I think this is what Christopher’s
>>   Patchwork instance does.
>>
>>     <https://patches.guix-patches.cbaines.net/project/guix-patches/list/>
>>
>>   Dovecot/OpenSMTP/Exim can be used on a mail server, but they can also
>>   be used as a local IMAP server, which something like Gnus can connect
>>   to.
>>
>>   I have also seen people use Postfix as a Sendmail/Msmtp replacement,
>>   and it would thus make sense to have a Guix Home service for it too.
>>
>> * Alsa: There is already an Alsa service for Guix System, but a user may
>>   also want like to configure their ~/.asoundrc file in order to not
>>   pollute the system configuration.
>>
>> * WeeChat can be used as an IRC client, and as a relay for other WeeChat
>>   clients to connect to.  It would therefore make sense to have WeeChat
>>   running on a server (Guix System), and then connect to it through
>>   WeeChat as a regular user (Guix Home).
>>
>> * Shells: Each individual user will most likely configure their shell,
>>   but the sysadmin also might want the configure the system-wide shell
>>   and not just run with the default settings.
>>
>> There is also the problem of system service only working on Guix System,
>> whereas home services will work on foreign distros as well.  As someone
>> who is on a foreign distro, I would like to configure things like Tor
>> (and Privoxy), Transmission, Ipfs, Bitlbee, and a login manager and a
>> desktop environment.  But right now I have to be on Guix System to
>> configure to these things.
>>
>> That’s just the ones I can think of; other people probably have more
>> things to add.
>>
>
> I think most of this usecases are solvable by having only home services
> and linger shepherd.
>
> For example an administrator can define a home-environment in
> operating-system for weechat-relay user, which contains a WeeChat home
> service, configured as a relay and setup it with `guix system
> reconfigure`.  Any other users can control their own home-environments
> and configure and install their weechat clients with `guix home`

That could work, then one would have to have lots of home environments
if they had many services.  Having a bunch of home environment would
probably introduce quite a bit of overhead, compared to just running a
service as another user.  The configuration would also be quite a bit
more complicated; instead of something like this:

  (operating-system
    (services (list (service dovecot-service-type ...)
                    (service tor-service-type ...)
                    (service weechat-service-type ...))))

It would look something like:

  
  (operating-system
    (services (list (service guix-home
                             `(("dovecot" ,(generate-home-environment ...))
                               ("tor" , (generate-home-environment ...))
                               ("weechat" ,(generate-home-environment ...)))))))

And the user would also have to manually create the “dovecot”, “tor”,
and “weechat” users and groups by extending the ‘account-service-type’.

These services would also start on boot regardless if there is any
internet connection, because the Shepherd for the “dovecot” user isn’t
aware of the networking ‘requirement’, which is only available for Guix
System services.

There is also the problem of what if the Dovecot service, which is a
home service, has to extend something that is not a home service, e.g.,
‘etc-service-type’ or ‘pam-root-service-type’?  ‘home-file-service-type’
can only create files in $HOME of the user, but a file might have to be
put somewhere in /etc, which is out of reach of ‘home-file-service-type’
for the “dovecot” user.

By having a bunch of home-services, something like ‘guix system
extension-graph’ and ‘guix system shepherd-graph’ would be a lot less
useful, since a lot of things would be in home environments.  It would
make it harder for the user to visualize and understand how the system
is built from all of these system services and home-service.

If the Dovecot service became a home service, it would break
backwards-compatiblity and break many peoples setups.


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 861 bytes --]

  reply	other threads:[~2021-09-19 14:54 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-15  8:47 On the naming of System and Home services modules Andrew Tropin
2021-09-15 10:09 ` Maxime Devos
2021-09-15 13:15   ` Andrew Tropin
2021-09-15 13:06 ` Xinglu Chen
2021-09-15 14:50   ` Katherine Cox-Buday
2021-09-16 10:01     ` Andrew Tropin
2021-09-16  9:57   ` Andrew Tropin
2021-09-17  9:28     ` Xinglu Chen
2021-09-17 11:35       ` Andrew Tropin
2021-09-19 14:54         ` Xinglu Chen [this message]
2021-09-23 20:08   ` Ludovic Courtès
2021-09-24  8:08     ` Andrew Tropin
2021-09-28 12:17       ` Ludovic Courtès
2021-09-24 13:35     ` Code sharing between system and home services (was Re: On the naming of System and Home services modules.) Xinglu Chen
2021-09-24 14:03       ` Maxime Devos
2021-09-24 15:39         ` Xinglu Chen
2021-09-24 17:02           ` Maxime Devos
2021-09-28 12:19           ` Ludovic Courtès
2021-09-28  6:03         ` Andrew Tropin
2021-09-24 15:32       ` Joshua Branson
2021-09-28 12:21         ` Ludovic Courtès
2021-09-29 13:52           ` Maxime Devos
2021-10-02 14:27             ` Ludovic Courtès
2021-10-02 22:13               ` Code sharing between system and home services Vagrant Cascadian
2021-10-04 14:34                 ` Ludovic Courtès
2021-10-03  8:45               ` Code sharing between system and home services (was Re: On the naming of System and Home services modules.) Maxime Devos
2021-10-04 14:32                 ` Ludovic Courtès
2021-10-04 16:14                   ` Maxime Devos
2021-10-06 13:12                     ` Ludovic Courtès
2021-09-28  2:32       ` Maxim Cournoyer
2021-09-16  3:05 ` On the naming of System and Home services modules Ryan Prior
2021-09-16  8:50   ` Andrew Tropin
2021-09-17 13:43     ` pinoaffe
2021-09-23 20:10 ` Ludovic Courtès
2021-09-28  6:32   ` Andrew Tropin
2021-09-28 12:26     ` Ludovic Courtès
2021-09-28 13:48       ` Andrew Tropin
2021-09-28 19:36         ` Oleg Pykhalov
2021-10-02 14:22           ` Ludovic Courtès
2021-10-02 17:23             ` Oleg Pykhalov
2021-09-28 15:25       ` Xinglu Chen
2021-10-02 14:25         ` Ludovic Courtès

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87zgs81uqg.fsf@yoctocell.xyz \
    --to=public@yoctocell.xyz \
    --cc=andrew@trop.in \
    --cc=guix-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).