From mboxrd@z Thu Jan 1 00:00:00 1970 From: ludo@gnu.org (Ludovic =?utf-8?Q?Court=C3=A8s?=) Subject: Re: guix environment Date: Tue, 03 Feb 2015 21:29:16 +0100 Message-ID: <87k2zypwmb.fsf@inria.fr> References: <87egqpyvov.fsf@gnu.org> <87lhkldwfs.fsf@izanagi.i-did-not-set--mail-host-address--so-tickle-me> 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]:58201) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YIk6B-0003mi-DD for guix-devel@gnu.org; Tue, 03 Feb 2015 15:29:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YIk6A-0008EB-Cz for guix-devel@gnu.org; Tue, 03 Feb 2015 15:29:27 -0500 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: David Thompson Cc: Guix-devel , bug-guix@gnu.org, Federico Beffa David Thompson skribis: > Ludovic Court=C3=A8s writes: > >> On closer inspection, I see two issues: >> >> (define (packages->transitive-inputs packages) >> "Return a list of the transitive inputs for all PACKAGES." >> (define (transitive-inputs package) >> (filter-map (match-lambda >> ((_ (? package? package)) package) >> (_ #f)) ; <---- ! >> (bag-transitive-inputs >> (package->bag package)))) >> (delete-duplicates >> (append-map transitive-inputs packages))) >> >> Here only inputs of the form ("foo" PKG) are considered; things like >> ("glib" ,glib "bin") are discarded. >> >> (define (for-each-search-path proc inputs derivations pure?) >> (let ((paths (map derivation->output-path derivations))) ; <-- ! >> [...] >> >> Above, =E2=80=98derivation->output-path=E2=80=99 considers only the =E2= =80=9Cout=E2=80=9D output, >> ignoring others if they are needed. > > Here's a patch. WDYT? > > > From 9609806fb78557d74cf5b3fb47802898ef9d1ecf Mon Sep 17 00:00:00 2001 > From: David Thompson > Date: Thu, 29 Jan 2015 17:53:17 -0500 > Subject: [PATCH] guix: environment: Consider all package outputs. > > * guix/scripts/environment.scm (for-each-search-path): Iterate over all > derivation output paths. > (packages->transitive-inputs): Process inputs that specify an output, t= oo. [...] > --- a/guix/scripts/environment.scm > +++ b/guix/scripts/environment.scm > @@ -40,7 +40,12 @@ > Use the output paths of DERIVATIONS to build each search path. When PUR= E? is > #t, the existing search path value is ignored. Otherwise, the existing = search > path value is appended." > - (let ((paths (map derivation->output-path derivations))) > + (let ((paths (append-map (lambda (drv) > + (map (match-lambda > + ((_ . output) > + (derivation-output-path output))) > + (derivation-outputs drv))) > + derivations))) > (for-each (match-lambda > (($ > variable directories separator) > @@ -177,7 +182,9 @@ packages." > "Return a list of the transitive inputs for all PACKAGES." > (define (transitive-inputs package) > (filter-map (match-lambda > - ((_ (? package? package)) package) > + ((or (_ (? package? package)) > + (_ (? package? package) _)) > + package) > (_ #f)) LGTM, please push! There=E2=80=99s another problem, though. When a dependency is a multiple-o= utput package, all its outputs are added to the environment, because =E2=80=98package->transitive-inputs=E2=80=99 discards the information of wh= ich output is needed. So for instance, both the =E2=80=98out=E2=80=99 and the =E2=80=98debug=E2= =80=99 output of Coreutils end up being downloaded and added to the environment, even though only =E2=80= =98out=E2=80=99 is an input. Now, the problem is that =E2=80=98build-derivations=E2=80=99 can only build= *all* the outputs of the given derivation. This could be worked around either: 1. by creating a =E2=80=9Csink=E2=80=9D derivation, for instance with =E2=80=98profile-derivation=E2=80=99, that could refer precisely to th= e output(s) needed; not ideal. 2. by using (build-things (list "/the/output/path")) and resorting to =E2=80=98build-derivations=E2=80=99 only if the =E2=80=98build-things= =E2=80=99 call did nothing (when passed a non-.drv store item, =E2=80=98build-things=E2=80=99 tri= es to substitute and does nothing if that fails.) Thoughts? Ludo=E2=80=99.