From mboxrd@z Thu Jan 1 00:00:00 1970 From: ludo@gnu.org (Ludovic =?utf-8?Q?Court=C3=A8s?=) Subject: Re: Services can now have a default value Date: Thu, 20 Apr 2017 10:42:50 +0200 Message-ID: <87bmrr4ghh.fsf@gnu.org> References: <87shl9qo7h.fsf@gnu.org> <877f2go3wn.fsf@zancanaro.id.au> <877f2gksbs.fsf@gnu.org> <8737d32abz.fsf@zancanaro.id.au> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:41259) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d17g1-0004Tv-7i for guix-devel@gnu.org; Thu, 20 Apr 2017 04:42:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d17fy-0008GE-0s for guix-devel@gnu.org; Thu, 20 Apr 2017 04:42:57 -0400 In-Reply-To: <8737d32abz.fsf@zancanaro.id.au> (Carlo Zancanaro's message of "Thu, 20 Apr 2017 10:26:24 +1000") List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: "Guix-devel" To: Carlo Zancanaro Cc: guix-devel Hi Carlo, Carlo Zancanaro skribis: >> There are two issues here: >> >> 1. The default values here are redundant with those we also specify in >> . >> >> 2. The =E2=80=98-service=E2=80=99 procedures are a bit opaque. For th= ings like >> =E2=80=98modify-services=E2=80=99, we want to expose the fact that = we have service >> objects with an associated value, rather than >> hide it inside a procedure. >> >> For these reasons, I=E2=80=99ve been progressively suggesting that we av= oid >> =E2=80=98-service=E2=80=99 procedures altogether, and deprecate the exis= ting ones. >> There are still many of them though, as you write; we should remove >> them (patches welcome! easy task for a GuixSD newcomer! :-)). > > Could we create a mapping from configuration -> service-type? Or somehow > embed the service-type inside the configuration record? (I prefer the > former.) That way we could specify our service list as a list of > configurations without having to doubly-specify the services. > > So then instead of > > (service foo-service-type > (foo-configuration (foo #f) > (number 42))) > > we could have: > > (foo-configuration (foo #f) > (number 42)) > > and have the foo-service-type implicitly looked up when instantiating > the services. There must be some sort of a mapping between service types and configuration types, indeed, but I=E2=80=99m not sure how to achieve it. One solution would be to have all the records inherit (in the OO sense) from , or something along these lines. Or we could make =E2=80=9Cstruct vtables=E2=80=9D and then m= ake instances of those vtables (info "(guile) Vtables"). I=E2=80=99d rather avoid using those interfaces, though (currently the only record API we use is SRFI-9.) Or we could have a =E2=80=98define-service=E2=80=99 macro that defines both= the and the , and defines a =E2=80=98foo-serv= ice=E2=80=99 macro equivalent to (service foo-service-type (foo-configuration =E2=80=A6)= ). (define-service-type openssh-service-type openssh-service (extensions =E2=80=A6) (configuration (port openssh-service-port (default 22)) (use-pam? openssh-service-use-pam? (default #t)))) and then: (operating-system ;; =E2=80=A6 (services (cons (openssh-service (port 2222)) %base-services))) Thoughts? >> The default value thing in this thread is about making the =E2=80=98serv= ice=E2=80=99 >> form less verbose and closer to what we had with =E2=80=98-service=E2=80= =99 >> procedures. > > Yeah, okay. I guess I just saw the change and felt like it doesn't > actually change much. Having a default value saves you a bit of typing, > but only in the case where you don't want to change any configuration > for the service. > > The other thing that it would buy you (which is more significant) is the > ability to create services that are required for service extensions, but > which aren't listed in the operating-system's services. I assume we > don't want to do that, though, because that could be > dangerous/surprising. I=E2=80=99m not sure what you mean. Is it something like what =E2=80=98sim= ple-service=E2=80=99 does? >> Does that clarify things? > > Yes, thanks! Are there discussions somewhere that I can read about how > this came together? I don't think I've been on the list long enough to > have seen it myself (or if I have, I can't find them). It all started with the new service API, which introduced service types and service objects: https://lists.gnu.org/archive/html/guix-devel/2015-09/msg00608.html The specific issue we=E2=80=99re discussing hasn=E2=80=99t received much at= tention though, but it=E2=80=99s been discussed a few times as people were adding n= ew service definitions. Thanks, Ludo=E2=80=99.