me
/
guix
Archived
1
0
Fork 0

gexp: Add #:graft? parameter to 'gexp->derivation'.

* guix/gexp.scm (gexp->derivation): Add #:graft? parameter and honor it.
* tests/gexp.scm ("gexp->derivation vs. grafts"): New test.
* doc/guix.texi (G-Expressions): Update 'gexp->derivation'
  documentation.
master
Ludovic Courtès 2015-02-13 23:14:05 +01:00
parent b8bedf6051
commit ce45eb4c38
3 changed files with 58 additions and 32 deletions

View File

@ -2580,7 +2580,7 @@ below allow you to do that (@pxref{The Store Monad}, for more
information about monads.) information about monads.)
@deffn {Monadic Procedure} gexp->derivation @var{name} @var{exp} @ @deffn {Monadic Procedure} gexp->derivation @var{name} @var{exp} @
[#:system (%current-system)] [#:target #f] [#:inputs '()] @ [#:system (%current-system)] [#:target #f] [#:graft? #t] @
[#:hash #f] [#:hash-algo #f] @ [#:hash #f] [#:hash-algo #f] @
[#:recursive? #f] [#:env-vars '()] [#:modules '()] @ [#:recursive? #f] [#:env-vars '()] [#:modules '()] @
[#:module-path @var{%load-path}] @ [#:module-path @var{%load-path}] @
@ -2591,12 +2591,15 @@ Return a derivation @var{name} that runs @var{exp} (a gexp) with
is true, it is used as the cross-compilation target triplet for packages is true, it is used as the cross-compilation target triplet for packages
referred to by @var{exp}. referred to by @var{exp}.
Make @var{modules} available in the evaluation context of @var{EXP}; Make @var{modules} available in the evaluation context of @var{exp};
@var{MODULES} is a list of names of Guile modules searched in @var{modules} is a list of names of Guile modules searched in
@var{MODULE-PATH} to be copied in the store, compiled, and made available in @var{module-path} to be copied in the store, compiled, and made available in
the load path during the execution of @var{exp}---e.g., @code{((guix the load path during the execution of @var{exp}---e.g., @code{((guix
build utils) (guix build gnu-build-system))}. build utils) (guix build gnu-build-system))}.
@var{graft?} determines whether packages referred to by @var{exp} should be grafted when
applicable.
When @var{references-graphs} is true, it must be a list of tuples of one of the When @var{references-graphs} is true, it must be a list of tuples of one of the
following forms: following forms:

View File

@ -153,6 +153,7 @@ names and file names suitable for the #:allowed-references argument to
(modules '()) (modules '())
(module-path %load-path) (module-path %load-path)
(guile-for-build (%guile-for-build)) (guile-for-build (%guile-for-build))
(graft? (%graft?))
references-graphs references-graphs
allowed-references allowed-references
local-build?) local-build?)
@ -165,6 +166,9 @@ names of Guile modules searched in MODULE-PATH to be copied in the store,
compiled, and made available in the load path during the execution of compiled, and made available in the load path during the execution of
EXP---e.g., '((guix build utils) (guix build gnu-build-system)). EXP---e.g., '((guix build utils) (guix build gnu-build-system)).
GRAFT? determines whether packages referred to by EXP should be grafted when
applicable.
When REFERENCES-GRAPHS is true, it must be a list of tuples of one of the When REFERENCES-GRAPHS is true, it must be a list of tuples of one of the
following forms: following forms:
@ -198,10 +202,10 @@ The other arguments are as for 'derivation'."
(cons file-name thing))) (cons file-name thing)))
graphs)) graphs))
(mlet* %store-monad (;; The following binding is here to force (mlet* %store-monad (;; The following binding forces '%current-system' and
;; '%current-system' and '%current-target-system' to be ;; '%current-target-system' to be looked up at >>=
;; looked up at >>= time. ;; time.
(unused (return #f)) (graft? (set-grafting graft?))
(system -> (or system (%current-system))) (system -> (or system (%current-system)))
(target -> (if (eq? target 'current) (target -> (if (eq? target 'current)
@ -245,6 +249,8 @@ The other arguments are as for 'derivation'."
(return guile-for-build) (return guile-for-build)
(package->derivation (default-guile) (package->derivation (default-guile)
system)))) system))))
(mbegin %store-monad
(set-grafting graft?) ;restore the initial setting
(raw-derivation name (raw-derivation name
(string-append (derivation->output-path guile) (string-append (derivation->output-path guile)
"/bin/guile") "/bin/guile")
@ -268,7 +274,7 @@ The other arguments are as for 'derivation'."
#:hash hash #:hash-algo hash-algo #:recursive? recursive? #:hash hash #:hash-algo hash-algo #:recursive? recursive?
#:references-graphs (and=> graphs graphs-file-names) #:references-graphs (and=> graphs graphs-file-names)
#:allowed-references allowed #:allowed-references allowed
#:local-build? local-build?))) #:local-build? local-build?))))
(define* (gexp-inputs exp #:optional (references gexp-references)) (define* (gexp-inputs exp #:optional (references gexp-references))
"Return the input list for EXP, using REFERENCES to get its list of "Return the input list for EXP, using REFERENCES to get its list of

View File

@ -249,6 +249,23 @@
(equal? refs (list (dirname (dirname guile)))) (equal? refs (list (dirname (dirname guile))))
(equal? refs2 (list file)))))) (equal? refs2 (list file))))))
(test-assertm "gexp->derivation vs. grafts"
(mlet* %store-monad ((p0 -> (dummy-package "dummy"
(arguments
'(#:implicit-inputs? #f))))
(r -> (package (inherit p0) (name "DuMMY")))
(p1 -> (package (inherit p0) (replacement r)))
(exp0 -> (gexp (frob (ungexp p0) (ungexp output))))
(exp1 -> (gexp (frob (ungexp p1) (ungexp output))))
(void (set-guile-for-build %bootstrap-guile))
(drv0 (gexp->derivation "t" exp0))
(drv1 (gexp->derivation "t" exp1))
(drv1* (gexp->derivation "t" exp1 #:graft? #f)))
(return (and (not (string=? (derivation->output-path drv0)
(derivation->output-path drv1)))
(string=? (derivation->output-path drv0)
(derivation->output-path drv1*))))))
(test-assertm "gexp->derivation, composed gexps" (test-assertm "gexp->derivation, composed gexps"
(mlet* %store-monad ((exp0 -> (gexp (begin (mlet* %store-monad ((exp0 -> (gexp (begin
(mkdir (ungexp output)) (mkdir (ungexp output))