summary refs log tree commit diff
path: root/guix/monads.scm
diff options
context:
space:
mode:
Diffstat (limited to 'guix/monads.scm')
-rw-r--r--guix/monads.scm19
1 files changed, 18 insertions, 1 deletions
diff --git a/guix/monads.scm b/guix/monads.scm
index f5c9e8e9c7..410fdbecb2 100644
--- a/guix/monads.scm
+++ b/guix/monads.scm
@@ -56,7 +56,8 @@
             package-file
             package->derivation
             built-derivations
-            derivation-expression))
+            derivation-expression
+            lower-inputs))
 
 ;;; Commentary:
 ;;;
@@ -319,6 +320,22 @@ OUTPUT directory of PACKAGE."
           (string-append out "/" file)
           out))))
 
+(define (lower-inputs inputs)
+  "Turn any package from INPUTS into a derivation; return the corresponding
+input list as a monadic value."
+  ;; XXX: Should probably be in (guix packages).
+  (with-monad %store-monad
+    (sequence %store-monad
+              (map (match-lambda
+                    ((name (? package? package) sub-drv ...)
+                     (mlet %store-monad ((drv (package->derivation package)))
+                       (return `(,name ,drv ,@sub-drv))))
+                    ((name (? string? file))
+                     (return `(,name ,file)))
+                    (tuple
+                     (return tuple)))
+                   inputs))))
+
 (define derivation-expression
   (store-lift build-expression->derivation))