From debbugs-submit-bounces@debbugs.gnu.org Thu Jun 01 05:57:19 2017 Received: (at 27155) by debbugs.gnu.org; 1 Jun 2017 09:57:20 +0000 Received: from localhost ([127.0.0.1]:48453 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dGMr1-0003s3-MN for submit@debbugs.gnu.org; Thu, 01 Jun 2017 05:57:19 -0400 Received: from mail-lf0-f50.google.com ([209.85.215.50]:33969) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dGMqz-0003ro-Td for 27155@debbugs.gnu.org; Thu, 01 Jun 2017 05:57:18 -0400 Received: by mail-lf0-f50.google.com with SMTP id 99so23406010lfu.1 for <27155@debbugs.gnu.org>; Thu, 01 Jun 2017 02:57:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:message-id:user-agent :mime-version:content-transfer-encoding; bh=oy3dGzxzxZZsMS1BL4xalpItj1i4M5dtuizfYqWuixM=; b=hhyKOcinljTN4iKJDdlIzGoKlUBpvPLD2269/ly3wh5LVyBcAnKjo0NX+D3Am02EgP I1rSVRQKYPv896kVjB3fJUsCHq8CTFIa1vOaLMOvERwIgZC2UmE2rW3zVfWGuVKgKnzl jtwcl8WTKWdugdX4q2d50tSYXDCXnDOX4NLVSCN6cRV4Di9YM9VoB3vFxAv1P2BxqXaQ 3W6uZsebfoPsMkMmQp9BNMUGFT24tTkTIb2JPsVeXCsm7vU7ZFjS1Taj8DTb0qSXJ7Sh DUt/xyOJbN5kT6HnYbuR06v+bCTKkb1TRp78wEOA+wcfR69D2HeSHhYlYj7Dcs71S1fY yB9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:message-id :user-agent:mime-version:content-transfer-encoding; bh=oy3dGzxzxZZsMS1BL4xalpItj1i4M5dtuizfYqWuixM=; b=fQu0WkoL1UNo/mKJvtA9tniHltnIyPepnYoHxVdfb1wlFJ4/hPQxow6IUmK94qySP5 SlTGMw0DJ8gLIe9TrI4tmHQu0WBqL78xcQaZnGb8ZMBE695Ok4b0q/DLtfnpkYXj+tJK XBoq9nWMvCbtSKdyW++TuUxpPPrH9lElTn4TkUnwk5oan7ArsRj57whiySrTDr4sBfEs NVp86CgNl2Krm0zH8OiZW86aGSAA4ZyheKm+5h+GXdh0vUXQKslLKfr7e7mYgBHB1BFE j333RkMy0GJj12eUpDovG0WfOK2YGH33Ta9RYBiOnnlZ8LKUTsu87AQpsWVpugp/YgeE LV7Q== X-Gm-Message-State: AODbwcBUlQU1FFpbc+Urb4HHhVGSNSzJAeIgd39VqsVRF2bFi1AAoQBo 9InHyX0qonTBzThm X-Received: by 10.46.69.8 with SMTP id s8mr241360lja.55.1496311031621; Thu, 01 Jun 2017 02:57:11 -0700 (PDT) Received: from leviafan ([217.107.194.134]) by smtp.gmail.com with ESMTPSA id v30sm4205842ljd.9.2017.06.01.02.57.10 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 01 Jun 2017 02:57:10 -0700 (PDT) From: Alex Kost To: Ludovic =?utf-8?Q?Court=C3=A8s?= Subject: Re: bug#27155: [PATCH 0/2] Support service extensions on the "final" service values References: <20170530215850.7522-1-ludo@gnu.org> Date: Thu, 01 Jun 2017 12:57:09 +0300 Message-ID: <8760ggrpxm.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.5 (/) X-Debbugs-Envelope-To: 27155 Cc: 27155@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.5 (/) Ludovic Court=C3=A8s (2017-05-30 23:58 +0200) wrote: > 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. Definitely! > 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. This is great! Just what I wanted, and thanks for this example! Based on it, I made the following service: (define replace-etc/profile-type (let ((replace (lambda (file entries) (cons `("profile" ,file) (map (match-lambda ((name . rest) (cons (if (string=3D name "profile") (string-append "original-profile") name) rest))) entries))))) (service-type (name 'replace-etc/profile) (extensions (list (service-extension etc-service-type (const '()) replace)))))) (service replace-etc/profile-type (local-file ".../my-system-profile")) So now I can use my own "/etc/profile", moreover I can look at the "/etc/original-profile" anytime. I already use a system with this service and I enjoy it, thanks a lot! > The first patch currently lacks doc. I'll work on it if there's consensus > on the approach. I agree with this approach! --=20 Alex