2014-04-28 17:00:57 -04:00
|
|
|
|
;;; GNU Guix --- Functional package management for GNU
|
2015-01-12 17:26:52 -05:00
|
|
|
|
;;; Copyright © 2014, 2015 Ludovic Courtès <ludo@gnu.org>
|
2014-04-28 17:00:57 -04:00
|
|
|
|
;;;
|
|
|
|
|
;;; This file is part of GNU Guix.
|
|
|
|
|
;;;
|
|
|
|
|
;;; GNU Guix is free software; you can redistribute it and/or modify it
|
|
|
|
|
;;; under the terms of the GNU General Public License as published by
|
|
|
|
|
;;; the Free Software Foundation; either version 3 of the License, or (at
|
|
|
|
|
;;; your option) any later version.
|
|
|
|
|
;;;
|
|
|
|
|
;;; GNU Guix is distributed in the hope that it will be useful, but
|
|
|
|
|
;;; WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
;;; GNU General Public License for more details.
|
|
|
|
|
;;;
|
|
|
|
|
;;; You should have received a copy of the GNU General Public License
|
|
|
|
|
;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
|
|
(define-module (guix gexp)
|
monads: Move '%store-monad' and related procedures where they belong.
This turns (guix monads) into a generic module for monads, and moves the
store monad and related monadic procedures in their corresponding
module.
* guix/monads.scm (store-return, store-bind, %store-monad, store-lift,
text-file, interned-file, package-file, package->derivation,
package->cross-derivation, origin->derivation, imported-modules,
compiled, modules, built-derivations, run-with-store): Move to...
* guix/store.scm (store-return, store-bind, %store-monad, store-lift,
text-file, interned-file): ... here.
(%guile-for-build): New variable.
(run-with-store): Moved from monads.scm. Remove default value for
#:guile-for-build.
* guix/packages.scm (default-guile): Export.
(set-guile-for-build): New procedure.
(package-file, package->derivation, package->cross-derivation,
origin->derivation): Moved from monads.scm.
* guix/derivations.scm (%guile-for-build): Remove.
(imported-modules): Rename to...
(%imported-modules): ... this.
(compiled-modules): Rename to...
(%compiled-modules): ... this.
(built-derivations, imported-modules, compiled-modules): New
procedures.
* gnu/services/avahi.scm, gnu/services/base.scm, gnu/services/dbus.scm,
gnu/services/dmd.scm, gnu/services/networking.scm,
gnu/services/ssh.scm, gnu/services/xorg.scm, gnu/system/install.scm,
gnu/system/linux-initrd.scm, gnu/system/shadow.scm, guix/download.scm,
guix/gexp.scm, guix/git-download.scm, guix/profiles.scm,
guix/svn-download.scm, tests/monads.scm: Adjust imports accordingly.
* guix/monad-repl.scm (default-guile-derivation): New procedure.
(store-monad-language, run-in-store): Use it.
* build-aux/hydra/gnu-system.scm (qemu-jobs): Add explicit
'set-guile-for-build' call.
* guix/scripts/archive.scm (derivation-from-expression): Likewise.
* guix/scripts/build.scm (options/resolve-packages): Likewise.
* guix/scripts/environment.scm (guix-environment): Likewise.
* guix/scripts/system.scm (guix-system): Likewise.
* doc/guix.texi (The Store Monad): Adjust module names accordingly.
2015-01-14 07:34:52 -05:00
|
|
|
|
#:use-module (guix store)
|
2014-04-28 17:00:57 -04:00
|
|
|
|
#:use-module (guix monads)
|
monads: Move '%store-monad' and related procedures where they belong.
This turns (guix monads) into a generic module for monads, and moves the
store monad and related monadic procedures in their corresponding
module.
* guix/monads.scm (store-return, store-bind, %store-monad, store-lift,
text-file, interned-file, package-file, package->derivation,
package->cross-derivation, origin->derivation, imported-modules,
compiled, modules, built-derivations, run-with-store): Move to...
* guix/store.scm (store-return, store-bind, %store-monad, store-lift,
text-file, interned-file): ... here.
(%guile-for-build): New variable.
(run-with-store): Moved from monads.scm. Remove default value for
#:guile-for-build.
* guix/packages.scm (default-guile): Export.
(set-guile-for-build): New procedure.
(package-file, package->derivation, package->cross-derivation,
origin->derivation): Moved from monads.scm.
* guix/derivations.scm (%guile-for-build): Remove.
(imported-modules): Rename to...
(%imported-modules): ... this.
(compiled-modules): Rename to...
(%compiled-modules): ... this.
(built-derivations, imported-modules, compiled-modules): New
procedures.
* gnu/services/avahi.scm, gnu/services/base.scm, gnu/services/dbus.scm,
gnu/services/dmd.scm, gnu/services/networking.scm,
gnu/services/ssh.scm, gnu/services/xorg.scm, gnu/system/install.scm,
gnu/system/linux-initrd.scm, gnu/system/shadow.scm, guix/download.scm,
guix/gexp.scm, guix/git-download.scm, guix/profiles.scm,
guix/svn-download.scm, tests/monads.scm: Adjust imports accordingly.
* guix/monad-repl.scm (default-guile-derivation): New procedure.
(store-monad-language, run-in-store): Use it.
* build-aux/hydra/gnu-system.scm (qemu-jobs): Add explicit
'set-guile-for-build' call.
* guix/scripts/archive.scm (derivation-from-expression): Likewise.
* guix/scripts/build.scm (options/resolve-packages): Likewise.
* guix/scripts/environment.scm (guix-environment): Likewise.
* guix/scripts/system.scm (guix-system): Likewise.
* doc/guix.texi (The Store Monad): Adjust module names accordingly.
2015-01-14 07:34:52 -05:00
|
|
|
|
#:use-module (guix derivations)
|
2014-04-28 17:00:57 -04:00
|
|
|
|
#:use-module (guix packages)
|
|
|
|
|
#:use-module (srfi srfi-1)
|
|
|
|
|
#:use-module (srfi srfi-9)
|
2014-04-30 17:16:03 -04:00
|
|
|
|
#:use-module (srfi srfi-9 gnu)
|
2014-04-28 17:00:57 -04:00
|
|
|
|
#:use-module (srfi srfi-26)
|
|
|
|
|
#:use-module (ice-9 match)
|
|
|
|
|
#:export (gexp
|
|
|
|
|
gexp?
|
|
|
|
|
gexp->derivation
|
|
|
|
|
gexp->file
|
2015-01-12 17:26:52 -05:00
|
|
|
|
gexp->script
|
|
|
|
|
text-file*))
|
2014-04-28 17:00:57 -04:00
|
|
|
|
|
|
|
|
|
;;; Commentary:
|
|
|
|
|
;;;
|
|
|
|
|
;;; This module implements "G-expressions", or "gexps". Gexps are like
|
|
|
|
|
;;; S-expressions (sexps), with two differences:
|
|
|
|
|
;;;
|
|
|
|
|
;;; 1. References (un-quotations) to derivations or packages in a gexp are
|
gexp: Add 'ungexp-native' and 'ungexp-native-splicing'.
* guix/gexp.scm (<gexp>)[natives]: New field.
(write-gexp): Use both 'gexp-references' and
'gexp-native-references'.
(gexp->derivation): Use both 'gexp-inputs' and 'gexp-native-inputs',
and append them.
(gexp-inputs): Add 'references' parameter and honor it.
(gexp-native-inputs): New procedure.
(gexp->sexp)[reference->sexp]: Add 'native?' parameter and honor it.
Use it, and use 'gexp-native-references'.
(gexp)[collect-native-escapes]: New procedure.
[escape->ref]: Handle 'ungexp-native' and 'ungexp-native-splicing'.
[substitute-ungexp, substitute-ungexp-splicing]: New procedures.
[substitute-references]: Use them, and handle 'ungexp-native' and
'ungexp-native-splicing'.
Adjust generated 'make-gexp' call to provide both normal references
and native references.
[read-ungexp]: Support 'ungexp-native' and
'ungexp-native-splicing'.
Add reader extension for #+.
* tests/gexp.scm (gexp-native-inputs): New procedure.
(gexp->sexp*): Add 'target' parameter.
("ungexp + ungexp-native",
"input list + ungexp-native",
"input list splicing + ungexp-native-splicing",
"gexp->derivation, ungexp-native",
"gexp->derivation, ungexp + ungexp-native"): New tests.
("sugar"): Add tests for #+ and #+@.
* doc/guix.texi (G-Expressions): Document 'ungexp-native' et al.
2014-08-18 08:53:10 -04:00
|
|
|
|
;;; replaced by the corresponding output file name; in addition, the
|
|
|
|
|
;;; 'ungexp-native' unquote-like form allows code to explicitly refer to
|
|
|
|
|
;;; the native code of a given package, in case of cross-compilation;
|
2014-04-28 17:00:57 -04:00
|
|
|
|
;;;
|
|
|
|
|
;;; 2. Gexps embed information about the derivations they refer to.
|
|
|
|
|
;;;
|
|
|
|
|
;;; Gexps make it easy to write to files Scheme code that refers to store
|
|
|
|
|
;;; items, or to write Scheme code to build derivations.
|
|
|
|
|
;;;
|
|
|
|
|
;;; Code:
|
|
|
|
|
|
|
|
|
|
;; "G expressions".
|
|
|
|
|
(define-record-type <gexp>
|
gexp: Add 'ungexp-native' and 'ungexp-native-splicing'.
* guix/gexp.scm (<gexp>)[natives]: New field.
(write-gexp): Use both 'gexp-references' and
'gexp-native-references'.
(gexp->derivation): Use both 'gexp-inputs' and 'gexp-native-inputs',
and append them.
(gexp-inputs): Add 'references' parameter and honor it.
(gexp-native-inputs): New procedure.
(gexp->sexp)[reference->sexp]: Add 'native?' parameter and honor it.
Use it, and use 'gexp-native-references'.
(gexp)[collect-native-escapes]: New procedure.
[escape->ref]: Handle 'ungexp-native' and 'ungexp-native-splicing'.
[substitute-ungexp, substitute-ungexp-splicing]: New procedures.
[substitute-references]: Use them, and handle 'ungexp-native' and
'ungexp-native-splicing'.
Adjust generated 'make-gexp' call to provide both normal references
and native references.
[read-ungexp]: Support 'ungexp-native' and
'ungexp-native-splicing'.
Add reader extension for #+.
* tests/gexp.scm (gexp-native-inputs): New procedure.
(gexp->sexp*): Add 'target' parameter.
("ungexp + ungexp-native",
"input list + ungexp-native",
"input list splicing + ungexp-native-splicing",
"gexp->derivation, ungexp-native",
"gexp->derivation, ungexp + ungexp-native"): New tests.
("sugar"): Add tests for #+ and #+@.
* doc/guix.texi (G-Expressions): Document 'ungexp-native' et al.
2014-08-18 08:53:10 -04:00
|
|
|
|
(make-gexp references natives proc)
|
2014-04-28 17:00:57 -04:00
|
|
|
|
gexp?
|
|
|
|
|
(references gexp-references) ; ((DRV-OR-PKG OUTPUT) ...)
|
gexp: Add 'ungexp-native' and 'ungexp-native-splicing'.
* guix/gexp.scm (<gexp>)[natives]: New field.
(write-gexp): Use both 'gexp-references' and
'gexp-native-references'.
(gexp->derivation): Use both 'gexp-inputs' and 'gexp-native-inputs',
and append them.
(gexp-inputs): Add 'references' parameter and honor it.
(gexp-native-inputs): New procedure.
(gexp->sexp)[reference->sexp]: Add 'native?' parameter and honor it.
Use it, and use 'gexp-native-references'.
(gexp)[collect-native-escapes]: New procedure.
[escape->ref]: Handle 'ungexp-native' and 'ungexp-native-splicing'.
[substitute-ungexp, substitute-ungexp-splicing]: New procedures.
[substitute-references]: Use them, and handle 'ungexp-native' and
'ungexp-native-splicing'.
Adjust generated 'make-gexp' call to provide both normal references
and native references.
[read-ungexp]: Support 'ungexp-native' and
'ungexp-native-splicing'.
Add reader extension for #+.
* tests/gexp.scm (gexp-native-inputs): New procedure.
(gexp->sexp*): Add 'target' parameter.
("ungexp + ungexp-native",
"input list + ungexp-native",
"input list splicing + ungexp-native-splicing",
"gexp->derivation, ungexp-native",
"gexp->derivation, ungexp + ungexp-native"): New tests.
("sugar"): Add tests for #+ and #+@.
* doc/guix.texi (G-Expressions): Document 'ungexp-native' et al.
2014-08-18 08:53:10 -04:00
|
|
|
|
(natives gexp-native-references) ; ((DRV-OR-PKG OUTPUT) ...)
|
2014-04-28 17:00:57 -04:00
|
|
|
|
(proc gexp-proc)) ; procedure
|
|
|
|
|
|
2014-04-30 17:16:03 -04:00
|
|
|
|
(define (write-gexp gexp port)
|
|
|
|
|
"Write GEXP on PORT."
|
|
|
|
|
(display "#<gexp " port)
|
2014-07-17 09:40:06 -04:00
|
|
|
|
|
|
|
|
|
;; Try to write the underlying sexp. Now, this trick doesn't work when
|
|
|
|
|
;; doing things like (ungexp-splicing (gexp ())) because GEXP's procedure
|
|
|
|
|
;; tries to use 'append' on that, which fails with wrong-type-arg.
|
|
|
|
|
(false-if-exception
|
gexp: Add 'ungexp-native' and 'ungexp-native-splicing'.
* guix/gexp.scm (<gexp>)[natives]: New field.
(write-gexp): Use both 'gexp-references' and
'gexp-native-references'.
(gexp->derivation): Use both 'gexp-inputs' and 'gexp-native-inputs',
and append them.
(gexp-inputs): Add 'references' parameter and honor it.
(gexp-native-inputs): New procedure.
(gexp->sexp)[reference->sexp]: Add 'native?' parameter and honor it.
Use it, and use 'gexp-native-references'.
(gexp)[collect-native-escapes]: New procedure.
[escape->ref]: Handle 'ungexp-native' and 'ungexp-native-splicing'.
[substitute-ungexp, substitute-ungexp-splicing]: New procedures.
[substitute-references]: Use them, and handle 'ungexp-native' and
'ungexp-native-splicing'.
Adjust generated 'make-gexp' call to provide both normal references
and native references.
[read-ungexp]: Support 'ungexp-native' and
'ungexp-native-splicing'.
Add reader extension for #+.
* tests/gexp.scm (gexp-native-inputs): New procedure.
(gexp->sexp*): Add 'target' parameter.
("ungexp + ungexp-native",
"input list + ungexp-native",
"input list splicing + ungexp-native-splicing",
"gexp->derivation, ungexp-native",
"gexp->derivation, ungexp + ungexp-native"): New tests.
("sugar"): Add tests for #+ and #+@.
* doc/guix.texi (G-Expressions): Document 'ungexp-native' et al.
2014-08-18 08:53:10 -04:00
|
|
|
|
(write (apply (gexp-proc gexp)
|
|
|
|
|
(append (gexp-references gexp)
|
|
|
|
|
(gexp-native-references gexp)))
|
|
|
|
|
port))
|
2014-04-30 17:16:03 -04:00
|
|
|
|
(format port " ~a>"
|
|
|
|
|
(number->string (object-address gexp) 16)))
|
|
|
|
|
|
|
|
|
|
(set-record-type-printer! <gexp> write-gexp)
|
|
|
|
|
|
2014-04-28 17:00:57 -04:00
|
|
|
|
;; Reference to one of the derivation's outputs, for gexps used in
|
|
|
|
|
;; derivations.
|
|
|
|
|
(define-record-type <output-ref>
|
|
|
|
|
(output-ref name)
|
|
|
|
|
output-ref?
|
|
|
|
|
(name output-ref-name))
|
|
|
|
|
|
|
|
|
|
(define raw-derivation
|
|
|
|
|
(store-lift derivation))
|
|
|
|
|
|
2014-08-17 15:20:11 -04:00
|
|
|
|
(define* (lower-inputs inputs
|
|
|
|
|
#:key system target)
|
|
|
|
|
"Turn any package from INPUTS into a derivation for SYSTEM; return the
|
|
|
|
|
corresponding input list as a monadic value. When TARGET is true, use it as
|
|
|
|
|
the cross-compilation target triplet."
|
2014-04-28 17:00:57 -04:00
|
|
|
|
(with-monad %store-monad
|
|
|
|
|
(sequence %store-monad
|
|
|
|
|
(map (match-lambda
|
|
|
|
|
(((? package? package) sub-drv ...)
|
2014-08-17 15:20:11 -04:00
|
|
|
|
(mlet %store-monad
|
|
|
|
|
((drv (if target
|
|
|
|
|
(package->cross-derivation package target
|
|
|
|
|
system)
|
|
|
|
|
(package->derivation package system))))
|
2014-04-28 17:00:57 -04:00
|
|
|
|
(return `(,drv ,@sub-drv))))
|
2014-05-01 10:15:00 -04:00
|
|
|
|
(((? origin? origin) sub-drv ...)
|
|
|
|
|
(mlet %store-monad ((drv (origin->derivation origin)))
|
|
|
|
|
(return `(,drv ,@sub-drv))))
|
2014-04-28 17:00:57 -04:00
|
|
|
|
(input
|
|
|
|
|
(return input)))
|
|
|
|
|
inputs))))
|
|
|
|
|
|
2014-09-06 09:45:32 -04:00
|
|
|
|
(define* (lower-reference-graphs graphs #:key system target)
|
|
|
|
|
"Given GRAPHS, a list of (FILE-NAME INPUT ...) lists for use as a
|
|
|
|
|
#:reference-graphs argument, lower it such that each INPUT is replaced by the
|
|
|
|
|
corresponding derivation."
|
|
|
|
|
(match graphs
|
|
|
|
|
(((file-names . inputs) ...)
|
|
|
|
|
(mlet %store-monad ((inputs (lower-inputs inputs
|
|
|
|
|
#:system system
|
|
|
|
|
#:target target)))
|
|
|
|
|
(return (map cons file-names inputs))))))
|
|
|
|
|
|
2014-04-28 17:00:57 -04:00
|
|
|
|
(define* (gexp->derivation name exp
|
|
|
|
|
#:key
|
2014-08-17 15:20:11 -04:00
|
|
|
|
system (target 'current)
|
2014-04-28 17:00:57 -04:00
|
|
|
|
hash hash-algo recursive?
|
|
|
|
|
(env-vars '())
|
|
|
|
|
(modules '())
|
2014-11-09 16:19:17 -05:00
|
|
|
|
(module-path %load-path)
|
2014-04-28 17:00:57 -04:00
|
|
|
|
(guile-for-build (%guile-for-build))
|
|
|
|
|
references-graphs
|
|
|
|
|
local-build?)
|
|
|
|
|
"Return a derivation NAME that runs EXP (a gexp) with GUILE-FOR-BUILD (a
|
2014-08-17 15:20:11 -04:00
|
|
|
|
derivation) on SYSTEM. When TARGET is true, it is used as the
|
|
|
|
|
cross-compilation target triplet for packages referred to by EXP.
|
2014-04-28 17:00:57 -04:00
|
|
|
|
|
|
|
|
|
Make MODULES available in the evaluation context of EXP; MODULES is a list of
|
2014-11-09 16:19:17 -05:00
|
|
|
|
names of Guile modules searched in MODULE-PATH to be copied in the store,
|
2014-04-28 17:00:57 -04:00
|
|
|
|
compiled, and made available in the load path during the execution of
|
|
|
|
|
EXP---e.g., '((guix build utils) (guix build gnu-build-system)).
|
|
|
|
|
|
2014-09-06 09:45:32 -04:00
|
|
|
|
When REFERENCES-GRAPHS is true, it must be a list of tuples of one of the
|
|
|
|
|
following forms:
|
|
|
|
|
|
|
|
|
|
(FILE-NAME PACKAGE)
|
|
|
|
|
(FILE-NAME PACKAGE OUTPUT)
|
|
|
|
|
(FILE-NAME DERIVATION)
|
|
|
|
|
(FILE-NAME DERIVATION OUTPUT)
|
|
|
|
|
(FILE-NAME STORE-ITEM)
|
|
|
|
|
|
|
|
|
|
The right-hand-side of each element of REFERENCES-GRAPHS is automatically made
|
|
|
|
|
an input of the build process of EXP. In the build environment, each
|
|
|
|
|
FILE-NAME contains the reference graph of the corresponding item, in a simple
|
|
|
|
|
text format.
|
|
|
|
|
|
|
|
|
|
In that case, the reference graph of each store path is exported in
|
|
|
|
|
the build environment in the corresponding file, in a simple text format.
|
|
|
|
|
|
2014-04-28 17:00:57 -04:00
|
|
|
|
The other arguments are as for 'derivation'."
|
|
|
|
|
(define %modules modules)
|
|
|
|
|
(define outputs (gexp-outputs exp))
|
|
|
|
|
|
2014-09-06 09:45:32 -04:00
|
|
|
|
(define (graphs-file-names graphs)
|
|
|
|
|
;; Return a list of (FILE-NAME . STORE-PATH) pairs made from GRAPHS.
|
|
|
|
|
(map (match-lambda
|
|
|
|
|
((file-name (? derivation? drv))
|
|
|
|
|
(cons file-name (derivation->output-path drv)))
|
|
|
|
|
((file-name (? derivation? drv) sub-drv)
|
|
|
|
|
(cons file-name (derivation->output-path drv sub-drv)))
|
|
|
|
|
((file-name thing)
|
|
|
|
|
(cons file-name thing)))
|
|
|
|
|
graphs))
|
|
|
|
|
|
2014-08-17 15:20:11 -04:00
|
|
|
|
(mlet* %store-monad (;; The following binding is here to force
|
|
|
|
|
;; '%current-system' and '%current-target-system' to be
|
|
|
|
|
;; looked up at >>= time.
|
|
|
|
|
(unused (return #f))
|
|
|
|
|
|
2014-07-12 16:11:12 -04:00
|
|
|
|
(system -> (or system (%current-system)))
|
2014-08-17 15:20:11 -04:00
|
|
|
|
(target -> (if (eq? target 'current)
|
|
|
|
|
(%current-target-system)
|
|
|
|
|
target))
|
gexp: Add 'ungexp-native' and 'ungexp-native-splicing'.
* guix/gexp.scm (<gexp>)[natives]: New field.
(write-gexp): Use both 'gexp-references' and
'gexp-native-references'.
(gexp->derivation): Use both 'gexp-inputs' and 'gexp-native-inputs',
and append them.
(gexp-inputs): Add 'references' parameter and honor it.
(gexp-native-inputs): New procedure.
(gexp->sexp)[reference->sexp]: Add 'native?' parameter and honor it.
Use it, and use 'gexp-native-references'.
(gexp)[collect-native-escapes]: New procedure.
[escape->ref]: Handle 'ungexp-native' and 'ungexp-native-splicing'.
[substitute-ungexp, substitute-ungexp-splicing]: New procedures.
[substitute-references]: Use them, and handle 'ungexp-native' and
'ungexp-native-splicing'.
Adjust generated 'make-gexp' call to provide both normal references
and native references.
[read-ungexp]: Support 'ungexp-native' and
'ungexp-native-splicing'.
Add reader extension for #+.
* tests/gexp.scm (gexp-native-inputs): New procedure.
(gexp->sexp*): Add 'target' parameter.
("ungexp + ungexp-native",
"input list + ungexp-native",
"input list splicing + ungexp-native-splicing",
"gexp->derivation, ungexp-native",
"gexp->derivation, ungexp + ungexp-native"): New tests.
("sugar"): Add tests for #+ and #+@.
* doc/guix.texi (G-Expressions): Document 'ungexp-native' et al.
2014-08-18 08:53:10 -04:00
|
|
|
|
(normals (lower-inputs (gexp-inputs exp)
|
2014-08-17 15:20:11 -04:00
|
|
|
|
#:system system
|
|
|
|
|
#:target target))
|
gexp: Add 'ungexp-native' and 'ungexp-native-splicing'.
* guix/gexp.scm (<gexp>)[natives]: New field.
(write-gexp): Use both 'gexp-references' and
'gexp-native-references'.
(gexp->derivation): Use both 'gexp-inputs' and 'gexp-native-inputs',
and append them.
(gexp-inputs): Add 'references' parameter and honor it.
(gexp-native-inputs): New procedure.
(gexp->sexp)[reference->sexp]: Add 'native?' parameter and honor it.
Use it, and use 'gexp-native-references'.
(gexp)[collect-native-escapes]: New procedure.
[escape->ref]: Handle 'ungexp-native' and 'ungexp-native-splicing'.
[substitute-ungexp, substitute-ungexp-splicing]: New procedures.
[substitute-references]: Use them, and handle 'ungexp-native' and
'ungexp-native-splicing'.
Adjust generated 'make-gexp' call to provide both normal references
and native references.
[read-ungexp]: Support 'ungexp-native' and
'ungexp-native-splicing'.
Add reader extension for #+.
* tests/gexp.scm (gexp-native-inputs): New procedure.
(gexp->sexp*): Add 'target' parameter.
("ungexp + ungexp-native",
"input list + ungexp-native",
"input list splicing + ungexp-native-splicing",
"gexp->derivation, ungexp-native",
"gexp->derivation, ungexp + ungexp-native"): New tests.
("sugar"): Add tests for #+ and #+@.
* doc/guix.texi (G-Expressions): Document 'ungexp-native' et al.
2014-08-18 08:53:10 -04:00
|
|
|
|
(natives (lower-inputs (gexp-native-inputs exp)
|
|
|
|
|
#:system system
|
|
|
|
|
#:target #f))
|
|
|
|
|
(inputs -> (append normals natives))
|
2014-08-17 15:20:11 -04:00
|
|
|
|
(sexp (gexp->sexp exp
|
|
|
|
|
#:system system
|
|
|
|
|
#:target target))
|
2014-04-28 17:00:57 -04:00
|
|
|
|
(builder (text-file (string-append name "-builder")
|
|
|
|
|
(object->string sexp)))
|
|
|
|
|
(modules (if (pair? %modules)
|
|
|
|
|
(imported-modules %modules
|
|
|
|
|
#:system system
|
2014-11-09 16:19:17 -05:00
|
|
|
|
#:module-path module-path
|
2014-04-28 17:00:57 -04:00
|
|
|
|
#:guile guile-for-build)
|
|
|
|
|
(return #f)))
|
|
|
|
|
(compiled (if (pair? %modules)
|
|
|
|
|
(compiled-modules %modules
|
|
|
|
|
#:system system
|
2014-11-09 16:19:17 -05:00
|
|
|
|
#:module-path module-path
|
2014-04-28 17:00:57 -04:00
|
|
|
|
#:guile guile-for-build)
|
|
|
|
|
(return #f)))
|
2014-09-06 09:45:32 -04:00
|
|
|
|
(graphs (if references-graphs
|
|
|
|
|
(lower-reference-graphs references-graphs
|
|
|
|
|
#:system system
|
|
|
|
|
#:target target)
|
|
|
|
|
(return #f)))
|
2014-04-28 17:00:57 -04:00
|
|
|
|
(guile (if guile-for-build
|
|
|
|
|
(return guile-for-build)
|
2014-05-01 12:53:16 -04:00
|
|
|
|
(package->derivation (default-guile)
|
|
|
|
|
system))))
|
2014-04-28 17:00:57 -04:00
|
|
|
|
(raw-derivation name
|
|
|
|
|
(string-append (derivation->output-path guile)
|
|
|
|
|
"/bin/guile")
|
|
|
|
|
`("--no-auto-compile"
|
|
|
|
|
,@(if (pair? %modules)
|
|
|
|
|
`("-L" ,(derivation->output-path modules)
|
|
|
|
|
"-C" ,(derivation->output-path compiled))
|
|
|
|
|
'())
|
|
|
|
|
,builder)
|
|
|
|
|
#:outputs outputs
|
|
|
|
|
#:env-vars env-vars
|
|
|
|
|
#:system system
|
|
|
|
|
#:inputs `((,guile)
|
|
|
|
|
(,builder)
|
|
|
|
|
,@(if modules
|
|
|
|
|
`((,modules) (,compiled) ,@inputs)
|
2014-09-06 09:45:32 -04:00
|
|
|
|
inputs)
|
|
|
|
|
,@(match graphs
|
|
|
|
|
(((_ . inputs) ...) inputs)
|
|
|
|
|
(_ '())))
|
2014-04-28 17:00:57 -04:00
|
|
|
|
#:hash hash #:hash-algo hash-algo #:recursive? recursive?
|
2014-09-06 09:45:32 -04:00
|
|
|
|
#:references-graphs (and=> graphs graphs-file-names)
|
2014-04-28 17:00:57 -04:00
|
|
|
|
#:local-build? local-build?)))
|
|
|
|
|
|
gexp: Add 'ungexp-native' and 'ungexp-native-splicing'.
* guix/gexp.scm (<gexp>)[natives]: New field.
(write-gexp): Use both 'gexp-references' and
'gexp-native-references'.
(gexp->derivation): Use both 'gexp-inputs' and 'gexp-native-inputs',
and append them.
(gexp-inputs): Add 'references' parameter and honor it.
(gexp-native-inputs): New procedure.
(gexp->sexp)[reference->sexp]: Add 'native?' parameter and honor it.
Use it, and use 'gexp-native-references'.
(gexp)[collect-native-escapes]: New procedure.
[escape->ref]: Handle 'ungexp-native' and 'ungexp-native-splicing'.
[substitute-ungexp, substitute-ungexp-splicing]: New procedures.
[substitute-references]: Use them, and handle 'ungexp-native' and
'ungexp-native-splicing'.
Adjust generated 'make-gexp' call to provide both normal references
and native references.
[read-ungexp]: Support 'ungexp-native' and
'ungexp-native-splicing'.
Add reader extension for #+.
* tests/gexp.scm (gexp-native-inputs): New procedure.
(gexp->sexp*): Add 'target' parameter.
("ungexp + ungexp-native",
"input list + ungexp-native",
"input list splicing + ungexp-native-splicing",
"gexp->derivation, ungexp-native",
"gexp->derivation, ungexp + ungexp-native"): New tests.
("sugar"): Add tests for #+ and #+@.
* doc/guix.texi (G-Expressions): Document 'ungexp-native' et al.
2014-08-18 08:53:10 -04:00
|
|
|
|
(define* (gexp-inputs exp #:optional (references gexp-references))
|
|
|
|
|
"Return the input list for EXP, using REFERENCES to get its list of
|
|
|
|
|
references."
|
2014-04-28 17:00:57 -04:00
|
|
|
|
(define (add-reference-inputs ref result)
|
|
|
|
|
(match ref
|
|
|
|
|
(((? derivation?) (? string?))
|
|
|
|
|
(cons ref result))
|
|
|
|
|
(((? package?) (? string?))
|
|
|
|
|
(cons ref result))
|
2014-05-01 10:15:00 -04:00
|
|
|
|
(((? origin?) (? string?))
|
|
|
|
|
(cons ref result))
|
2014-04-28 17:00:57 -04:00
|
|
|
|
((? gexp? exp)
|
gexp: Add 'ungexp-native' and 'ungexp-native-splicing'.
* guix/gexp.scm (<gexp>)[natives]: New field.
(write-gexp): Use both 'gexp-references' and
'gexp-native-references'.
(gexp->derivation): Use both 'gexp-inputs' and 'gexp-native-inputs',
and append them.
(gexp-inputs): Add 'references' parameter and honor it.
(gexp-native-inputs): New procedure.
(gexp->sexp)[reference->sexp]: Add 'native?' parameter and honor it.
Use it, and use 'gexp-native-references'.
(gexp)[collect-native-escapes]: New procedure.
[escape->ref]: Handle 'ungexp-native' and 'ungexp-native-splicing'.
[substitute-ungexp, substitute-ungexp-splicing]: New procedures.
[substitute-references]: Use them, and handle 'ungexp-native' and
'ungexp-native-splicing'.
Adjust generated 'make-gexp' call to provide both normal references
and native references.
[read-ungexp]: Support 'ungexp-native' and
'ungexp-native-splicing'.
Add reader extension for #+.
* tests/gexp.scm (gexp-native-inputs): New procedure.
(gexp->sexp*): Add 'target' parameter.
("ungexp + ungexp-native",
"input list + ungexp-native",
"input list splicing + ungexp-native-splicing",
"gexp->derivation, ungexp-native",
"gexp->derivation, ungexp + ungexp-native"): New tests.
("sugar"): Add tests for #+ and #+@.
* doc/guix.texi (G-Expressions): Document 'ungexp-native' et al.
2014-08-18 08:53:10 -04:00
|
|
|
|
(append (gexp-inputs exp references) result))
|
2014-04-28 17:00:57 -04:00
|
|
|
|
(((? string? file))
|
|
|
|
|
(if (direct-store-path? file)
|
|
|
|
|
(cons ref result)
|
|
|
|
|
result))
|
|
|
|
|
((refs ...)
|
|
|
|
|
(fold-right add-reference-inputs result refs))
|
|
|
|
|
(_
|
|
|
|
|
;; Ignore references to other kinds of objects.
|
|
|
|
|
result)))
|
|
|
|
|
|
|
|
|
|
(fold-right add-reference-inputs
|
|
|
|
|
'()
|
gexp: Add 'ungexp-native' and 'ungexp-native-splicing'.
* guix/gexp.scm (<gexp>)[natives]: New field.
(write-gexp): Use both 'gexp-references' and
'gexp-native-references'.
(gexp->derivation): Use both 'gexp-inputs' and 'gexp-native-inputs',
and append them.
(gexp-inputs): Add 'references' parameter and honor it.
(gexp-native-inputs): New procedure.
(gexp->sexp)[reference->sexp]: Add 'native?' parameter and honor it.
Use it, and use 'gexp-native-references'.
(gexp)[collect-native-escapes]: New procedure.
[escape->ref]: Handle 'ungexp-native' and 'ungexp-native-splicing'.
[substitute-ungexp, substitute-ungexp-splicing]: New procedures.
[substitute-references]: Use them, and handle 'ungexp-native' and
'ungexp-native-splicing'.
Adjust generated 'make-gexp' call to provide both normal references
and native references.
[read-ungexp]: Support 'ungexp-native' and
'ungexp-native-splicing'.
Add reader extension for #+.
* tests/gexp.scm (gexp-native-inputs): New procedure.
(gexp->sexp*): Add 'target' parameter.
("ungexp + ungexp-native",
"input list + ungexp-native",
"input list splicing + ungexp-native-splicing",
"gexp->derivation, ungexp-native",
"gexp->derivation, ungexp + ungexp-native"): New tests.
("sugar"): Add tests for #+ and #+@.
* doc/guix.texi (G-Expressions): Document 'ungexp-native' et al.
2014-08-18 08:53:10 -04:00
|
|
|
|
(references exp)))
|
|
|
|
|
|
|
|
|
|
(define gexp-native-inputs
|
|
|
|
|
(cut gexp-inputs <> gexp-native-references))
|
2014-04-28 17:00:57 -04:00
|
|
|
|
|
|
|
|
|
(define (gexp-outputs exp)
|
|
|
|
|
"Return the outputs referred to by EXP as a list of strings."
|
|
|
|
|
(define (add-reference-output ref result)
|
|
|
|
|
(match ref
|
|
|
|
|
(($ <output-ref> name)
|
|
|
|
|
(cons name result))
|
|
|
|
|
((? gexp? exp)
|
|
|
|
|
(append (gexp-outputs exp) result))
|
|
|
|
|
(_
|
|
|
|
|
result)))
|
|
|
|
|
|
|
|
|
|
(fold-right add-reference-output
|
|
|
|
|
'()
|
|
|
|
|
(gexp-references exp)))
|
|
|
|
|
|
2014-08-17 15:20:11 -04:00
|
|
|
|
(define* (gexp->sexp exp #:key
|
|
|
|
|
(system (%current-system))
|
|
|
|
|
(target (%current-target-system)))
|
2014-04-28 17:00:57 -04:00
|
|
|
|
"Return (monadically) the sexp corresponding to EXP for the given OUTPUT,
|
|
|
|
|
and in the current monad setting (system type, etc.)"
|
gexp: Add 'ungexp-native' and 'ungexp-native-splicing'.
* guix/gexp.scm (<gexp>)[natives]: New field.
(write-gexp): Use both 'gexp-references' and
'gexp-native-references'.
(gexp->derivation): Use both 'gexp-inputs' and 'gexp-native-inputs',
and append them.
(gexp-inputs): Add 'references' parameter and honor it.
(gexp-native-inputs): New procedure.
(gexp->sexp)[reference->sexp]: Add 'native?' parameter and honor it.
Use it, and use 'gexp-native-references'.
(gexp)[collect-native-escapes]: New procedure.
[escape->ref]: Handle 'ungexp-native' and 'ungexp-native-splicing'.
[substitute-ungexp, substitute-ungexp-splicing]: New procedures.
[substitute-references]: Use them, and handle 'ungexp-native' and
'ungexp-native-splicing'.
Adjust generated 'make-gexp' call to provide both normal references
and native references.
[read-ungexp]: Support 'ungexp-native' and
'ungexp-native-splicing'.
Add reader extension for #+.
* tests/gexp.scm (gexp-native-inputs): New procedure.
(gexp->sexp*): Add 'target' parameter.
("ungexp + ungexp-native",
"input list + ungexp-native",
"input list splicing + ungexp-native-splicing",
"gexp->derivation, ungexp-native",
"gexp->derivation, ungexp + ungexp-native"): New tests.
("sugar"): Add tests for #+ and #+@.
* doc/guix.texi (G-Expressions): Document 'ungexp-native' et al.
2014-08-18 08:53:10 -04:00
|
|
|
|
(define* (reference->sexp ref #:optional native?)
|
2014-04-28 17:00:57 -04:00
|
|
|
|
(with-monad %store-monad
|
|
|
|
|
(match ref
|
|
|
|
|
(((? derivation? drv) (? string? output))
|
|
|
|
|
(return (derivation->output-path drv output)))
|
|
|
|
|
(((? package? p) (? string? output))
|
2014-08-17 15:20:11 -04:00
|
|
|
|
(package-file p
|
|
|
|
|
#:output output
|
|
|
|
|
#:system system
|
gexp: Add 'ungexp-native' and 'ungexp-native-splicing'.
* guix/gexp.scm (<gexp>)[natives]: New field.
(write-gexp): Use both 'gexp-references' and
'gexp-native-references'.
(gexp->derivation): Use both 'gexp-inputs' and 'gexp-native-inputs',
and append them.
(gexp-inputs): Add 'references' parameter and honor it.
(gexp-native-inputs): New procedure.
(gexp->sexp)[reference->sexp]: Add 'native?' parameter and honor it.
Use it, and use 'gexp-native-references'.
(gexp)[collect-native-escapes]: New procedure.
[escape->ref]: Handle 'ungexp-native' and 'ungexp-native-splicing'.
[substitute-ungexp, substitute-ungexp-splicing]: New procedures.
[substitute-references]: Use them, and handle 'ungexp-native' and
'ungexp-native-splicing'.
Adjust generated 'make-gexp' call to provide both normal references
and native references.
[read-ungexp]: Support 'ungexp-native' and
'ungexp-native-splicing'.
Add reader extension for #+.
* tests/gexp.scm (gexp-native-inputs): New procedure.
(gexp->sexp*): Add 'target' parameter.
("ungexp + ungexp-native",
"input list + ungexp-native",
"input list splicing + ungexp-native-splicing",
"gexp->derivation, ungexp-native",
"gexp->derivation, ungexp + ungexp-native"): New tests.
("sugar"): Add tests for #+ and #+@.
* doc/guix.texi (G-Expressions): Document 'ungexp-native' et al.
2014-08-18 08:53:10 -04:00
|
|
|
|
#:target (if native? #f target)))
|
2014-05-01 10:15:00 -04:00
|
|
|
|
(((? origin? o) (? string? output))
|
|
|
|
|
(mlet %store-monad ((drv (origin->derivation o)))
|
|
|
|
|
(return (derivation->output-path drv output))))
|
2014-04-28 17:00:57 -04:00
|
|
|
|
(($ <output-ref> output)
|
2014-04-29 11:58:34 -04:00
|
|
|
|
;; Output file names are not known in advance but the daemon defines
|
|
|
|
|
;; an environment variable for each of them at build time, so use
|
|
|
|
|
;; that trick.
|
|
|
|
|
(return `((@ (guile) getenv) ,output)))
|
2014-04-28 17:00:57 -04:00
|
|
|
|
((? gexp? exp)
|
gexp: Add 'ungexp-native' and 'ungexp-native-splicing'.
* guix/gexp.scm (<gexp>)[natives]: New field.
(write-gexp): Use both 'gexp-references' and
'gexp-native-references'.
(gexp->derivation): Use both 'gexp-inputs' and 'gexp-native-inputs',
and append them.
(gexp-inputs): Add 'references' parameter and honor it.
(gexp-native-inputs): New procedure.
(gexp->sexp)[reference->sexp]: Add 'native?' parameter and honor it.
Use it, and use 'gexp-native-references'.
(gexp)[collect-native-escapes]: New procedure.
[escape->ref]: Handle 'ungexp-native' and 'ungexp-native-splicing'.
[substitute-ungexp, substitute-ungexp-splicing]: New procedures.
[substitute-references]: Use them, and handle 'ungexp-native' and
'ungexp-native-splicing'.
Adjust generated 'make-gexp' call to provide both normal references
and native references.
[read-ungexp]: Support 'ungexp-native' and
'ungexp-native-splicing'.
Add reader extension for #+.
* tests/gexp.scm (gexp-native-inputs): New procedure.
(gexp->sexp*): Add 'target' parameter.
("ungexp + ungexp-native",
"input list + ungexp-native",
"input list splicing + ungexp-native-splicing",
"gexp->derivation, ungexp-native",
"gexp->derivation, ungexp + ungexp-native"): New tests.
("sugar"): Add tests for #+ and #+@.
* doc/guix.texi (G-Expressions): Document 'ungexp-native' et al.
2014-08-18 08:53:10 -04:00
|
|
|
|
(gexp->sexp exp
|
|
|
|
|
#:system system
|
|
|
|
|
#:target (if native? #f target)))
|
2014-04-28 17:00:57 -04:00
|
|
|
|
(((? string? str))
|
|
|
|
|
(return (if (direct-store-path? str) str ref)))
|
|
|
|
|
((refs ...)
|
gexp: Add 'ungexp-native' and 'ungexp-native-splicing'.
* guix/gexp.scm (<gexp>)[natives]: New field.
(write-gexp): Use both 'gexp-references' and
'gexp-native-references'.
(gexp->derivation): Use both 'gexp-inputs' and 'gexp-native-inputs',
and append them.
(gexp-inputs): Add 'references' parameter and honor it.
(gexp-native-inputs): New procedure.
(gexp->sexp)[reference->sexp]: Add 'native?' parameter and honor it.
Use it, and use 'gexp-native-references'.
(gexp)[collect-native-escapes]: New procedure.
[escape->ref]: Handle 'ungexp-native' and 'ungexp-native-splicing'.
[substitute-ungexp, substitute-ungexp-splicing]: New procedures.
[substitute-references]: Use them, and handle 'ungexp-native' and
'ungexp-native-splicing'.
Adjust generated 'make-gexp' call to provide both normal references
and native references.
[read-ungexp]: Support 'ungexp-native' and
'ungexp-native-splicing'.
Add reader extension for #+.
* tests/gexp.scm (gexp-native-inputs): New procedure.
(gexp->sexp*): Add 'target' parameter.
("ungexp + ungexp-native",
"input list + ungexp-native",
"input list splicing + ungexp-native-splicing",
"gexp->derivation, ungexp-native",
"gexp->derivation, ungexp + ungexp-native"): New tests.
("sugar"): Add tests for #+ and #+@.
* doc/guix.texi (G-Expressions): Document 'ungexp-native' et al.
2014-08-18 08:53:10 -04:00
|
|
|
|
(sequence %store-monad
|
|
|
|
|
(map (cut reference->sexp <> native?) refs)))
|
2014-04-28 17:00:57 -04:00
|
|
|
|
(x
|
|
|
|
|
(return x)))))
|
|
|
|
|
|
|
|
|
|
(mlet %store-monad
|
|
|
|
|
((args (sequence %store-monad
|
gexp: Add 'ungexp-native' and 'ungexp-native-splicing'.
* guix/gexp.scm (<gexp>)[natives]: New field.
(write-gexp): Use both 'gexp-references' and
'gexp-native-references'.
(gexp->derivation): Use both 'gexp-inputs' and 'gexp-native-inputs',
and append them.
(gexp-inputs): Add 'references' parameter and honor it.
(gexp-native-inputs): New procedure.
(gexp->sexp)[reference->sexp]: Add 'native?' parameter and honor it.
Use it, and use 'gexp-native-references'.
(gexp)[collect-native-escapes]: New procedure.
[escape->ref]: Handle 'ungexp-native' and 'ungexp-native-splicing'.
[substitute-ungexp, substitute-ungexp-splicing]: New procedures.
[substitute-references]: Use them, and handle 'ungexp-native' and
'ungexp-native-splicing'.
Adjust generated 'make-gexp' call to provide both normal references
and native references.
[read-ungexp]: Support 'ungexp-native' and
'ungexp-native-splicing'.
Add reader extension for #+.
* tests/gexp.scm (gexp-native-inputs): New procedure.
(gexp->sexp*): Add 'target' parameter.
("ungexp + ungexp-native",
"input list + ungexp-native",
"input list splicing + ungexp-native-splicing",
"gexp->derivation, ungexp-native",
"gexp->derivation, ungexp + ungexp-native"): New tests.
("sugar"): Add tests for #+ and #+@.
* doc/guix.texi (G-Expressions): Document 'ungexp-native' et al.
2014-08-18 08:53:10 -04:00
|
|
|
|
(append (map reference->sexp (gexp-references exp))
|
|
|
|
|
(map (cut reference->sexp <> #t)
|
|
|
|
|
(gexp-native-references exp))))))
|
2014-04-28 17:00:57 -04:00
|
|
|
|
(return (apply (gexp-proc exp) args))))
|
|
|
|
|
|
|
|
|
|
(define (canonicalize-reference ref)
|
|
|
|
|
"Return a canonical variant of REF, which adds any missing output part in
|
|
|
|
|
package/derivation references."
|
|
|
|
|
(match ref
|
|
|
|
|
((? package? p)
|
|
|
|
|
`(,p "out"))
|
2014-05-01 10:15:00 -04:00
|
|
|
|
((? origin? o)
|
|
|
|
|
`(,o "out"))
|
2014-04-28 17:00:57 -04:00
|
|
|
|
((? derivation? d)
|
|
|
|
|
`(,d "out"))
|
|
|
|
|
(((? package?) (? string?))
|
|
|
|
|
ref)
|
2014-05-01 10:15:00 -04:00
|
|
|
|
(((? origin?) (? string?))
|
|
|
|
|
ref)
|
2014-04-28 17:00:57 -04:00
|
|
|
|
(((? derivation?) (? string?))
|
|
|
|
|
ref)
|
|
|
|
|
((? string? s)
|
|
|
|
|
(if (direct-store-path? s) `(,s) s))
|
|
|
|
|
((refs ...)
|
|
|
|
|
(map canonicalize-reference refs))
|
|
|
|
|
(x x)))
|
|
|
|
|
|
|
|
|
|
(define (syntax-location-string s)
|
|
|
|
|
"Return a string representing the source code location of S."
|
|
|
|
|
(let ((props (syntax-source s)))
|
|
|
|
|
(if props
|
|
|
|
|
(let ((file (assoc-ref props 'filename))
|
|
|
|
|
(line (and=> (assoc-ref props 'line) 1+))
|
|
|
|
|
(column (assoc-ref props 'column)))
|
|
|
|
|
(if file
|
|
|
|
|
(simple-format #f "~a:~a:~a"
|
|
|
|
|
file line column)
|
|
|
|
|
(simple-format #f "~a:~a" line column)))
|
|
|
|
|
"<unknown location>")))
|
|
|
|
|
|
|
|
|
|
(define-syntax gexp
|
|
|
|
|
(lambda (s)
|
|
|
|
|
(define (collect-escapes exp)
|
|
|
|
|
;; Return all the 'ungexp' present in EXP.
|
|
|
|
|
(let loop ((exp exp)
|
|
|
|
|
(result '()))
|
|
|
|
|
(syntax-case exp (ungexp ungexp-splicing)
|
|
|
|
|
((ungexp _)
|
|
|
|
|
(cons exp result))
|
|
|
|
|
((ungexp _ _)
|
|
|
|
|
(cons exp result))
|
|
|
|
|
((ungexp-splicing _ ...)
|
|
|
|
|
(cons exp result))
|
|
|
|
|
((exp0 exp ...)
|
|
|
|
|
(let ((result (loop #'exp0 result)))
|
|
|
|
|
(fold loop result #'(exp ...))))
|
|
|
|
|
(_
|
|
|
|
|
result))))
|
|
|
|
|
|
gexp: Add 'ungexp-native' and 'ungexp-native-splicing'.
* guix/gexp.scm (<gexp>)[natives]: New field.
(write-gexp): Use both 'gexp-references' and
'gexp-native-references'.
(gexp->derivation): Use both 'gexp-inputs' and 'gexp-native-inputs',
and append them.
(gexp-inputs): Add 'references' parameter and honor it.
(gexp-native-inputs): New procedure.
(gexp->sexp)[reference->sexp]: Add 'native?' parameter and honor it.
Use it, and use 'gexp-native-references'.
(gexp)[collect-native-escapes]: New procedure.
[escape->ref]: Handle 'ungexp-native' and 'ungexp-native-splicing'.
[substitute-ungexp, substitute-ungexp-splicing]: New procedures.
[substitute-references]: Use them, and handle 'ungexp-native' and
'ungexp-native-splicing'.
Adjust generated 'make-gexp' call to provide both normal references
and native references.
[read-ungexp]: Support 'ungexp-native' and
'ungexp-native-splicing'.
Add reader extension for #+.
* tests/gexp.scm (gexp-native-inputs): New procedure.
(gexp->sexp*): Add 'target' parameter.
("ungexp + ungexp-native",
"input list + ungexp-native",
"input list splicing + ungexp-native-splicing",
"gexp->derivation, ungexp-native",
"gexp->derivation, ungexp + ungexp-native"): New tests.
("sugar"): Add tests for #+ and #+@.
* doc/guix.texi (G-Expressions): Document 'ungexp-native' et al.
2014-08-18 08:53:10 -04:00
|
|
|
|
(define (collect-native-escapes exp)
|
|
|
|
|
;; Return all the 'ungexp-native' forms present in EXP.
|
|
|
|
|
(let loop ((exp exp)
|
|
|
|
|
(result '()))
|
|
|
|
|
(syntax-case exp (ungexp-native ungexp-native-splicing)
|
|
|
|
|
((ungexp-native _)
|
|
|
|
|
(cons exp result))
|
|
|
|
|
((ungexp-native _ _)
|
|
|
|
|
(cons exp result))
|
|
|
|
|
((ungexp-native-splicing _ ...)
|
|
|
|
|
(cons exp result))
|
|
|
|
|
((exp0 exp ...)
|
|
|
|
|
(let ((result (loop #'exp0 result)))
|
|
|
|
|
(fold loop result #'(exp ...))))
|
|
|
|
|
(_
|
|
|
|
|
result))))
|
|
|
|
|
|
2014-04-28 17:00:57 -04:00
|
|
|
|
(define (escape->ref exp)
|
|
|
|
|
;; Turn 'ungexp' form EXP into a "reference".
|
gexp: Add 'ungexp-native' and 'ungexp-native-splicing'.
* guix/gexp.scm (<gexp>)[natives]: New field.
(write-gexp): Use both 'gexp-references' and
'gexp-native-references'.
(gexp->derivation): Use both 'gexp-inputs' and 'gexp-native-inputs',
and append them.
(gexp-inputs): Add 'references' parameter and honor it.
(gexp-native-inputs): New procedure.
(gexp->sexp)[reference->sexp]: Add 'native?' parameter and honor it.
Use it, and use 'gexp-native-references'.
(gexp)[collect-native-escapes]: New procedure.
[escape->ref]: Handle 'ungexp-native' and 'ungexp-native-splicing'.
[substitute-ungexp, substitute-ungexp-splicing]: New procedures.
[substitute-references]: Use them, and handle 'ungexp-native' and
'ungexp-native-splicing'.
Adjust generated 'make-gexp' call to provide both normal references
and native references.
[read-ungexp]: Support 'ungexp-native' and
'ungexp-native-splicing'.
Add reader extension for #+.
* tests/gexp.scm (gexp-native-inputs): New procedure.
(gexp->sexp*): Add 'target' parameter.
("ungexp + ungexp-native",
"input list + ungexp-native",
"input list splicing + ungexp-native-splicing",
"gexp->derivation, ungexp-native",
"gexp->derivation, ungexp + ungexp-native"): New tests.
("sugar"): Add tests for #+ and #+@.
* doc/guix.texi (G-Expressions): Document 'ungexp-native' et al.
2014-08-18 08:53:10 -04:00
|
|
|
|
(syntax-case exp (ungexp ungexp-splicing
|
|
|
|
|
ungexp-native ungexp-native-splicing
|
|
|
|
|
output)
|
2014-04-28 17:00:57 -04:00
|
|
|
|
((ungexp output)
|
|
|
|
|
#'(output-ref "out"))
|
|
|
|
|
((ungexp output name)
|
|
|
|
|
#'(output-ref name))
|
|
|
|
|
((ungexp thing)
|
|
|
|
|
#'thing)
|
|
|
|
|
((ungexp drv-or-pkg out)
|
|
|
|
|
#'(list drv-or-pkg out))
|
|
|
|
|
((ungexp-splicing lst)
|
gexp: Add 'ungexp-native' and 'ungexp-native-splicing'.
* guix/gexp.scm (<gexp>)[natives]: New field.
(write-gexp): Use both 'gexp-references' and
'gexp-native-references'.
(gexp->derivation): Use both 'gexp-inputs' and 'gexp-native-inputs',
and append them.
(gexp-inputs): Add 'references' parameter and honor it.
(gexp-native-inputs): New procedure.
(gexp->sexp)[reference->sexp]: Add 'native?' parameter and honor it.
Use it, and use 'gexp-native-references'.
(gexp)[collect-native-escapes]: New procedure.
[escape->ref]: Handle 'ungexp-native' and 'ungexp-native-splicing'.
[substitute-ungexp, substitute-ungexp-splicing]: New procedures.
[substitute-references]: Use them, and handle 'ungexp-native' and
'ungexp-native-splicing'.
Adjust generated 'make-gexp' call to provide both normal references
and native references.
[read-ungexp]: Support 'ungexp-native' and
'ungexp-native-splicing'.
Add reader extension for #+.
* tests/gexp.scm (gexp-native-inputs): New procedure.
(gexp->sexp*): Add 'target' parameter.
("ungexp + ungexp-native",
"input list + ungexp-native",
"input list splicing + ungexp-native-splicing",
"gexp->derivation, ungexp-native",
"gexp->derivation, ungexp + ungexp-native"): New tests.
("sugar"): Add tests for #+ and #+@.
* doc/guix.texi (G-Expressions): Document 'ungexp-native' et al.
2014-08-18 08:53:10 -04:00
|
|
|
|
#'lst)
|
|
|
|
|
((ungexp-native thing)
|
|
|
|
|
#'thing)
|
|
|
|
|
((ungexp-native drv-or-pkg out)
|
|
|
|
|
#'(list drv-or-pkg out))
|
|
|
|
|
((ungexp-native-splicing lst)
|
2014-04-28 17:00:57 -04:00
|
|
|
|
#'lst)))
|
|
|
|
|
|
gexp: Add 'ungexp-native' and 'ungexp-native-splicing'.
* guix/gexp.scm (<gexp>)[natives]: New field.
(write-gexp): Use both 'gexp-references' and
'gexp-native-references'.
(gexp->derivation): Use both 'gexp-inputs' and 'gexp-native-inputs',
and append them.
(gexp-inputs): Add 'references' parameter and honor it.
(gexp-native-inputs): New procedure.
(gexp->sexp)[reference->sexp]: Add 'native?' parameter and honor it.
Use it, and use 'gexp-native-references'.
(gexp)[collect-native-escapes]: New procedure.
[escape->ref]: Handle 'ungexp-native' and 'ungexp-native-splicing'.
[substitute-ungexp, substitute-ungexp-splicing]: New procedures.
[substitute-references]: Use them, and handle 'ungexp-native' and
'ungexp-native-splicing'.
Adjust generated 'make-gexp' call to provide both normal references
and native references.
[read-ungexp]: Support 'ungexp-native' and
'ungexp-native-splicing'.
Add reader extension for #+.
* tests/gexp.scm (gexp-native-inputs): New procedure.
(gexp->sexp*): Add 'target' parameter.
("ungexp + ungexp-native",
"input list + ungexp-native",
"input list splicing + ungexp-native-splicing",
"gexp->derivation, ungexp-native",
"gexp->derivation, ungexp + ungexp-native"): New tests.
("sugar"): Add tests for #+ and #+@.
* doc/guix.texi (G-Expressions): Document 'ungexp-native' et al.
2014-08-18 08:53:10 -04:00
|
|
|
|
(define (substitute-ungexp exp substs)
|
|
|
|
|
;; Given EXP, an 'ungexp' or 'ungexp-native' form, substitute it with
|
|
|
|
|
;; the corresponding form in SUBSTS.
|
|
|
|
|
(match (assoc exp substs)
|
|
|
|
|
((_ id)
|
|
|
|
|
id)
|
|
|
|
|
(_
|
|
|
|
|
#'(syntax-error "error: no 'ungexp' substitution"
|
|
|
|
|
#'ref))))
|
|
|
|
|
|
|
|
|
|
(define (substitute-ungexp-splicing exp substs)
|
|
|
|
|
(syntax-case exp ()
|
|
|
|
|
((exp rest ...)
|
|
|
|
|
(match (assoc #'exp substs)
|
|
|
|
|
((_ id)
|
|
|
|
|
(with-syntax ((id id))
|
|
|
|
|
#`(append id
|
|
|
|
|
#,(substitute-references #'(rest ...) substs))))
|
|
|
|
|
(_
|
|
|
|
|
#'(syntax-error "error: no 'ungexp-splicing' substitution"
|
|
|
|
|
#'ref))))))
|
|
|
|
|
|
2014-04-28 17:00:57 -04:00
|
|
|
|
(define (substitute-references exp substs)
|
|
|
|
|
;; Return a variant of EXP where all the cars of SUBSTS have been
|
|
|
|
|
;; replaced by the corresponding cdr.
|
gexp: Add 'ungexp-native' and 'ungexp-native-splicing'.
* guix/gexp.scm (<gexp>)[natives]: New field.
(write-gexp): Use both 'gexp-references' and
'gexp-native-references'.
(gexp->derivation): Use both 'gexp-inputs' and 'gexp-native-inputs',
and append them.
(gexp-inputs): Add 'references' parameter and honor it.
(gexp-native-inputs): New procedure.
(gexp->sexp)[reference->sexp]: Add 'native?' parameter and honor it.
Use it, and use 'gexp-native-references'.
(gexp)[collect-native-escapes]: New procedure.
[escape->ref]: Handle 'ungexp-native' and 'ungexp-native-splicing'.
[substitute-ungexp, substitute-ungexp-splicing]: New procedures.
[substitute-references]: Use them, and handle 'ungexp-native' and
'ungexp-native-splicing'.
Adjust generated 'make-gexp' call to provide both normal references
and native references.
[read-ungexp]: Support 'ungexp-native' and
'ungexp-native-splicing'.
Add reader extension for #+.
* tests/gexp.scm (gexp-native-inputs): New procedure.
(gexp->sexp*): Add 'target' parameter.
("ungexp + ungexp-native",
"input list + ungexp-native",
"input list splicing + ungexp-native-splicing",
"gexp->derivation, ungexp-native",
"gexp->derivation, ungexp + ungexp-native"): New tests.
("sugar"): Add tests for #+ and #+@.
* doc/guix.texi (G-Expressions): Document 'ungexp-native' et al.
2014-08-18 08:53:10 -04:00
|
|
|
|
(syntax-case exp (ungexp ungexp-native
|
|
|
|
|
ungexp-splicing ungexp-native-splicing)
|
2014-04-28 17:00:57 -04:00
|
|
|
|
((ungexp _ ...)
|
gexp: Add 'ungexp-native' and 'ungexp-native-splicing'.
* guix/gexp.scm (<gexp>)[natives]: New field.
(write-gexp): Use both 'gexp-references' and
'gexp-native-references'.
(gexp->derivation): Use both 'gexp-inputs' and 'gexp-native-inputs',
and append them.
(gexp-inputs): Add 'references' parameter and honor it.
(gexp-native-inputs): New procedure.
(gexp->sexp)[reference->sexp]: Add 'native?' parameter and honor it.
Use it, and use 'gexp-native-references'.
(gexp)[collect-native-escapes]: New procedure.
[escape->ref]: Handle 'ungexp-native' and 'ungexp-native-splicing'.
[substitute-ungexp, substitute-ungexp-splicing]: New procedures.
[substitute-references]: Use them, and handle 'ungexp-native' and
'ungexp-native-splicing'.
Adjust generated 'make-gexp' call to provide both normal references
and native references.
[read-ungexp]: Support 'ungexp-native' and
'ungexp-native-splicing'.
Add reader extension for #+.
* tests/gexp.scm (gexp-native-inputs): New procedure.
(gexp->sexp*): Add 'target' parameter.
("ungexp + ungexp-native",
"input list + ungexp-native",
"input list splicing + ungexp-native-splicing",
"gexp->derivation, ungexp-native",
"gexp->derivation, ungexp + ungexp-native"): New tests.
("sugar"): Add tests for #+ and #+@.
* doc/guix.texi (G-Expressions): Document 'ungexp-native' et al.
2014-08-18 08:53:10 -04:00
|
|
|
|
(substitute-ungexp exp substs))
|
|
|
|
|
((ungexp-native _ ...)
|
|
|
|
|
(substitute-ungexp exp substs))
|
2014-04-28 17:00:57 -04:00
|
|
|
|
(((ungexp-splicing _ ...) rest ...)
|
gexp: Add 'ungexp-native' and 'ungexp-native-splicing'.
* guix/gexp.scm (<gexp>)[natives]: New field.
(write-gexp): Use both 'gexp-references' and
'gexp-native-references'.
(gexp->derivation): Use both 'gexp-inputs' and 'gexp-native-inputs',
and append them.
(gexp-inputs): Add 'references' parameter and honor it.
(gexp-native-inputs): New procedure.
(gexp->sexp)[reference->sexp]: Add 'native?' parameter and honor it.
Use it, and use 'gexp-native-references'.
(gexp)[collect-native-escapes]: New procedure.
[escape->ref]: Handle 'ungexp-native' and 'ungexp-native-splicing'.
[substitute-ungexp, substitute-ungexp-splicing]: New procedures.
[substitute-references]: Use them, and handle 'ungexp-native' and
'ungexp-native-splicing'.
Adjust generated 'make-gexp' call to provide both normal references
and native references.
[read-ungexp]: Support 'ungexp-native' and
'ungexp-native-splicing'.
Add reader extension for #+.
* tests/gexp.scm (gexp-native-inputs): New procedure.
(gexp->sexp*): Add 'target' parameter.
("ungexp + ungexp-native",
"input list + ungexp-native",
"input list splicing + ungexp-native-splicing",
"gexp->derivation, ungexp-native",
"gexp->derivation, ungexp + ungexp-native"): New tests.
("sugar"): Add tests for #+ and #+@.
* doc/guix.texi (G-Expressions): Document 'ungexp-native' et al.
2014-08-18 08:53:10 -04:00
|
|
|
|
(substitute-ungexp-splicing exp substs))
|
|
|
|
|
(((ungexp-native-splicing _ ...) rest ...)
|
|
|
|
|
(substitute-ungexp-splicing exp substs))
|
2014-04-28 17:00:57 -04:00
|
|
|
|
((exp0 exp ...)
|
|
|
|
|
#`(cons #,(substitute-references #'exp0 substs)
|
|
|
|
|
#,(substitute-references #'(exp ...) substs)))
|
|
|
|
|
(x #''x)))
|
|
|
|
|
|
|
|
|
|
(syntax-case s (ungexp output)
|
|
|
|
|
((_ exp)
|
gexp: Add 'ungexp-native' and 'ungexp-native-splicing'.
* guix/gexp.scm (<gexp>)[natives]: New field.
(write-gexp): Use both 'gexp-references' and
'gexp-native-references'.
(gexp->derivation): Use both 'gexp-inputs' and 'gexp-native-inputs',
and append them.
(gexp-inputs): Add 'references' parameter and honor it.
(gexp-native-inputs): New procedure.
(gexp->sexp)[reference->sexp]: Add 'native?' parameter and honor it.
Use it, and use 'gexp-native-references'.
(gexp)[collect-native-escapes]: New procedure.
[escape->ref]: Handle 'ungexp-native' and 'ungexp-native-splicing'.
[substitute-ungexp, substitute-ungexp-splicing]: New procedures.
[substitute-references]: Use them, and handle 'ungexp-native' and
'ungexp-native-splicing'.
Adjust generated 'make-gexp' call to provide both normal references
and native references.
[read-ungexp]: Support 'ungexp-native' and
'ungexp-native-splicing'.
Add reader extension for #+.
* tests/gexp.scm (gexp-native-inputs): New procedure.
(gexp->sexp*): Add 'target' parameter.
("ungexp + ungexp-native",
"input list + ungexp-native",
"input list splicing + ungexp-native-splicing",
"gexp->derivation, ungexp-native",
"gexp->derivation, ungexp + ungexp-native"): New tests.
("sugar"): Add tests for #+ and #+@.
* doc/guix.texi (G-Expressions): Document 'ungexp-native' et al.
2014-08-18 08:53:10 -04:00
|
|
|
|
(let* ((normals (delete-duplicates (collect-escapes #'exp)))
|
|
|
|
|
(natives (delete-duplicates (collect-native-escapes #'exp)))
|
|
|
|
|
(escapes (append normals natives))
|
2014-04-28 17:00:57 -04:00
|
|
|
|
(formals (generate-temporaries escapes))
|
|
|
|
|
(sexp (substitute-references #'exp (zip escapes formals)))
|
gexp: Add 'ungexp-native' and 'ungexp-native-splicing'.
* guix/gexp.scm (<gexp>)[natives]: New field.
(write-gexp): Use both 'gexp-references' and
'gexp-native-references'.
(gexp->derivation): Use both 'gexp-inputs' and 'gexp-native-inputs',
and append them.
(gexp-inputs): Add 'references' parameter and honor it.
(gexp-native-inputs): New procedure.
(gexp->sexp)[reference->sexp]: Add 'native?' parameter and honor it.
Use it, and use 'gexp-native-references'.
(gexp)[collect-native-escapes]: New procedure.
[escape->ref]: Handle 'ungexp-native' and 'ungexp-native-splicing'.
[substitute-ungexp, substitute-ungexp-splicing]: New procedures.
[substitute-references]: Use them, and handle 'ungexp-native' and
'ungexp-native-splicing'.
Adjust generated 'make-gexp' call to provide both normal references
and native references.
[read-ungexp]: Support 'ungexp-native' and
'ungexp-native-splicing'.
Add reader extension for #+.
* tests/gexp.scm (gexp-native-inputs): New procedure.
(gexp->sexp*): Add 'target' parameter.
("ungexp + ungexp-native",
"input list + ungexp-native",
"input list splicing + ungexp-native-splicing",
"gexp->derivation, ungexp-native",
"gexp->derivation, ungexp + ungexp-native"): New tests.
("sugar"): Add tests for #+ and #+@.
* doc/guix.texi (G-Expressions): Document 'ungexp-native' et al.
2014-08-18 08:53:10 -04:00
|
|
|
|
(refs (map escape->ref normals))
|
|
|
|
|
(nrefs (map escape->ref natives)))
|
2014-04-28 17:00:57 -04:00
|
|
|
|
#`(make-gexp (map canonicalize-reference (list #,@refs))
|
gexp: Add 'ungexp-native' and 'ungexp-native-splicing'.
* guix/gexp.scm (<gexp>)[natives]: New field.
(write-gexp): Use both 'gexp-references' and
'gexp-native-references'.
(gexp->derivation): Use both 'gexp-inputs' and 'gexp-native-inputs',
and append them.
(gexp-inputs): Add 'references' parameter and honor it.
(gexp-native-inputs): New procedure.
(gexp->sexp)[reference->sexp]: Add 'native?' parameter and honor it.
Use it, and use 'gexp-native-references'.
(gexp)[collect-native-escapes]: New procedure.
[escape->ref]: Handle 'ungexp-native' and 'ungexp-native-splicing'.
[substitute-ungexp, substitute-ungexp-splicing]: New procedures.
[substitute-references]: Use them, and handle 'ungexp-native' and
'ungexp-native-splicing'.
Adjust generated 'make-gexp' call to provide both normal references
and native references.
[read-ungexp]: Support 'ungexp-native' and
'ungexp-native-splicing'.
Add reader extension for #+.
* tests/gexp.scm (gexp-native-inputs): New procedure.
(gexp->sexp*): Add 'target' parameter.
("ungexp + ungexp-native",
"input list + ungexp-native",
"input list splicing + ungexp-native-splicing",
"gexp->derivation, ungexp-native",
"gexp->derivation, ungexp + ungexp-native"): New tests.
("sugar"): Add tests for #+ and #+@.
* doc/guix.texi (G-Expressions): Document 'ungexp-native' et al.
2014-08-18 08:53:10 -04:00
|
|
|
|
(map canonicalize-reference (list #,@nrefs))
|
2014-04-28 17:00:57 -04:00
|
|
|
|
(lambda #,formals
|
|
|
|
|
#,sexp)))))))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;
|
|
|
|
|
;;; Convenience procedures.
|
|
|
|
|
;;;
|
|
|
|
|
|
2014-05-01 12:53:16 -04:00
|
|
|
|
(define (default-guile)
|
|
|
|
|
;; Lazily resolve 'guile-final'. This module must not refer to (gnu …)
|
|
|
|
|
;; modules directly, to avoid circular dependencies, hence this hack.
|
gnu: Split (gnu packages base), adding (gnu packages commencement).
* gnu/packages/base.scm (gnu-make-boot0, diffutils-boot0,
findutils-boot0, %boot0-inputs, nix-system->gnu-triplet, boot-triplet,
binutils-boot0, gcc-boot0, perl-boot0, linux-libre-headers-boot0,
texinfo-boot0, %boot1-inputs, glibc-final-with-bootstrap-bash,
cross-gcc-wrapper, static-bash-for-glibc, glibc-final,
gcc-boot0-wrapped, %boot2-inputs, binutils-final, libstdc++,
gcc-final, ld-wrapper-boot3, %boot3-inputs, bash-final, %boot4-inputs,
guile-final, gnu-make-final, ld-wrapper, coreutils-final, grep-final,
%boot5-inputs, %final-inputs, canonical-package, gcc-toolchain,
gcc-toolchain-4.8, gcc-toolchain-4.9): Move to...
* gnu/packages/commencement.scm: ... here. New file.
* gnu-system.am (GNU_SYSTEM_MODULES): Add it.
* build-aux/check-final-inputs-self-contained.scm: Adjust accordingly.
* gnu/packages/cross-base.scm: Likewise.
* gnu/packages/make-bootstrap.scm: Likewise.
* guix/build-system/cmake.scm (cmake-build): Likewise.
* guix/build-system/gnu.scm (standard-packages, gnu-build,
gnu-cross-build): Likewise.
* guix/build-system/perl.scm (perl-build): Likewise.
* guix/build-system/python.scm (python-build): Likewise.
* guix/build-system/trivial.scm (guile-for-build): Likewise.
* guix/download.scm (url-fetch): Likewise.
* guix/gexp.scm (default-guile): Likewise.
* guix/git-download.scm (git-fetch): Likewise.
* guix/monads.scm (run-with-store): Likewise.
* guix/packages.scm (default-guile): Likewise.
* guix/scripts/package.scm (guix-package): Likewise.
* guix/scripts/refresh.scm: Likewise.
* guix/svn-download.scm (svn-fetch): Likewise.
* tests/builders.scm (%bootstrap-inputs, %bootstrap-search-paths):
Likewise.
* tests/packages.scm ("GNU Make, bootstrap"): Likewise.
* tests/guix-package.sh: Likewise.
* gnu/services/base.scm: Use 'canonical-package' instead of xxx-final.
* gnu/services/xorg.scm: Likewise.
* gnu/system/vm.scm: Likewise.
* guix/scripts/pull.scm (guix-pull): Likewise.
2014-08-26 18:25:17 -04:00
|
|
|
|
(module-ref (resolve-interface '(gnu packages commencement))
|
2014-05-01 12:53:16 -04:00
|
|
|
|
'guile-final))
|
|
|
|
|
|
2014-04-28 17:00:57 -04:00
|
|
|
|
(define* (gexp->script name exp
|
2014-05-01 12:53:16 -04:00
|
|
|
|
#:key (modules '()) (guile (default-guile)))
|
2014-04-28 17:00:57 -04:00
|
|
|
|
"Return an executable script NAME that runs EXP using GUILE with MODULES in
|
|
|
|
|
its search path."
|
|
|
|
|
(mlet %store-monad ((modules (imported-modules modules))
|
|
|
|
|
(compiled (compiled-modules modules)))
|
|
|
|
|
(gexp->derivation name
|
|
|
|
|
(gexp
|
|
|
|
|
(call-with-output-file (ungexp output)
|
|
|
|
|
(lambda (port)
|
2014-06-04 11:26:54 -04:00
|
|
|
|
;; Note: that makes a long shebang. When the store
|
|
|
|
|
;; is /gnu/store, that fits within the 128-byte
|
|
|
|
|
;; limit imposed by Linux, but that may go beyond
|
|
|
|
|
;; when running tests.
|
2014-04-28 17:00:57 -04:00
|
|
|
|
(format port
|
|
|
|
|
"#!~a/bin/guile --no-auto-compile~%!#~%"
|
|
|
|
|
(ungexp guile))
|
2014-09-07 17:57:36 -04:00
|
|
|
|
|
|
|
|
|
;; Write the 'eval-when' form so that it can be
|
|
|
|
|
;; compiled.
|
2014-04-28 17:00:57 -04:00
|
|
|
|
(write
|
2014-09-07 17:57:36 -04:00
|
|
|
|
'(eval-when (expand load eval)
|
|
|
|
|
(set! %load-path
|
|
|
|
|
(cons (ungexp modules) %load-path))
|
|
|
|
|
(set! %load-compiled-path
|
|
|
|
|
(cons (ungexp compiled)
|
|
|
|
|
%load-compiled-path)))
|
2014-04-28 17:00:57 -04:00
|
|
|
|
port)
|
|
|
|
|
(write '(ungexp exp) port)
|
|
|
|
|
(chmod port #o555)))))))
|
|
|
|
|
|
|
|
|
|
(define (gexp->file name exp)
|
|
|
|
|
"Return a derivation that builds a file NAME containing EXP."
|
|
|
|
|
(gexp->derivation name
|
|
|
|
|
(gexp
|
|
|
|
|
(call-with-output-file (ungexp output)
|
|
|
|
|
(lambda (port)
|
2014-07-16 09:48:28 -04:00
|
|
|
|
(write '(ungexp exp) port))))
|
|
|
|
|
#:local-build? #t))
|
2014-04-28 17:00:57 -04:00
|
|
|
|
|
2015-01-12 17:26:52 -05:00
|
|
|
|
(define* (text-file* name #:rest text)
|
|
|
|
|
"Return as a monadic value a derivation that builds a text file containing
|
|
|
|
|
all of TEXT. TEXT may list, in addition to strings, packages, derivations,
|
|
|
|
|
and store file names; the resulting store file holds references to all these."
|
|
|
|
|
(define builder
|
|
|
|
|
(gexp (call-with-output-file (ungexp output "out")
|
|
|
|
|
(lambda (port)
|
|
|
|
|
(display (string-append (ungexp-splicing text)) port)))))
|
|
|
|
|
|
|
|
|
|
(gexp->derivation name builder))
|
|
|
|
|
|
|
|
|
|
|
2014-04-28 17:00:57 -04:00
|
|
|
|
|
|
|
|
|
;;;
|
|
|
|
|
;;; Syntactic sugar.
|
|
|
|
|
;;;
|
|
|
|
|
|
|
|
|
|
(eval-when (expand load eval)
|
gexp: Add 'ungexp-native' and 'ungexp-native-splicing'.
* guix/gexp.scm (<gexp>)[natives]: New field.
(write-gexp): Use both 'gexp-references' and
'gexp-native-references'.
(gexp->derivation): Use both 'gexp-inputs' and 'gexp-native-inputs',
and append them.
(gexp-inputs): Add 'references' parameter and honor it.
(gexp-native-inputs): New procedure.
(gexp->sexp)[reference->sexp]: Add 'native?' parameter and honor it.
Use it, and use 'gexp-native-references'.
(gexp)[collect-native-escapes]: New procedure.
[escape->ref]: Handle 'ungexp-native' and 'ungexp-native-splicing'.
[substitute-ungexp, substitute-ungexp-splicing]: New procedures.
[substitute-references]: Use them, and handle 'ungexp-native' and
'ungexp-native-splicing'.
Adjust generated 'make-gexp' call to provide both normal references
and native references.
[read-ungexp]: Support 'ungexp-native' and
'ungexp-native-splicing'.
Add reader extension for #+.
* tests/gexp.scm (gexp-native-inputs): New procedure.
(gexp->sexp*): Add 'target' parameter.
("ungexp + ungexp-native",
"input list + ungexp-native",
"input list splicing + ungexp-native-splicing",
"gexp->derivation, ungexp-native",
"gexp->derivation, ungexp + ungexp-native"): New tests.
("sugar"): Add tests for #+ and #+@.
* doc/guix.texi (G-Expressions): Document 'ungexp-native' et al.
2014-08-18 08:53:10 -04:00
|
|
|
|
(define* (read-ungexp chr port #:optional native?)
|
|
|
|
|
"Read an 'ungexp' or 'ungexp-splicing' form from PORT. When NATIVE? is
|
|
|
|
|
true, use 'ungexp-native' and 'ungexp-native-splicing' instead."
|
2014-04-28 17:00:57 -04:00
|
|
|
|
(define unquote-symbol
|
|
|
|
|
(match (peek-char port)
|
|
|
|
|
(#\@
|
|
|
|
|
(read-char port)
|
gexp: Add 'ungexp-native' and 'ungexp-native-splicing'.
* guix/gexp.scm (<gexp>)[natives]: New field.
(write-gexp): Use both 'gexp-references' and
'gexp-native-references'.
(gexp->derivation): Use both 'gexp-inputs' and 'gexp-native-inputs',
and append them.
(gexp-inputs): Add 'references' parameter and honor it.
(gexp-native-inputs): New procedure.
(gexp->sexp)[reference->sexp]: Add 'native?' parameter and honor it.
Use it, and use 'gexp-native-references'.
(gexp)[collect-native-escapes]: New procedure.
[escape->ref]: Handle 'ungexp-native' and 'ungexp-native-splicing'.
[substitute-ungexp, substitute-ungexp-splicing]: New procedures.
[substitute-references]: Use them, and handle 'ungexp-native' and
'ungexp-native-splicing'.
Adjust generated 'make-gexp' call to provide both normal references
and native references.
[read-ungexp]: Support 'ungexp-native' and
'ungexp-native-splicing'.
Add reader extension for #+.
* tests/gexp.scm (gexp-native-inputs): New procedure.
(gexp->sexp*): Add 'target' parameter.
("ungexp + ungexp-native",
"input list + ungexp-native",
"input list splicing + ungexp-native-splicing",
"gexp->derivation, ungexp-native",
"gexp->derivation, ungexp + ungexp-native"): New tests.
("sugar"): Add tests for #+ and #+@.
* doc/guix.texi (G-Expressions): Document 'ungexp-native' et al.
2014-08-18 08:53:10 -04:00
|
|
|
|
(if native?
|
|
|
|
|
'ungexp-native-splicing
|
|
|
|
|
'ungexp-splicing))
|
2014-04-28 17:00:57 -04:00
|
|
|
|
(_
|
gexp: Add 'ungexp-native' and 'ungexp-native-splicing'.
* guix/gexp.scm (<gexp>)[natives]: New field.
(write-gexp): Use both 'gexp-references' and
'gexp-native-references'.
(gexp->derivation): Use both 'gexp-inputs' and 'gexp-native-inputs',
and append them.
(gexp-inputs): Add 'references' parameter and honor it.
(gexp-native-inputs): New procedure.
(gexp->sexp)[reference->sexp]: Add 'native?' parameter and honor it.
Use it, and use 'gexp-native-references'.
(gexp)[collect-native-escapes]: New procedure.
[escape->ref]: Handle 'ungexp-native' and 'ungexp-native-splicing'.
[substitute-ungexp, substitute-ungexp-splicing]: New procedures.
[substitute-references]: Use them, and handle 'ungexp-native' and
'ungexp-native-splicing'.
Adjust generated 'make-gexp' call to provide both normal references
and native references.
[read-ungexp]: Support 'ungexp-native' and
'ungexp-native-splicing'.
Add reader extension for #+.
* tests/gexp.scm (gexp-native-inputs): New procedure.
(gexp->sexp*): Add 'target' parameter.
("ungexp + ungexp-native",
"input list + ungexp-native",
"input list splicing + ungexp-native-splicing",
"gexp->derivation, ungexp-native",
"gexp->derivation, ungexp + ungexp-native"): New tests.
("sugar"): Add tests for #+ and #+@.
* doc/guix.texi (G-Expressions): Document 'ungexp-native' et al.
2014-08-18 08:53:10 -04:00
|
|
|
|
(if native?
|
|
|
|
|
'ungexp-native
|
|
|
|
|
'ungexp))))
|
2014-04-28 17:00:57 -04:00
|
|
|
|
|
|
|
|
|
(match (read port)
|
|
|
|
|
((? symbol? symbol)
|
|
|
|
|
(let ((str (symbol->string symbol)))
|
|
|
|
|
(match (string-index-right str #\:)
|
|
|
|
|
(#f
|
|
|
|
|
`(,unquote-symbol ,symbol))
|
|
|
|
|
(colon
|
|
|
|
|
(let ((name (string->symbol (substring str 0 colon)))
|
|
|
|
|
(output (substring str (+ colon 1))))
|
|
|
|
|
`(,unquote-symbol ,name ,output))))))
|
|
|
|
|
(x
|
|
|
|
|
`(,unquote-symbol ,x))))
|
|
|
|
|
|
|
|
|
|
(define (read-gexp chr port)
|
|
|
|
|
"Read a 'gexp' form from PORT."
|
|
|
|
|
`(gexp ,(read port)))
|
|
|
|
|
|
|
|
|
|
;; Extend the reader
|
|
|
|
|
(read-hash-extend #\~ read-gexp)
|
gexp: Add 'ungexp-native' and 'ungexp-native-splicing'.
* guix/gexp.scm (<gexp>)[natives]: New field.
(write-gexp): Use both 'gexp-references' and
'gexp-native-references'.
(gexp->derivation): Use both 'gexp-inputs' and 'gexp-native-inputs',
and append them.
(gexp-inputs): Add 'references' parameter and honor it.
(gexp-native-inputs): New procedure.
(gexp->sexp)[reference->sexp]: Add 'native?' parameter and honor it.
Use it, and use 'gexp-native-references'.
(gexp)[collect-native-escapes]: New procedure.
[escape->ref]: Handle 'ungexp-native' and 'ungexp-native-splicing'.
[substitute-ungexp, substitute-ungexp-splicing]: New procedures.
[substitute-references]: Use them, and handle 'ungexp-native' and
'ungexp-native-splicing'.
Adjust generated 'make-gexp' call to provide both normal references
and native references.
[read-ungexp]: Support 'ungexp-native' and
'ungexp-native-splicing'.
Add reader extension for #+.
* tests/gexp.scm (gexp-native-inputs): New procedure.
(gexp->sexp*): Add 'target' parameter.
("ungexp + ungexp-native",
"input list + ungexp-native",
"input list splicing + ungexp-native-splicing",
"gexp->derivation, ungexp-native",
"gexp->derivation, ungexp + ungexp-native"): New tests.
("sugar"): Add tests for #+ and #+@.
* doc/guix.texi (G-Expressions): Document 'ungexp-native' et al.
2014-08-18 08:53:10 -04:00
|
|
|
|
(read-hash-extend #\$ read-ungexp)
|
|
|
|
|
(read-hash-extend #\+ (cut read-ungexp <> <> #t)))
|
2014-04-28 17:00:57 -04:00
|
|
|
|
|
|
|
|
|
;;; gexp.scm ends here
|