unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Guix shepherd user services
@ 2019-02-10 15:02 Pierre Neidhardt
  2019-02-10 17:21 ` Gábor Boskovits
  0 siblings, 1 reply; 9+ messages in thread
From: Pierre Neidhardt @ 2019-02-10 15:02 UTC (permalink / raw)
  To: Guix-devel; +Cc: alex.ter.weele, Ludovic Courtès

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

I've been thinking about shepherd user services.

We just had a discussion on the topic:

	https://lists.gnu.org/archive/html/help-guix/2019-02/msg00010.html

and an interesting patch was sent a while ago:

	https://lists.gnu.org/archive/html/guix-devel/2018-02/msg00047.html.

Jelle first introduced me to this idea during the Guix days and it took
me a while to understand why it's pure awesomeness.  In short: just like
we can fully configure an operating-system in Guile and we don't have to
touch /etc manually, we could do the same with our user profile.  At
last, done with .bashrc / .profile to start user daemons, cron jobs,
whatever synchronization script you use...

It would also make it possible to fully _initialize_ a user profile (just like
we initialize the operating-system) with the desired files.  For instance, a
service could synchronize git repositories (e.g. your dotfiles), deploy it,
synchronize your emails, generate the mlocate cache, snapshot some btrfs drives,
you name it.

As a result, on a Guix install it would be possible to run

	guix service --install -f my-services.scm

let the magic happen, relog(?) et enjoy a 100% pre-configured user
profile.  How cool is that?

Benefits over traditional dotfiles or cron jobs:

- No more need for .xinitrc, .local/bin, etc.

- Declarative and uniformly programmable in Guile.

- Every service is uniformly controllable (start, restart, stop, status, etc.).
  It's not so convenient to do that with a daemon that was started from .xinitrc.

- Drags non-propagated inputs automatically, no need to polute the user profile
  (e.g. with redshift, xcape, etc.)

- Pre-configured services to choose from, as provided by Guix (unlike mcron).


My thoughts regarding the implementation design:

- Services can be enabled, disabled, started, restarted, stopped, listed,
  they can show details and documentation, they can run pre-defined actions.
  They are semantically very different from packages (in fact they often use
  packages, but not always).  I don't think it would be good to mix and match
  services and packages in a command like `guix package --list-installer`.  So I
  suggest we keep them separate.

- The user must be able to build and install services.  We could have the
  following behaviour then:

  `guix service --build redshift` would produce a
  /gnu/store/...-shepherd-redshit.scm

  `guix service --install redshift` would install it to ~/.guix-profile/services/redshift.scm.

  `guix service --remove redshift` would remove it from the above location.

  `guix service --upgrade=redshift` would rebuilt the service (and maybe
  redshift) and install the new version.

- How do we write custom services?  Well, just like we write custom packages and
  custom operating-system, in a channel or in GUIX_PACKAGE_PATH (which name
  becomes less and less meaningful).

- How do we update services (e.g. the redshift service when the redshift package
  just got updated)?  My understanding is that services are citizens similar to
  operating system declarations: they depend on the current Guix version and the
  user-defined definitions (e.g. channels).
  Then `guix pull && guix service --upgrade` will do.

- How do we start the user shepherd on login and load the service configuration?
  We need to be cautious to support foreign distributions.  On GuixSD, we could
  arrange /etc/profile to run

    shepherd --config ~/.guix-profile/service-manifest.scm

  on login.  On foreign distributions, users can add the above command to
  ~/.profile, or ~/.bashrc, etc.

- If the package manifest and the service manifest are separate, it follows that
  we now have 2 parameters to "reproducibly" define a user profile.  I think
  that's fine and it allows for composition (mix and match service manifests and
  package manifests).

- Currently I think it's not possible to just define shepherd services without
  enabling them.  Thus it's not possible to have a list of available services
  just like we have a list of packages.  While this might be OK for the system
  (but is it?), I think it would be nice if, as a user, we could do a

      guix service --list-available

  and pick services from there.  This is somewhat a separate issue but
  it would be nice to solve it.  I don't know enough about the shepherd
  internals to go into the details here.

- Should Guix drive the services with a `guix service` subcommand or should we
  leave it to `herd` run by the user?  Since we use `herd` for system services,
  I think it's more consistent to stick to `herd`.

I'd like to work on it with anyone interesting on the topic.  I know
some people I've worked on it before, so feel free to share your
progress :)

--
Pierre Neidhardt
https://ambrevar.xyz/

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

^ permalink raw reply	[flat|nested] 9+ messages in thread
* Re: Guix shepherd user services
@ 2019-04-29 19:57 Tanguy Le Carrour
  2019-04-29 20:10 ` Tobias Geerinckx-Rice
  0 siblings, 1 reply; 9+ messages in thread
From: Tanguy Le Carrour @ 2019-04-29 19:57 UTC (permalink / raw)
  To: Guix

Hello Guix!

I've just read this thread [1] on the archive and I think it would be a
great feature! Any update on the topic?!

[1]: https://lists.gnu.org/archive/html/guix-devel/2019-02/msg00132.html

I would love to have some services started when I log in (tor,
transmission-daemon, mpd, gpg-agent… you name them!) without having to
rely on the root user and system configuration.

One other nice thing would be to have something like systemd timers [2]
to replace cron jobs. I use them to run things like mbsync and vdirsyncer.

[2]: https://wiki.archlinux.org/index.php/Systemd/Timers

I'm not sure that I'm able to write any (good) Guile code, but I can read
some and discuss things, if that helps!

Regards


-- 
Tanguy

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2019-05-08  7:30 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-10 15:02 Guix shepherd user services Pierre Neidhardt
2019-02-10 17:21 ` Gábor Boskovits
2019-02-10 18:22   ` Pierre Neidhardt
  -- strict thread matches above, loose matches on Subject: below --
2019-04-29 19:57 Tanguy Le Carrour
2019-04-29 20:10 ` Tobias Geerinckx-Rice
2019-05-01  9:00   ` Tanguy Le Carrour
2019-05-04  7:07     ` Tanguy Le Carrour
2019-05-04 11:45       ` Tobias Geerinckx-Rice
2019-05-08  7:30         ` Tanguy Le Carrour

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).