all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Ludovic Courtès" <ludo@gnu.org>
To: 27155@debbugs.gnu.org
Cc: Alex Kost <alezost@gmail.com>
Subject: bug#27155: [PATCH 0/2] Support service extensions on the "final" service values
Date: Tue, 30 May 2017 23:58:50 +0200	[thread overview]
Message-ID: <20170530215850.7522-1-ludo@gnu.org> (raw)

Hello!

This patch adds support for service extensions that modify the
"final" values of a service.  This is meant to implement cross-cutting
concerns as well as system-wide customization as discussed with Alex
long ago:

  https://lists.gnu.org/archive/html/guix-devel/2015-11/msg00623.html
  https://lists.gnu.org/archive/html/guix-devel/2016-09/msg01505.html

To summarize, a "finalization extension" (for lack of a better name)
gets the final value of a service and returns a new value for that
service.  This is in contrast with a "normal" extension which can only
contribute to the value of a target service, and not inspect the value
of that target service.

For example, for the /etc service, a "normal" extension can only add
entries for /etc.  A "finalization" extension can instead inspect and
change all the /etc entries.  IOW, it is a sort of a "sudo" for service
extensions; it's also quite inelegant compared to the "normal" extension
mechanism, but it's certainly useful.

A use case is given in the second patch: we change all the PAM services
to use pam_elogind.so or pam_limits.so.  Likewise, the 'rename-etc-files'
service below shows how to rename all the files in /etc (for illustration
purposes only :-)):

  (define rename-etc-files
    (let ((rename (lambda (prefix entries)
		    (map (match-lambda
			   ((name . rest)
			    (cons (string-append prefix name)
				  rest)))
			 entries))))
      (service-type
       (name 'rename-etc-files)
       (extensions (list (service-extension etc-service-type
					    (const '())
					    rename))))))


  (operating-system
    ;; ...
    (services (cons* (service rename-etc-files "foo-")
                     ...)))

I think this should fulfill the need that Alex had expressed, which is
to not only be able to add files to /etc, but also to have the ability
to inspect and modify what goes to /etc.

The first patch currently lacks doc.  I'll work on it if there's consensus
on the approach.

Feedback welcome!

Ludo'.

Ludovic Courtès (2):
  DRAFT services: Extensions can specify a "finalization" procedure.
  system: pam: Remove custom API to transform PAM services.

 gnu/services.scm         | 52 ++++++++++++++++++++++++++++++++++++++----------
 gnu/services/base.scm    | 33 ++++++++++++++++--------------
 gnu/services/desktop.scm | 23 +++++++++++----------
 gnu/system/pam.scm       | 44 ++++++++--------------------------------
 tests/services.scm       | 34 +++++++++++++++++++++++++++++++
 5 files changed, 114 insertions(+), 72 deletions(-)

-- 
2.13.0

             reply	other threads:[~2017-05-30 22:00 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-30 21:58 Ludovic Courtès [this message]
2017-05-30 22:05 ` bug#27155: [PATCH 1/2] DRAFT services: Extensions can specify a "finalization" procedure Ludovic Courtès
2017-05-30 22:05   ` bug#27155: [PATCH 2/2] system: pam: Remove custom API to transform PAM services Ludovic Courtès
2017-06-01  9:57 ` bug#27155: [PATCH 0/2] Support service extensions on the "final" service values Alex Kost
2017-06-01 11:24   ` Ludovic Courtès
2017-06-03 21:21 ` Ludovic Courtès
2017-06-04 14:26   ` Alex Kost
2017-06-05 10:06     ` Ludovic Courtès
2017-06-05 12:52 ` Ricardo Wurmus
2017-06-06 23:07   ` Ludovic Courtès
2017-06-15 17:12     ` [bug#27155] " 宋文武
2017-06-21 13:06       ` 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

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

  git send-email \
    --in-reply-to=20170530215850.7522-1-ludo@gnu.org \
    --to=ludo@gnu.org \
    --cc=27155@debbugs.gnu.org \
    --cc=alezost@gmail.com \
    /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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.