guix-devel
[Top][All Lists]
Advanced

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

Re: [PATCH] profiles: Add gtk-icon-themes hook.


From: 宋文武
Subject: Re: [PATCH] profiles: Add gtk-icon-themes hook.
Date: Fri, 22 May 2015 14:43:05 +0800
User-agent: Notmuch/0.18.1 (http://notmuchmail.org) Emacs/24.5.1 (x86_64-unknown-linux-gnu)

Ludovic Courtès <address@hidden> writes:

> 宋文武 <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.
OK.
>
>> +    ;; 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)))))))
>
DONE.
>> +  (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))
This doesn't work, 'anym' need a list of monadic values, I endup with:

  (anym %store-monad
        (lambda (x) x) ; any better idea?
        (map entry-lookup-gtk+ (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?
Here it is:

Attachment: 0001-profiles-Add-gtk-icon-themes-hook.patch
Description: Text Data

And I have to modify 'profile-derivation' to do an extra filter for
'extras', because 'gtk-icon-themes' could return a monadic '#f'.
Any better idea?


reply via email to

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