bug-guix
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#19641: guix environment


From: Ludovic Courtès
Subject: bug#19641: guix environment
Date: Tue, 03 Feb 2015 21:29:16 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux)

David Thompson <address@hidden> skribis:

> Ludovic Courtès <address@hidden> 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, ‘derivation->output-path’ considers only the “out” output,
>> ignoring others if they are needed.
>
> Here's a patch.  WDYT?
>
>
> From 9609806fb78557d74cf5b3fb47802898ef9d1ecf Mon Sep 17 00:00:00 2001
> From: David Thompson <address@hidden>
> 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, too.

[...]

> --- 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 PURE? 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
>                 (($ <search-path-specification>
>                     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’s another problem, though.  When a dependency is a multiple-output
package, all its outputs are added to the environment, because
‘package->transitive-inputs’ discards the information of which output is
needed.

So for instance, both the ‘out’ and the ‘debug’ output of Coreutils end
up being downloaded and added to the environment, even though only ‘out’
is an input.

Now, the problem is that ‘build-derivations’ can only build *all* the
outputs of the given derivation.  This could be worked around either:

  1. by creating a “sink” derivation, for instance with
     ‘profile-derivation’, that could refer precisely to the output(s)
     needed; not ideal.

  2. by using (build-things (list "/the/output/path")) and resorting to
     ‘build-derivations’ only if the ‘build-things’ call did nothing
     (when passed a non-.drv store item, ‘build-things’ tries to
     substitute and does nothing if that fails.)

Thoughts?

Ludo’.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]