Subject: bug#26652: [PATCH 1/2] profiles: Add manifest->packages.

From: Maxim Cournoyer <[email-masked]>
Date: Wed, 26 Apr 2017 01:47:12 +0900

Hi Mathieu!

Mathieu Othacehe <[email-masked]> writes:

> * guix/profiles.scm (manifest->packages): New exported procedure.
> ---
>  guix/profiles.scm | 10 ++++++++++
>  1 file changed, 10 insertions(+)
>
> diff --git a/guix/profiles.scm b/guix/profiles.scm
> index eb172ef45..157445407 100644
> --- a/guix/profiles.scm
> +++ b/guix/profiles.scm
> @@ -8,6 +8,7 @@
>  ;;; Copyright © 2016 Chris Marusich <[email-masked]>
>  ;;; Copyright © 2017 Huang Ying <[email-masked]>
>  ;;; Copyright © 2017 Maxim Cournoyer <[email-masked]>
> +;;; Copyright © 2017 Mathieu Othacehe <[email-masked]>
>  ;;;
>  ;;; This file is part of GNU Guix.
>  ;;;
> @@ -94,6 +95,7 @@
>              profile-manifest
>              package->manifest-entry
>              packages->manifest
> +            manifest->packages
>              ca-certificate-bundle
>              %default-profile-hooks
>              profile-derivation
> @@ -203,6 +205,14 @@ denoting a specific output of a package."
>            (package->manifest-entry package)))
>          packages)))
>  
> +(define (manifest->packages manifest)
> +  "Return the list of packages in MANIFEST."
> +  (delete-duplicates
> +   (filter-map (lambda (entry)
> +                 (let ((item (manifest-entry-item entry)))
> +                   (if (package? item) item #f)))
> +               (manifest-entries manifest))))
> +
>  (define (manifest->gexp manifest)
>    "Return a representation of MANIFEST as a gexp."
>    (define (entry->gexp entry)

The filter-map part seems problematic, IIUC. You might end up with an
`#f' in your list of packages, no? Maybe you could use something like:

(delete-duplicates
 (filter package? (map manifest-entry-item (manifest-entries manifest))))

Disclaimer: I haven't tested it.

Maxim