宋文武 <iyzs...@gmail.com> 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’.