summaryrefslogtreecommitdiff
path: root/guix/monads.scm
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2014-08-17 20:56:47 +0200
committerLudovic Courtès <ludo@gnu.org>2014-08-17 20:58:58 +0200
commit4231f05bbc29e4e3deffc9106a5faf14920979d3 (patch)
tree70e0d25011624721d1c5f853180cfe3c58fbe482 /guix/monads.scm
parent65f88b20857b2358cf228a4b0794d2c42f70f84f (diff)
downloadgnu-guix-4231f05bbc29e4e3deffc9106a5faf14920979d3.tar
gnu-guix-4231f05bbc29e4e3deffc9106a5faf14920979d3.tar.gz
monads: Add 'package->cross-derivation' and #:target for 'package-file'.
* guix/monads.scm (package-file): Add #:target keyword parameter and honor it. (package->cross-derivation): New procedure. * tests/monads.scm ("package-file + package->cross-derivation"): New test. * doc/guix.texi (The Store Monad): Update 'package-file' documentation. Add 'package->cross-derivation'.
Diffstat (limited to 'guix/monads.scm')
-rw-r--r--guix/monads.scm21
1 files changed, 17 insertions, 4 deletions
diff --git a/guix/monads.scm b/guix/monads.scm
index 4af2b704ab..8909312a87 100644
--- a/guix/monads.scm
+++ b/guix/monads.scm
@@ -59,6 +59,7 @@
package-file
origin->derivation
package->derivation
+ package->cross-derivation
built-derivations)
#:replace (imported-modules
compiled-modules))
@@ -377,13 +378,22 @@ permission bits are kept."
(define* (package-file package
#:optional file
- #:key (system (%current-system)) (output "out"))
+ #:key
+ (system (%current-system))
+ (output "out") target)
"Return as a monadic value the absolute file name of FILE within the
OUTPUT directory of PACKAGE. When FILE is omitted, return the name of the
-OUTPUT directory of PACKAGE."
+OUTPUT directory of PACKAGE. When TARGET is true, use it as a
+cross-compilation target triplet."
(lambda (store)
- (let* ((drv (package-derivation store package system))
- (out (derivation->output-path drv output)))
+ (define compute-derivation
+ (if target
+ (cut package-cross-derivation <> <> target <>)
+ package-derivation))
+
+ (let* ((system (or system (%current-system)))
+ (drv (compute-derivation store package system))
+ (out (derivation->output-path drv output)))
(if file
(string-append out "/" file)
out))))
@@ -411,6 +421,9 @@ input list as a monadic value."
(define package->derivation
(store-lift package-derivation))
+(define package->cross-derivation
+ (store-lift package-cross-derivation))
+
(define origin->derivation
(store-lift package-source-derivation))