From mboxrd@z Thu Jan 1 00:00:00 1970 From: ludo@gnu.org (Ludovic =?utf-8?Q?Court=C3=A8s?=) Subject: Re: Channel dependencies Date: Mon, 15 Oct 2018 11:41:17 +0200 Message-ID: <87pnwbim2q.fsf@gnu.org> References: <877eimnxpq.fsf@mdc-berlin.de> 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]:33643) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gBzNI-0006yD-CT for guix-devel@gnu.org; Mon, 15 Oct 2018 05:41:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gBzNH-0005jn-8M for guix-devel@gnu.org; Mon, 15 Oct 2018 05:41:20 -0400 In-Reply-To: <877eimnxpq.fsf@mdc-berlin.de> (Ricardo Wurmus's message of "Sat, 13 Oct 2018 08:54:09 +0200") 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: Ricardo Wurmus Cc: guix-devel@gnu.org Hello! Ricardo Wurmus skribis: > the attached patch allows channel authors to declare other channels as > dependencies of their own channel. In addition to explicitly requested > channels, =E2=80=9Cguix pull=E2=80=9D will now also download and build ch= annels that > have been declared as dependencies in the file =E2=80=98.guix-channel=E2= =80=99 in the > repository root. > > An example of a simple .guix-channel file is this: > > (channel > (version 0) > (dependencies > (channel > (name guix-bimsb) > (url "https://github.com/BIMSBbioinfo/guix-bimsb")))) > > What do you think? I think that=E2=80=99s great. :-) > From 1783c17582906df970c7e68e89d761619a35caeb Mon Sep 17 00:00:00 2001 > From: Ricardo Wurmus > Date: Sat, 13 Oct 2018 08:39:23 +0200 > Subject: [PATCH] guix: Add support for channel dependencies. > > * guix/channels.scm (%channel-meta-file): New variable. > (channel-meta, channel-instance-dependencies): New procedures. > (latest-channel-instances): Include channel dependencies. > (channel-instance-derivations): Build derivation for additional channels = and > add it as dependency to the channel instance derivation. > * doc/guix.texi (Channels): Add subsection "Declaring Channel Dependencie= s". [...] > +(define (channel-meta instance) > + "Return an S-expression read from the channel INSTANCE's description f= ile, > +or return #F if the channel instance does not include the file." > + (let* ((source (channel-instance-checkout instance)) > + (meta-file (string-append source "/" %channel-meta-file))) > + (and (file-exists? meta-file) > + (call-with-input-file meta-file read)))) As a general pattern, I=E2=80=99d suggest declaring reco= rd type along with a =E2=80=98read-channel-metadata=E2=80=99 procedure that ta= kes care of =E2=80=9Cparsing=E2=80=9D and metadata version handling. That way parsing = code is in just one place and the rest of the code can happily deal with well-formed records. > +(define (channel-instance-dependencies instance) > + "Return the list of channels that are declared as dependencies for the= given > +channel INSTANCE." > + (or (and=3D> (assoc-ref (channel-meta instance) 'dependencies) > + (lambda (dependencies) > + (map (lambda (item) > + (let ((get (lambda* (key #:optional default) > + (or (and=3D> (assoc-ref item key) car= ) default)))) > + (let ((name (get 'name)) > + (url (get 'url)) > + (branch (get 'branch "master")) > + (commit (get 'commit))) > + (and name url branch > + (channel > + (name name) > + (branch branch) > + (url url) > + (commit commit)))))) > + dependencies))) > + '())) I=E2=80=99d recommend =E2=80=98match=E2=80=99 for the outer sexp, and then = something like the =E2=80=98alist-let*=E2=80=99 macro from (gnu services herd) in places where= you=E2=80=99d like to leave field ordering unspecified. Then I think it would make sense to add the =E2=80=98dependencies=E2=80=99 = field to directly (and keep internal.) Each element of the =E2=80=98dependencies=E2=80=99 field would be another . Actually =E2=80=98dependencies=E2=80=99 could be a promise that reads chann= el meta-data and looks up the channel instances for the given dependencies. Something like that. Thoughts? Chris raises interesting issues. I think it=E2=80=99s OK to first come up = with an implementation that has some limitations but works with the simple use cases we have in mind. Thanks for working on it! Ludo=E2=80=99.