From mboxrd@z Thu Jan 1 00:00:00 1970 From: ludo@gnu.org (Ludovic =?utf-8?Q?Court=C3=A8s?=) Subject: Re: Proposal: prefetch tarballs in a batch Date: Thu, 10 Apr 2014 10:21:31 +0200 Message-ID: <87vbuhbnn8.fsf@gnu.org> References: <87ha6jkyv8.fsf@karetnikov.org> <877g7epico.fsf@gnu.org> <87wqf8prau.fsf@karetnikov.org> <87ha6blwii.fsf@gnu.org> <87d2gznysk.fsf@karetnikov.org> <87vbuqvpsc.fsf@gnu.org> <87ha62dtmh.fsf@karetnikov.org> 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]:46804) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WYAEt-0004SL-7Z for guix-devel@gnu.org; Thu, 10 Apr 2014 04:21:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WYAEn-0002hZ-Ln for guix-devel@gnu.org; Thu, 10 Apr 2014 04:21:39 -0400 Received: from hera.aquilenet.fr ([2a01:474::1]:42135) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WYAEn-0002hU-6i for guix-devel@gnu.org; Thu, 10 Apr 2014 04:21:33 -0400 In-Reply-To: <87ha62dtmh.fsf@karetnikov.org> (Nikita Karetnikov's message of "Thu, 10 Apr 2014 02:29:26 +0400") 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-bounces+gcggd-guix-devel=m.gmane.org@gnu.org To: Nikita Karetnikov Cc: guix-devel@gnu.org Nikita Karetnikov skribis: > So, in order to add a tarball to the store, one can write: > > $ ./pre-inst-env guile > scheme@(guile-user)> ,use (guix store) (guix packages) (guix derivations)= (gnu packages wget) > scheme@(guile-user)> (define s (open-connection)) > scheme@(guile-user)> (package-source-derivation s (package-source wget)) > $1 =3D # /gnu/store/qz9vm8802v6pi69ci2kgnvfivrkr085r-wget-1.15.tar.= xz 1922cd0> > scheme@(guile-user)> (build-derivations s (list $1)) > $2 =3D #t > scheme@(guile-user)> (file-exists? (derivation->output-path $1)) > $3 =3D #t > > And to get a list of inputs (including the implicit ones): > > scheme@(guile-user)> ,use (srfi srfi-26) > scheme@(guile-user)> (for-each (cut format #t "~a~%" <>) (derivation-inpu= ts (package-derivation s wget))) > #< path: "/gnu/store/divcaakxh5zhgpkih3paxb6znmnpbzhw-g= uile-2.0.11.drv" sub-derivations: ("out")> > #< path: "/gnu/store/jf4hzf16akk7bjidpr6im3wamfnr5rpv-w= get-1.15.tar.xz.drv" sub-derivations: ("out")> > #< path: "/gnu/store/rx5kn39gcc0vm4hwr81kcwpxgybx2yay-p= erl-5.16.1.drv" sub-derivations: ("out")> Yup, but note that the you don=E2=80=99t need to actually build the derivat= ion to traverse it (IOW the =E2=80=98build-derivations=E2=80=99 call is not nee= ded.) > I=E2=80=99m planning to do the same for every input. But a couple of thi= ngs are > not clear: > > 1. Should the recursion stop when =E2=80=98fixed-output-derivation?=E2=80= =99 returns #t? I think so. In general fixed-output derivations are the things you would like to pre-fetch; so you would typically call =E2=80=98build-derivat= ions=E2=80=99 on these to do the actual pre-fetching. > 2. I=E2=80=99d like to use =E2=80=98package-source-derivation=E2=80=99 (s= ee above) in order to > get a tarball. Is it possible to get a type from > ? If not, what are my options? No: as the manual so nicely says ;-), =E2=80=9Cderivations are to package definitions what assembly is to C programs.=E2=80=9D What I would imagine is something like: (define (derivations-to-prefetch store drv) "Return the list of fixed-output derivations that DRV depends on, directly or indirectly." ...) And then you would just pass the result of this procedure to =E2=80=98build-derivations=E2=80=99, which would download anything not alre= ady present. Does that make sense? Ludo=E2=80=99.