mirror of
https://git.in.rschanz.org/ryan77627/guix.git
synced 2024-12-25 05:48:07 -05:00
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'.
This commit is contained in:
parent
65f88b2085
commit
4231f05bbc
3 changed files with 36 additions and 8 deletions
|
@ -2065,15 +2065,19 @@ The example below adds a file to the store, under two different names:
|
|||
@end deffn
|
||||
|
||||
@deffn {Monadic Procedure} package-file @var{package} [@var{file}] @
|
||||
[#:system (%current-system)] [#:output "out"] Return as a monadic
|
||||
[#:system (%current-system)] [#:target #f] @
|
||||
[#:output "out"] Return as a monadic
|
||||
value in the absolute file name of @var{file} within the @var{output}
|
||||
directory of @var{package}. When @var{file} is omitted, return the name
|
||||
of the @var{output} directory of @var{package}.
|
||||
of the @var{output} directory of @var{package}. When @var{target} is
|
||||
true, use it as a cross-compilation target triplet.
|
||||
@end deffn
|
||||
|
||||
@deffn {Monadic Procedure} package->derivation @var{package} [@var{system}]
|
||||
Monadic version of @code{package-derivation} (@pxref{Defining
|
||||
Packages}).
|
||||
@deffnx {Monadic Procedure} package->cross-derivation @var{package} @
|
||||
@var{target} [@var{system}]
|
||||
Monadic version of @code{package-derivation} and
|
||||
@code{package-cross-derivation} (@pxref{Defining Packages}).
|
||||
@end deffn
|
||||
|
||||
|
||||
|
|
|
@ -59,6 +59,7 @@ (define-module (guix monads)
|
|||
package-file
|
||||
origin->derivation
|
||||
package->derivation
|
||||
package->cross-derivation
|
||||
built-derivations)
|
||||
#:replace (imported-modules
|
||||
compiled-modules))
|
||||
|
@ -377,13 +378,22 @@ (define* (interned-file file #:optional name
|
|||
|
||||
(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 @@ (define derivation-expression
|
|||
(define package->derivation
|
||||
(store-lift package-derivation))
|
||||
|
||||
(define package->cross-derivation
|
||||
(store-lift package-cross-derivation))
|
||||
|
||||
(define origin->derivation
|
||||
(store-lift package-source-derivation))
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@ (define-module (test-monads)
|
|||
#:select (package-derivation %current-system))
|
||||
#:use-module (gnu packages)
|
||||
#:use-module (gnu packages bootstrap)
|
||||
#:use-module ((gnu packages base) #:select (coreutils))
|
||||
#:use-module (ice-9 match)
|
||||
#:use-module (rnrs io ports)
|
||||
#:use-module (srfi srfi-1)
|
||||
|
@ -108,6 +109,16 @@ (define (g x)
|
|||
guile)))
|
||||
#:guile-for-build (package-derivation %store %bootstrap-guile)))
|
||||
|
||||
(test-assert "package-file + package->cross-derivation"
|
||||
(run-with-store %store
|
||||
(mlet* %store-monad ((file (package-file coreutils "bin/ls"
|
||||
#:target "foo64-gnu"))
|
||||
(xcu (package->cross-derivation coreutils
|
||||
"foo64-gnu")))
|
||||
(let ((output (derivation->output-path xcu)))
|
||||
(return (string=? file (string-append output "/bin/ls")))))
|
||||
#:guile-for-build (package-derivation %store %bootstrap-guile)))
|
||||
|
||||
(test-assert "interned-file"
|
||||
(run-with-store %store
|
||||
(mlet* %store-monad ((file -> (search-path %load-path "guix.scm"))
|
||||
|
|
Loading…
Reference in a new issue