[Top][All Lists]

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

Adding versioning to our recursive importer

From: swedebugia
Subject: Adding versioning to our recursive importer
Date: Mon, 14 Jan 2019 10:53:54 +0100


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
  "Generate a stream of package expressions for PACKAGE-NAME and all its
  (receive (package . dependencies)
      (repo->guix-package package-name repo)
    (if (not package)

        ;; 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
                                  (null? (find-packages-by-name
                                          (guix-name dependency))))))
               (update     (lambda (state new-queue)
                             (match state
                               (((head . tail) . done)
                                (make-state (lset-difference
(lset-union equal? new-queue tail)
                                            (cons head done)))))))
            ;; 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: gulp.svgz
Description: image/svg

reply via email to

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