[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] profiles: Add gtk-icon-themes hook.
From: |
Ludovic Courtès |
Subject: |
Re: [PATCH] profiles: Add gtk-icon-themes hook. |
Date: |
Thu, 21 May 2015 18:33:59 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) |
宋文武 <address@hidden> skribis:
> * guix/profiles.scm (gtk-icon-themes): New function.
> (%default-profile-hooks): Add it.
[...]
> +(define (gtk-icon-themes manifest)
> + "Return a derivation that unions all icon themes from manifest entries and
> +creates the GTK+ 'icon-theme.cache' file for each icon theme."
> + (define (entry-lookup-gtk+ store entry)
> + "Return the GTK+ package or store path referenced by the manifest ENTRY,
> or
> +#f if not referenced."
Please use a comment rather than a docstring for inner defines.
> + ;; Find GTK+ in a list of packages.
> + (define (by-packages packages)
> + (find (lambda (package)
> + (equal? "gtk+" (package-name package)))
> + packages))
> +
> + ;; Find GTK+ in a list of store paths.
> + (define (by-paths paths)
> + (find (lambda (path)
> + (equal? "gtk+"
> + (package-name->name+version
> + (store-path-package-name path))))
> + paths))
> +
> + (match (manifest-entry-item entry)
> + ((? package? package)
> + (by-packages (delete-duplicates
> + (map cadr (package-transitive-inputs package)))))
> + ((? string? path)
> + (by-paths (references store path)))))
This procedure must be turned into a monadic procedure along these
lines (note: by-packages -> find-among-packages, and by-paths ->
find-among-store-items):
(define (lookup-gtk+ entry)
(define (find-among-packages ...) ...)
(define (find-among-store-items ...) ...)
(with-monad %store-monad
(match (manifest-entry-item entry)
((? package? package)
(match (package-transitive-inputs package)
(((labels packages . _) ...)
(return (find-among-packages packages)))))
((? string? item)
(mlet %store-monad ((refs (references* item)))
(return (find-among-store-items refs)))))))
> + (define (manifest-lookup-gtk+ store manifest)
> + "Return the first GTK+ package or store path referenced by MANIFEST
> entries,
> +or #f if not referenced by any entry."
> + (any (cut entry-lookup-gtk+ store <>) (manifest-entries manifest)))
This becomes:
(anym %store-monad
(cut entry-lookup-gtk+ store <>)
(manifest-entries manifest))
> + (define gtk+
> + (with-store store
> + (manifest-lookup-gtk+ store manifest)))
Opening an extra connection like this is Very Bad. ;-)
This is addressed by the above.
So this becomes:
(mlet %store-monad ((gtk+ (lookup-gtk+ manifest)))
(define build
#~(...))
...)
Could you send an updated patch?
Thank you!
Ludo’.
- [PATCH] profiles: Add gtk-icon-themes hook., 宋文武, 2015/05/13
- Re: [PATCH] profiles: Add gtk-icon-themes hook.,
Ludovic Courtès <=
- Re: [PATCH] profiles: Add gtk-icon-themes hook., 宋文武, 2015/05/22
- Re: [PATCH] profiles: Add gtk-icon-themes hook., Ludovic Courtès, 2015/05/27
- Re: [PATCH] profiles: Add gtk-icon-themes hook., 宋文武, 2015/05/27
- Re: [PATCH] profiles: Add gtk-icon-themes hook., Ludovic Courtès, 2015/05/27
- Re: [PATCH] profiles: Add gtk-icon-themes hook., Mark H Weaver, 2015/05/27
- Re: [PATCH] profiles: Add gtk-icon-themes hook., Ludovic Courtès, 2015/05/28