~ruther/guix-local

7244a5f74e8a2f465b1ad04b5c4666457567c54e — Ludovic Courtès 13 years ago 3441e16
derivations: Add `derivation-path->output-paths'.

* guix/derivations.scm (derivation-path->output-paths): New procedure.
* tests/derivations.scm ("multiple-output derivation"): Test it.
2 files changed, 17 insertions(+), 3 deletions(-)

M guix/derivations.scm
M tests/derivations.scm
M guix/derivations.scm => guix/derivations.scm +12 -1
@@ 1,5 1,5 @@
;;; Guix --- Nix package management from Guile.         -*- coding: utf-8 -*-
;;; Copyright (C) 2012 Ludovic Courtès <ludo@gnu.org>
;;; Copyright (C) 2012, 2013 Ludovic Courtès <ludo@gnu.org>
;;;
;;; This file is part of Guix.
;;;


@@ 55,6 55,7 @@
            read-derivation
            write-derivation
            derivation-path->output-path
            derivation-path->output-paths
            derivation

            %guile-for-build


@@ 288,6 289,16 @@ path of its output OUTPUT."
            (outputs (derivation-outputs drv)))
       (and=> (assoc-ref outputs output) derivation-output-path)))))

(define (derivation-path->output-paths path)
  "Read the derivation from PATH (`/nix/store/xxx.drv'), and return the
list of name/path pairs of its outputs."
  (let* ((drv     (call-with-input-file path read-derivation))
         (outputs (derivation-outputs drv)))
    (map (match-lambda
          ((name . output)
           (cons name (derivation-output-path output))))
         outputs)))


;;;
;;; Derivation primitive.

M tests/derivations.scm => tests/derivations.scm +5 -2
@@ 1,5 1,5 @@
;;; Guix --- Nix package management from Guile.         -*- coding: utf-8 -*-
;;; Copyright (C) 2012 Ludovic Courtès <ludo@gnu.org>
;;; Copyright (C) 2012, 2013 Ludovic Courtès <ludo@gnu.org>
;;;
;;; This file is part of Guix.
;;;


@@ 234,7 234,10 @@
    (and succeeded?
         (let ((one (derivation-path->output-path drv-path "out"))
               (two (derivation-path->output-path drv-path "second")))
           (and (eq? 'one (call-with-input-file one read))
           (and (lset= equal?
                       (derivation-path->output-paths drv-path)
                       `(("out" . ,one) ("second" . ,two)))
                (eq? 'one (call-with-input-file one read))
                (eq? 'two (call-with-input-file two read)))))))

(test-assert "multiple-output derivation, non-alphabetic order"