unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: ludo@gnu.org (Ludovic Courtès)
To: guix-devel@gnu.org
Subject: Re: Service refactoring
Date: Sun, 20 Sep 2015 17:42:47 +0200	[thread overview]
Message-ID: <87a8shp05k.fsf@gnu.org> (raw)
In-Reply-To: <87vbbn44zi.fsf_-_@gnu.org> ("Ludovic \=\?utf-8\?Q\?Court\=C3\=A8s\?\= \=\?utf-8\?Q\?\=22's\?\= message of "Sun, 06 Sep 2015 23:23:13 +0200")

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

Currently that ’wip-service-refactor’ contains a first implementation of
the “service DAG”.  So far I only “converted” services in (gnu services
base); modulo the yet-to-be-converted services, it looks like this:


[-- Attachment #2: the service hierarchy --]
[-- Type: image/png, Size: 73921 bytes --]

[-- Attachment #3: Type: text/plain, Size: 2791 bytes --]


“Service” here has a much broader meaning than before.

There’s a service for PAM services, one for user accounts, one for dmd
services, one for /etc entries, one for activation snippets, and finally
the “boot” service.

The PAM root service collects PAM services produced by lshd, mingetty,
etc. and turns them into ‘pam.d’ entry for /etc; the /etc service takes
such entries and turns them into a gexp that calls ‘activate-etc’.
Likewise, the guix-daemon service passes user accounts and groups to the
account service, which turns that into an activation snippet.

The nice thing is that it allows us to express things that were not
possible before, and increases separation of concerns.  For instance,
the ‘account’ service takes care of everything related to user accounts
in a single place, whereas before this would be entangled in (gnu
system); ditto for PAM services.

The API defines <service-type>, <service-extension>, and <service>.  The
“service type” defines how services of this type are “extended” and/or
how services of this type extend other services:

  (define dmd-root-service-type
    (service-type
     (name 'dmd-root)
     ;; Extending the root dmd service (aka. PID 1) happens by concatenating the
     ;; list of <dmd-service> provided by the extensions.
     (extend concatenate)
     (extensions (list (service-extension (target boot-service-type)
                                          (compute dmd-boot-gexp))))))

  (define guix-service-type
    (service-type
     (name 'guix)
     (extensions
      (list (service-extension (target dmd-root-service-type)
                               (compute guix-dmd-service))
            (service-extension (target account-service-type)
                               (compute guix-accounts))
            (service-extension (target activation-service-type)
                               (compute guix-activation))))))

The service procedures used in OS declarations can usually remain
unchanged, written like this:

  (define* (guix-service #:optional (config %default-guix-configuration))
    (service (type guix-service-type)
             (parameters config)))

There can be several services of a given type.  However, there must be
only one service of a type that can be extended–for instance, there can
be only one service of type ‘dmd-root-service-type’ or
‘etc-service-type’.

The ‘fold-services’ procedure is passed a list of services, propagates
extensions, and returns the root service (typically ‘%boot-service’)
with its ‘parameters’ field changed accordingly.

I’m quite happy with the result, but comments are welcome!  I’ll convert
some more services to see how it goes.

Ludo’.

  parent reply	other threads:[~2015-09-20 15:52 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-03 21:23 [PATCHES] Get elogind-service working as intended Mark H Weaver
2015-09-04  7:57 ` Andy Wingo
2015-09-06 21:23   ` Service refactoring Ludovic Courtès
2015-09-08  8:47     ` Andy Wingo
2015-09-08 10:12       ` Ludovic Courtès
2015-09-08 10:33         ` Andy Wingo
2015-09-08 14:48     ` Mark H Weaver
2015-09-10 16:05       ` Ludovic Courtès
2015-09-10 16:14       ` Ludovic Courtès
2015-09-20 15:42     ` Ludovic Courtès [this message]
2015-09-21  8:18       ` Andy Wingo
2015-09-21 16:00         ` Ludovic Courtès
2015-09-24  0:33           ` Thompson, David
2015-09-24  7:41             ` Ludovic Courtès
2015-09-24  9:33               ` 宋文武
2015-09-24 17:09                 ` Ludovic Courtès
2015-09-25 22:50               ` Christopher Allan Webber
2015-09-26 12:50                 ` Ludovic Courtès
2015-09-30  8:59       ` Ludovic Courtès
2015-10-10 21:01         ` Ludovic Courtès
2015-09-10 16:03 ` [PATCHES] Get elogind-service working as intended 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=87a8shp05k.fsf@gnu.org \
    --to=ludo@gnu.org \
    --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).