* Adding versioning to our recursive importer
@ 2019-01-14 9:53 swedebugia
2019-01-26 0:00 ` Ivan Petkov
0 siblings, 1 reply; 2+ messages in thread
From: swedebugia @ 2019-01-14 9:53 UTC (permalink / raw)
To: guix-devel
[-- Attachment #1: Type: text/plain, Size: 3280 bytes --]
Hi
I would like some help from someone who understands the recursive importer.
The reason is that in our npm-importer we have to support different
versions of the same packages to avoid circular dependencies (which
happen e.g. when importing gulp when not considering versions).
Doing this manually is... not viable. (see the svgz attached)
For every dependency I expect the procedure below to handle a list
dependency pairs of name+version instead of just name.
Our very nice recursive importer looks like this:
(define* (recursive-import package-name repo
#:key repo->guix-package guix-name
#:allow-other-keys)
"Generate a stream of package expressions for PACKAGE-NAME and all its
dependencies."
(receive (package . dependencies)
(repo->guix-package package-name repo)
(if (not package)
stream-null
;; Generate a lazy stream of package expressions for all unknown
;; dependencies in the graph.
(let* ((make-state (lambda (queue done)
(cons queue done)))
(next (match-lambda
(((next . rest) . done) next)))
(imported (match-lambda
((queue . done) done)))
(done? (match-lambda
((queue . done)
(zero? (length queue)))))
(unknown? (lambda* (dependency #:optional (done '()))
(and (not (member dependency
done))
(null? (find-packages-by-name
(guix-name dependency))))))
(update (lambda (state new-queue)
(match state
(((head . tail) . done)
(make-state (lset-difference
equal?
(lset-union equal?
new-queue tail)
done)
(cons head done)))))))
(stream-cons
package
(stream-unfold
;; map: produce a stream element
(lambda (state)
(repo->guix-package (next state) repo))
;; predicate
(negate done?)
;; generator: update the queue
(lambda (state)
(receive (package . dependencies)
(repo->guix-package (next state) repo)
(if package
(update state (filter (cut unknown? <>
(cons (next state)
(imported state)))
(car dependencies)))
;; TODO: Try the other archives before giving up
(update state (imported state)))))
;; initial state
(make-state (filter unknown? (car dependencies))
(list package-name))))))))
Any ideas?
--
Cheers Swedebugia
[-- Attachment #2: gulp.svgz --]
[-- Type: image/svg+xml-compressed, Size: 74131 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-01-26 0:00 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-01-14 9:53 Adding versioning to our recursive importer swedebugia
2019-01-26 0:00 ` Ivan Petkov
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/guix.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).