2013-01-06 00:47:50 +01:00
|
|
|
|
;;; GNU Guix --- Functional package management for GNU
|
2019-04-16 11:42:18 +02:00
|
|
|
|
;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 Ludovic Courtès <ludo@gnu.org>
|
2016-12-17 15:12:19 +01:00
|
|
|
|
;;; Copyright © 2016, 2017 Mathieu Lirzin <mthl@gnu.org>
|
2012-04-18 23:34:12 +02:00
|
|
|
|
;;;
|
2013-01-06 00:47:50 +01:00
|
|
|
|
;;; This file is part of GNU Guix.
|
2012-04-18 23:34:12 +02:00
|
|
|
|
;;;
|
2013-01-06 00:47:50 +01:00
|
|
|
|
;;; GNU Guix is free software; you can redistribute it and/or modify it
|
2012-04-18 23:34:12 +02:00
|
|
|
|
;;; 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.
|
|
|
|
|
;;;
|
2013-01-06 00:47:50 +01:00
|
|
|
|
;;; GNU Guix is distributed in the hope that it will be useful, but
|
2012-04-18 23:34:12 +02:00
|
|
|
|
;;; 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
|
2013-01-06 00:47:50 +01:00
|
|
|
|
;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
|
2012-04-18 23:34:12 +02:00
|
|
|
|
|
|
|
|
|
(define-module (guix derivations)
|
|
|
|
|
#:use-module (srfi srfi-1)
|
|
|
|
|
#:use-module (srfi srfi-9)
|
2013-09-18 11:10:02 +02:00
|
|
|
|
#:use-module (srfi srfi-9 gnu)
|
2019-06-19 22:05:06 +02:00
|
|
|
|
#:use-module (srfi srfi-11)
|
2012-04-18 23:34:12 +02:00
|
|
|
|
#:use-module (srfi srfi-26)
|
2015-01-24 22:50:40 +01:00
|
|
|
|
#:use-module (srfi srfi-34)
|
|
|
|
|
#:use-module (srfi srfi-35)
|
2016-10-19 14:28:56 +02:00
|
|
|
|
#:use-module (ice-9 binary-ports)
|
2012-04-18 23:34:12 +02:00
|
|
|
|
#:use-module (rnrs bytevectors)
|
|
|
|
|
#:use-module (ice-9 match)
|
|
|
|
|
#:use-module (ice-9 rdelim)
|
2013-11-13 00:25:57 +01:00
|
|
|
|
#:use-module (ice-9 vlist)
|
2012-06-01 23:29:55 +02:00
|
|
|
|
#:use-module (guix store)
|
2012-06-01 23:29:55 +02:00
|
|
|
|
#:use-module (guix utils)
|
utils: Move base16 procedures to (guix base16).
* guix/utils.scm (bytevector->base16-string, base16-string->bytevector):
Move to...
* guix/base16.scm: ... here. New file.
* tests/utils.scm ("bytevector->base16-string->bytevector"): Move to...
* tests/base16.scm: ... here. New file.
* Makefile.am (MODULES): Add guix/base16.scm.
(SCM_TESTS): Add tests/base16.scm.
* build-aux/download.scm, guix/derivations.scm,
guix/docker.scm, guix/import/snix.scm, guix/pk-crypto.scm,
guix/scripts/authenticate.scm, guix/scripts/download.scm,
guix/scripts/hash.scm, guix/store.scm, tests/hash.scm,
tests/pk-crypto.scm: Adjust imports accordingly.
2017-03-15 21:54:34 +01:00
|
|
|
|
#:use-module (guix base16)
|
Add (guix memoization).
* guix/combinators.scm (memoize): Remove.
* guix/memoization.scm: New file.
* Makefile.am (MODULES): Add it.
* gnu/packages.scm, gnu/packages/bootstrap.scm,
guix/build-system/gnu.scm, guix/build-system/python.scm,
guix/derivations.scm, guix/gnu-maintenance.scm,
guix/import/cran.scm, guix/import/elpa.scm,
guix/modules.scm, guix/scripts/build.scm,
guix/scripts/graph.scm, guix/scripts/lint.scm,
guix/store.scm, guix/utils.scm: Adjust imports accordingly.
2017-01-28 16:33:57 +01:00
|
|
|
|
#:use-module (guix memoization)
|
utils: Move combinators to (guix combinators).
* guix/utils.scm (compile-time-value, memoize, fold2)
(fold-tree, fold-tree-leaves): Move to...
* guix/combinators: ... here. New file.
* tests/utils.scm ("fold2, 1 list", "fold2, 2 lists")
(fold-tree tests): Move to...
* tests/combinators.scm: ... here. New file.
* Makefile.am (MODULES, SCM_TESTS): Add them.
* gnu/packages.scm, gnu/packages/bootstrap.scm,
gnu/services/herd.scm, guix/build-system/gnu.scm,
guix/build-system/python.scm, guix/derivations.scm,
guix/gnu-maintenance.scm, guix/import/elpa.scm,
guix/scripts/archive.scm, guix/scripts/build.scm,
guix/scripts/graph.scm, guix/scripts/lint.scm,
guix/scripts/size.scm, guix/scripts/substitute.scm,
guix/serialization.scm, guix/store.scm, guix/ui.scm: Adjust imports
accordingly.
2016-05-04 17:35:47 +02:00
|
|
|
|
#:use-module (guix combinators)
|
2019-06-19 22:05:06 +02:00
|
|
|
|
#:use-module (guix deprecation)
|
2019-07-10 18:18:19 +02:00
|
|
|
|
#:use-module (guix diagnostics)
|
|
|
|
|
#:use-module (guix i18n)
|
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 13:34:52 +01:00
|
|
|
|
#:use-module (guix monads)
|
Switch to Guile-Gcrypt.
This removes (guix hash) and (guix pk-crypto), which now live as part of
Guile-Gcrypt (version 0.1.0.)
* guix/gcrypt.scm, guix/hash.scm, guix/pk-crypto.scm,
tests/hash.scm, tests/pk-crypto.scm: Remove.
* configure.ac: Test for Guile-Gcrypt. Remove LIBGCRYPT and
LIBGCRYPT_LIBDIR assignments.
* m4/guix.m4 (GUIX_ASSERT_LIBGCRYPT_USABLE): Remove.
* README: Add Guile-Gcrypt to the dependencies; move libgcrypt as
"required unless --disable-daemon".
* doc/guix.texi (Requirements): Likewise.
* gnu/packages/bash.scm, guix/derivations.scm, guix/docker.scm,
guix/git.scm, guix/http-client.scm, guix/import/cpan.scm,
guix/import/cran.scm, guix/import/crate.scm, guix/import/elpa.scm,
guix/import/gnu.scm, guix/import/hackage.scm,
guix/import/texlive.scm, guix/import/utils.scm, guix/nar.scm,
guix/pki.scm, guix/scripts/archive.scm,
guix/scripts/authenticate.scm, guix/scripts/download.scm,
guix/scripts/hash.scm, guix/scripts/pack.scm,
guix/scripts/publish.scm, guix/scripts/refresh.scm,
guix/scripts/substitute.scm, guix/store.scm,
guix/store/deduplication.scm, guix/tests.scm, tests/base32.scm,
tests/builders.scm, tests/challenge.scm, tests/cpan.scm,
tests/crate.scm, tests/derivations.scm, tests/gem.scm,
tests/nar.scm, tests/opam.scm, tests/pki.scm,
tests/publish.scm, tests/pypi.scm, tests/store-deduplication.scm,
tests/store.scm, tests/substitute.scm: Adjust imports.
* gnu/system/vm.scm: Likewise.
(guile-sqlite3&co): Rename to...
(gcrypt-sqlite3&co): ... this. Add GUILE-GCRYPT.
(expression->derivation-in-linux-vm)[config]: Remove.
(iso9660-image)[config]: Remove.
(qemu-image)[config]: Remove.
(system-docker-image)[config]: Remove.
* guix/scripts/pack.scm: Adjust imports.
(guile-sqlite3&co): Rename to...
(gcrypt-sqlite3&co): ... this. Add GUILE-GCRYPT.
(self-contained-tarball)[build]: Call 'make-config.scm' without
#:libgcrypt argument.
(squashfs-image)[libgcrypt]: Remove.
[build]: Call 'make-config.scm' without #:libgcrypt.
(docker-image)[config, json]: Remove.
[build]: Add GUILE-GCRYPT to the extensions Remove (guix config) from
the imported modules.
* guix/self.scm (specification->package): Remove "libgcrypt", add
"guile-gcrypt".
(compiled-guix): Remove #:libgcrypt.
[guile-gcrypt]: New variable.
[dependencies]: Add it.
[*core-modules*]: Remove #:libgcrypt from 'make-config.scm' call.
Add #:extensions.
[*config*]: Remove #:libgcrypt from 'make-config.scm' call.
(%dependency-variables): Remove %libgcrypt.
(make-config.scm): Remove #:libgcrypt.
* build-aux/build-self.scm (guile-gcrypt): New variable.
(make-config.scm): Remove #:libgcrypt.
(build-program)[fake-gcrypt-hash]: New variable.
Add (gcrypt hash) to the imported modules. Adjust load path
assignments.
* gnu/packages/package-management.scm (guix)[propagated-inputs]: Add
GUILE-GCRYPT.
[arguments]: In 'wrap-program' phase, add GUILE-GCRYPT to the search
path.
2018-08-31 17:07:07 +02:00
|
|
|
|
#:use-module (gcrypt hash)
|
Move base32 code to (guix base32).
* guix/utils.scm (bytevector-quintet-ref, bytevector-quintet-ref-right,
bytevector-quintet-length, bytevector-quintet-fold,
bytevector-quintet-fold-right, make-bytevector->base32-string,
%nix-base32-chars, %rfc4648-base32-chars, bytevector->base32-string,
bytevector->nix-base32-string, bytevector-quintet-set!,
bytevector-quintet-set-right!, base32-string-unfold,
base32-string-unfold-right, make-base32-string->bytevector,
base32-string->bytevector, nix-base32-string->bytevector): Move to...
* guix/base32.scm: ... here. New file.
* tests/utils.scm (%nix-hash, "bytevector->base32-string",
"base32-string->bytevector", "nix-base32-string->bytevector", "sha256
& bytevector->base32-string"): Move to...
* tests/base32.scm: ... here. New file
* guix-download.in, guix/derivations.scm, guix/packages.scm,
guix/snix.scm, tests/builders.scm, tests/derivations.scm: Adjust
accordingly.
* guix.scm (%public-modules): Add `base32'.
2012-11-11 22:33:28 +01:00
|
|
|
|
#:use-module (guix base32)
|
2014-10-14 14:47:49 +02:00
|
|
|
|
#:use-module (guix records)
|
2015-01-11 23:04:07 +01:00
|
|
|
|
#:use-module (guix sets)
|
2012-07-01 00:37:03 +02:00
|
|
|
|
#:export (<derivation>
|
|
|
|
|
derivation?
|
2012-04-18 23:34:12 +02:00
|
|
|
|
derivation-outputs
|
|
|
|
|
derivation-inputs
|
|
|
|
|
derivation-sources
|
|
|
|
|
derivation-system
|
2014-12-02 16:45:45 +01:00
|
|
|
|
derivation-builder
|
2012-04-18 23:34:12 +02:00
|
|
|
|
derivation-builder-arguments
|
|
|
|
|
derivation-builder-environment-vars
|
2013-09-17 23:00:55 +02:00
|
|
|
|
derivation-file-name
|
2012-07-01 00:37:03 +02:00
|
|
|
|
derivation-prerequisites
|
2019-06-19 22:05:06 +02:00
|
|
|
|
derivation-build-plan
|
|
|
|
|
derivation-prerequisites-to-build ;deprecated
|
2012-04-18 23:34:12 +02:00
|
|
|
|
|
2012-07-01 00:37:03 +02:00
|
|
|
|
<derivation-output>
|
2012-04-18 23:34:12 +02:00
|
|
|
|
derivation-output?
|
|
|
|
|
derivation-output-path
|
|
|
|
|
derivation-output-hash-algo
|
|
|
|
|
derivation-output-hash
|
2014-02-21 23:03:19 +01:00
|
|
|
|
derivation-output-recursive?
|
2012-04-18 23:34:12 +02:00
|
|
|
|
|
2012-07-01 00:37:03 +02:00
|
|
|
|
<derivation-input>
|
2012-04-18 23:34:12 +02:00
|
|
|
|
derivation-input?
|
2019-06-19 22:05:06 +02:00
|
|
|
|
derivation-input
|
2012-04-18 23:34:12 +02:00
|
|
|
|
derivation-input-path
|
2019-06-19 21:49:22 +02:00
|
|
|
|
derivation-input-derivation
|
2012-04-18 23:34:12 +02:00
|
|
|
|
derivation-input-sub-derivations
|
2013-04-17 00:06:59 +02:00
|
|
|
|
derivation-input-output-paths
|
2019-07-10 18:39:25 +02:00
|
|
|
|
derivation-input-output-path
|
2015-03-25 09:42:45 +01:00
|
|
|
|
valid-derivation-input?
|
2012-04-18 23:34:12 +02:00
|
|
|
|
|
2015-01-24 22:50:40 +01:00
|
|
|
|
&derivation-error
|
|
|
|
|
derivation-error?
|
|
|
|
|
derivation-error-derivation
|
|
|
|
|
&derivation-missing-output-error
|
|
|
|
|
derivation-missing-output-error?
|
|
|
|
|
derivation-missing-output
|
|
|
|
|
|
2014-10-17 20:58:02 +02:00
|
|
|
|
derivation-name
|
2015-01-09 23:33:42 +01:00
|
|
|
|
derivation-output-names
|
2012-04-18 23:34:12 +02:00
|
|
|
|
fixed-output-derivation?
|
2014-10-28 18:05:17 +01:00
|
|
|
|
offloadable-derivation?
|
|
|
|
|
substitutable-derivation?
|
2015-01-10 00:39:59 +01:00
|
|
|
|
substitution-oracle
|
2012-04-19 23:09:55 +02:00
|
|
|
|
derivation-hash
|
2018-11-26 22:14:11 +01:00
|
|
|
|
derivation-properties
|
2012-04-19 23:09:55 +02:00
|
|
|
|
|
|
|
|
|
read-derivation
|
2017-06-12 17:11:22 +02:00
|
|
|
|
read-derivation-from-file
|
2012-06-01 23:29:55 +02:00
|
|
|
|
write-derivation
|
derivations: 'derivation' and related procedures return a single value.
* guix/derivations.scm (derivation->output-path,
derivation->output-paths): New procedures.
(derivation-path->output-path): Use 'derivation->output-path'.
(derivation-path->output-paths): Use 'derivation->output-paths'.
(derivation): Accept 'derivation?' objects as inputs. Return a single
value.
(build-derivations): New procedure.
(compiled-modules): Use 'derivation->output-paths'.
(build-expression->derivation)[source-path]: Add case for when the
input matches 'derivation?'.
[prologue]: Accept 'derivation?' objects in INPUTS.
[mod-dir, go-dir]: Use 'derivation->output-path'.
* guix/download.scm (url-fetch): Adjust to the single-value return.
* guix/packages.scm (package-output): Use 'derivation->output-path'.
* guix/scripts/build.scm (guix-build): When the argument is
'derivation-path?', pass it through 'read-derivation'.
Use 'derivation-file-name' to print out the .drv file names, and to
register them. Use 'derivation->output-path' instead of
'derivation-path->output-path'.
* guix/scripts/package.scm (roll-back): Adjust to the single-value
return.
(guix-package): Use 'derivation->output-path'.
* guix/ui.scm (show-what-to-build): Adjust to deal with 'derivation?'
objects instead of .drv file names.
* gnu/system/grub.scm (grub-configuration-file): Use
'derivation->output-path' instead of 'derivation-path->output-path'.
* gnu/system/vm.scm (qemu-image, system-qemu-image): Likewise.
* tests/builders.scm, tests/derivations.scm, tests/packages.scm,
tests/store.scm, tests/union.scm: Adjust to the new calling
convention.
* doc/guix.texi (Defining Packages, The Store, Derivations): Adjust
accordingly.
2013-09-18 17:01:40 +02:00
|
|
|
|
derivation->output-path
|
|
|
|
|
derivation->output-paths
|
2012-06-07 23:15:00 +02:00
|
|
|
|
derivation-path->output-path
|
2013-01-05 23:51:13 +01:00
|
|
|
|
derivation-path->output-paths
|
2012-06-08 21:31:01 +02:00
|
|
|
|
derivation
|
2016-11-19 16:56:47 +01:00
|
|
|
|
raw-derivation
|
2017-12-13 15:01:07 +01:00
|
|
|
|
invalidate-derivation-caches!
|
2014-10-14 14:47:49 +02:00
|
|
|
|
|
2013-11-13 00:25:57 +01:00
|
|
|
|
map-derivation
|
2012-06-08 21:31:01 +02:00
|
|
|
|
|
2015-02-02 12:46:09 +01:00
|
|
|
|
build-derivations
|
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 13:34:52 +01:00
|
|
|
|
built-derivations
|
|
|
|
|
|
2016-03-22 15:00:53 +01:00
|
|
|
|
file-search-error?
|
|
|
|
|
file-search-error-file-name
|
|
|
|
|
file-search-error-search-path
|
2015-03-17 21:46:00 +01:00
|
|
|
|
|
2016-03-22 15:00:53 +01:00
|
|
|
|
search-path*
|
2016-03-22 14:58:59 +01:00
|
|
|
|
module->source-file-name
|
2015-02-13 17:23:17 +01:00
|
|
|
|
build-expression->derivation)
|
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 13:34:52 +01:00
|
|
|
|
|
|
|
|
|
;; Re-export it from here for backward compatibility.
|
2015-02-02 12:46:09 +01:00
|
|
|
|
#:re-export (%guile-for-build))
|
2012-04-18 23:34:12 +02:00
|
|
|
|
|
2015-01-24 22:50:40 +01:00
|
|
|
|
;;;
|
|
|
|
|
;;; Error conditions.
|
|
|
|
|
;;;
|
|
|
|
|
|
store: Rename '&nix-error' to '&store-error'.
* guix/store.scm (&nix-error): Rename to...
(&store-error): ... this, and adjust users.
(&nix-connection-error): Rename to...
(&store-connection-error): ... this, and adjust users.
(&nix-protocol-error): Rename to...
(&store-protocol-error): ... this, adjust users.
(&nix-error, &nix-connection-error, &nix-protocol-error): Define these
condition types and their getters as deprecrated aliases.
* build-aux/run-system-tests.scm, guix/derivations.scm,
guix/grafts.scm, guix/scripts/challenge.scm,
guix/scripts/graph.scm, guix/scripts/lint.scm,
guix/scripts/offload.scm, guix/serialization.scm,
guix/ssh.scm, guix/tests.scm, guix/ui.scm,
tests/derivations.scm, tests/gexp.scm, tests/guix-daemon.sh,
tests/packages.scm, tests/store.scm, doc/guix.texi: Adjust to use the
new names.
2019-01-21 17:41:11 +01:00
|
|
|
|
(define-condition-type &derivation-error &store-error
|
2015-01-24 22:50:40 +01:00
|
|
|
|
derivation-error?
|
|
|
|
|
(derivation derivation-error-derivation))
|
|
|
|
|
|
|
|
|
|
(define-condition-type &derivation-missing-output-error &derivation-error
|
|
|
|
|
derivation-missing-output-error?
|
|
|
|
|
(output derivation-missing-output))
|
|
|
|
|
|
2012-04-18 23:34:12 +02:00
|
|
|
|
;;;
|
|
|
|
|
;;; Nix derivations, as implemented in Nix's `derivations.cc'.
|
|
|
|
|
;;;
|
|
|
|
|
|
2016-12-17 15:12:19 +01:00
|
|
|
|
(define-immutable-record-type <derivation>
|
2013-09-17 23:00:55 +02:00
|
|
|
|
(make-derivation outputs inputs sources system builder args env-vars
|
|
|
|
|
file-name)
|
2012-04-18 23:34:12 +02:00
|
|
|
|
derivation?
|
|
|
|
|
(outputs derivation-outputs) ; list of name/<derivation-output> pairs
|
|
|
|
|
(inputs derivation-inputs) ; list of <derivation-input>
|
|
|
|
|
(sources derivation-sources) ; list of store paths
|
|
|
|
|
(system derivation-system) ; string
|
|
|
|
|
(builder derivation-builder) ; store path
|
|
|
|
|
(args derivation-builder-arguments) ; list of strings
|
2013-09-17 23:00:55 +02:00
|
|
|
|
(env-vars derivation-builder-environment-vars) ; list of name/value pairs
|
|
|
|
|
(file-name derivation-file-name)) ; the .drv file name
|
2012-04-18 23:34:12 +02:00
|
|
|
|
|
2017-12-12 15:20:47 +01:00
|
|
|
|
(define-immutable-record-type <derivation-output>
|
2014-02-21 23:03:19 +01:00
|
|
|
|
(make-derivation-output path hash-algo hash recursive?)
|
2012-04-18 23:34:12 +02:00
|
|
|
|
derivation-output?
|
|
|
|
|
(path derivation-output-path) ; store path
|
|
|
|
|
(hash-algo derivation-output-hash-algo) ; symbol | #f
|
2014-02-21 23:03:19 +01:00
|
|
|
|
(hash derivation-output-hash) ; bytevector | #f
|
|
|
|
|
(recursive? derivation-output-recursive?)) ; Boolean
|
2012-04-18 23:34:12 +02:00
|
|
|
|
|
2017-12-12 15:20:47 +01:00
|
|
|
|
(define-immutable-record-type <derivation-input>
|
2019-06-23 11:28:29 +02:00
|
|
|
|
(make-derivation-input drv sub-derivations)
|
2012-04-18 23:34:12 +02:00
|
|
|
|
derivation-input?
|
2019-06-23 11:28:29 +02:00
|
|
|
|
(drv derivation-input-derivation) ; <derivation>
|
2012-04-18 23:34:12 +02:00
|
|
|
|
(sub-derivations derivation-input-sub-derivations)) ; list of strings
|
|
|
|
|
|
2019-06-23 11:28:29 +02:00
|
|
|
|
|
|
|
|
|
(define (derivation-input-path input)
|
|
|
|
|
"Return the file name of the derivation INPUT refers to."
|
|
|
|
|
(derivation-file-name (derivation-input-derivation input)))
|
2019-06-19 21:49:22 +02:00
|
|
|
|
|
2019-06-23 11:46:17 +02:00
|
|
|
|
(define* (derivation-input drv #:optional
|
|
|
|
|
(outputs (derivation-output-names drv)))
|
|
|
|
|
"Return a <derivation-input> for the OUTPUTS of DRV."
|
|
|
|
|
;; This is a public interface meant to be more convenient than
|
|
|
|
|
;; 'make-derivation-input' and giving us more control.
|
2019-06-23 11:28:29 +02:00
|
|
|
|
(make-derivation-input drv outputs))
|
|
|
|
|
|
|
|
|
|
(define (derivation-input-key input)
|
|
|
|
|
"Return an object for which 'equal?' and 'hash' are constant-time, and which
|
|
|
|
|
can thus be used as a key for INPUT in lookup tables."
|
|
|
|
|
(cons (derivation-input-path input)
|
|
|
|
|
(derivation-input-sub-derivations input)))
|
2019-06-23 11:46:17 +02:00
|
|
|
|
|
2013-09-18 11:10:02 +02:00
|
|
|
|
(set-record-type-printer! <derivation>
|
|
|
|
|
(lambda (drv port)
|
|
|
|
|
(format port "#<derivation ~a => ~a ~a>"
|
|
|
|
|
(derivation-file-name drv)
|
|
|
|
|
(string-join
|
|
|
|
|
(map (match-lambda
|
|
|
|
|
((_ . output)
|
|
|
|
|
(derivation-output-path output)))
|
|
|
|
|
(derivation-outputs drv)))
|
|
|
|
|
(number->string (object-address drv) 16))))
|
|
|
|
|
|
2014-10-17 20:58:02 +02:00
|
|
|
|
(define (derivation-name drv)
|
|
|
|
|
"Return the base name of DRV."
|
|
|
|
|
(let ((base (store-path-package-name (derivation-file-name drv))))
|
|
|
|
|
(string-drop-right base 4)))
|
|
|
|
|
|
2015-01-09 23:33:42 +01:00
|
|
|
|
(define (derivation-output-names drv)
|
|
|
|
|
"Return the names of the outputs of DRV."
|
|
|
|
|
(match (derivation-outputs drv)
|
|
|
|
|
(((names . _) ...)
|
|
|
|
|
names)))
|
|
|
|
|
|
2012-04-18 23:34:12 +02:00
|
|
|
|
(define (fixed-output-derivation? drv)
|
|
|
|
|
"Return #t if DRV is a fixed-output derivation, such as the result of a
|
|
|
|
|
download with a fixed hash (aka. `fetchurl')."
|
|
|
|
|
(match drv
|
|
|
|
|
(($ <derivation>
|
2014-04-13 00:42:07 +02:00
|
|
|
|
(("out" . ($ <derivation-output> _ (? symbol?) (? bytevector?)))))
|
2012-04-18 23:34:12 +02:00
|
|
|
|
#t)
|
|
|
|
|
(_ #f)))
|
|
|
|
|
|
2016-05-19 23:27:48 +02:00
|
|
|
|
(define (derivation-input<? input1 input2)
|
|
|
|
|
"Compare INPUT1 and INPUT2, two <derivation-input>."
|
|
|
|
|
(string<? (derivation-input-path input1)
|
|
|
|
|
(derivation-input-path input2)))
|
|
|
|
|
|
2013-04-17 00:06:59 +02:00
|
|
|
|
(define (derivation-input-output-paths input)
|
|
|
|
|
"Return the list of output paths corresponding to INPUT, a
|
|
|
|
|
<derivation-input>."
|
|
|
|
|
(match input
|
2019-06-23 11:28:29 +02:00
|
|
|
|
(($ <derivation-input> drv sub-drvs)
|
|
|
|
|
(map (cut derivation->output-path drv <>)
|
2013-04-17 00:06:59 +02:00
|
|
|
|
sub-drvs))))
|
|
|
|
|
|
2019-07-10 18:39:25 +02:00
|
|
|
|
(define (derivation-input-output-path input)
|
|
|
|
|
"Return the output file name of INPUT. If INPUT has more than one outputs,
|
|
|
|
|
an error is raised."
|
|
|
|
|
(match input
|
|
|
|
|
(($ <derivation-input> drv (output))
|
|
|
|
|
(derivation->output-path drv output))))
|
|
|
|
|
|
2015-03-25 09:42:45 +01:00
|
|
|
|
(define (valid-derivation-input? store input)
|
|
|
|
|
"Return true if INPUT is valid--i.e., if all the outputs it requests are in
|
|
|
|
|
the store."
|
|
|
|
|
(every (cut valid-path? store <>)
|
|
|
|
|
(derivation-input-output-paths input)))
|
|
|
|
|
|
2016-05-19 23:27:48 +02:00
|
|
|
|
(define (coalesce-duplicate-inputs inputs)
|
|
|
|
|
"Return a list of inputs, such that when INPUTS contains the same DRV twice,
|
|
|
|
|
they are coalesced, with their sub-derivations merged. This is needed because
|
|
|
|
|
Nix itself keeps only one of them."
|
|
|
|
|
(fold (lambda (input result)
|
|
|
|
|
(match input
|
2019-06-23 11:28:29 +02:00
|
|
|
|
(($ <derivation-input> (= derivation-file-name path) sub-drvs)
|
2016-05-19 23:27:48 +02:00
|
|
|
|
;; XXX: quadratic
|
|
|
|
|
(match (find (match-lambda
|
2019-06-23 11:28:29 +02:00
|
|
|
|
(($ <derivation-input> (= derivation-file-name p)
|
|
|
|
|
s)
|
2016-05-19 23:27:48 +02:00
|
|
|
|
(string=? p path)))
|
|
|
|
|
result)
|
|
|
|
|
(#f
|
|
|
|
|
(cons input result))
|
2019-06-23 11:28:29 +02:00
|
|
|
|
((and dup ($ <derivation-input> drv sub-drvs2))
|
2016-05-19 23:27:48 +02:00
|
|
|
|
;; Merge DUP with INPUT.
|
|
|
|
|
(let ((sub-drvs (delete-duplicates
|
|
|
|
|
(append sub-drvs sub-drvs2))))
|
2019-06-23 11:28:29 +02:00
|
|
|
|
(cons (make-derivation-input drv (sort sub-drvs string<?))
|
2016-05-19 23:27:48 +02:00
|
|
|
|
(delq dup result))))))))
|
|
|
|
|
'()
|
|
|
|
|
inputs))
|
|
|
|
|
|
2015-03-25 09:42:45 +01:00
|
|
|
|
(define* (derivation-prerequisites drv #:optional (cut? (const #f)))
|
|
|
|
|
"Return the list of derivation-inputs required to build DRV, recursively.
|
|
|
|
|
|
|
|
|
|
CUT? is a predicate that is passed a derivation-input and returns true to
|
|
|
|
|
eliminate the given input and its dependencies from the search. An example of
|
2018-01-10 23:09:05 +01:00
|
|
|
|
such a predicate is 'valid-derivation-input?'; when it is used as CUT?, the
|
2015-03-25 09:42:45 +01:00
|
|
|
|
result is the set of prerequisites of DRV not already in valid."
|
2015-01-11 23:04:07 +01:00
|
|
|
|
(let loop ((drv drv)
|
|
|
|
|
(result '())
|
|
|
|
|
(input-set (set)))
|
2015-03-25 09:42:45 +01:00
|
|
|
|
(let ((inputs (remove (lambda (input)
|
2019-06-23 11:28:29 +02:00
|
|
|
|
(or (set-contains? input-set
|
|
|
|
|
(derivation-input-key input))
|
2015-03-25 09:42:45 +01:00
|
|
|
|
(cut? input)))
|
2012-07-01 00:37:03 +02:00
|
|
|
|
(derivation-inputs drv))))
|
2015-01-11 23:04:07 +01:00
|
|
|
|
(fold2 loop
|
|
|
|
|
(append inputs result)
|
2019-06-23 11:28:29 +02:00
|
|
|
|
(fold set-insert input-set
|
|
|
|
|
(map derivation-input-key inputs))
|
2019-06-19 21:49:22 +02:00
|
|
|
|
(map derivation-input-derivation inputs)))))
|
2012-07-01 00:37:03 +02:00
|
|
|
|
|
2014-10-28 18:05:17 +01:00
|
|
|
|
(define (offloadable-derivation? drv)
|
|
|
|
|
"Return true if DRV can be offloaded, false otherwise."
|
|
|
|
|
(match (assoc "preferLocalBuild"
|
|
|
|
|
(derivation-builder-environment-vars drv))
|
|
|
|
|
(("preferLocalBuild" . "1") #f)
|
|
|
|
|
(_ #t)))
|
|
|
|
|
|
2015-07-03 00:05:16 +02:00
|
|
|
|
(define (substitutable-derivation? drv)
|
|
|
|
|
"Return #t if DRV can be substituted."
|
|
|
|
|
(match (assoc "allowSubstitutes"
|
|
|
|
|
(derivation-builder-environment-vars drv))
|
|
|
|
|
(("allowSubstitutes" . value)
|
|
|
|
|
(string=? value "1"))
|
|
|
|
|
(_ #t)))
|
2014-10-28 18:05:17 +01:00
|
|
|
|
|
2015-01-10 00:39:59 +01:00
|
|
|
|
(define (derivation-output-paths drv sub-drvs)
|
|
|
|
|
"Return the output paths of outputs SUB-DRVS of DRV."
|
|
|
|
|
(match drv
|
|
|
|
|
(($ <derivation> outputs)
|
|
|
|
|
(map (lambda (sub-drv)
|
|
|
|
|
(derivation-output-path (assoc-ref outputs sub-drv)))
|
|
|
|
|
sub-drvs))))
|
|
|
|
|
|
2019-07-05 00:09:27 +02:00
|
|
|
|
(define* (substitution-oracle store inputs-or-drv
|
2015-12-09 10:30:03 +01:00
|
|
|
|
#:key (mode (build-mode normal)))
|
2015-01-10 00:39:59 +01:00
|
|
|
|
"Return a one-argument procedure that, when passed a store file name,
|
2017-05-31 09:55:56 +02:00
|
|
|
|
returns a 'substitutable?' if it's substitutable and #f otherwise.
|
2019-07-05 00:09:27 +02:00
|
|
|
|
|
|
|
|
|
The returned procedure knows about all substitutes for all the derivation
|
|
|
|
|
inputs or derivations listed in INPUTS-OR-DRV, *except* those that are already
|
|
|
|
|
valid (that is, it won't bother checking whether an item is substitutable if
|
|
|
|
|
it's already on disk); it also knows about their prerequisites, unless they
|
|
|
|
|
are themselves substitutable.
|
2015-01-10 00:39:59 +01:00
|
|
|
|
|
2017-05-31 09:55:56 +02:00
|
|
|
|
Creating a single oracle (thus making a single 'substitutable-path-info' call) and
|
2015-01-10 00:39:59 +01:00
|
|
|
|
reusing it is much more efficient than calling 'has-substitutes?' or similar
|
|
|
|
|
repeatedly, because it avoids the costs associated with launching the
|
|
|
|
|
substituter many times."
|
2015-03-25 09:48:52 +01:00
|
|
|
|
(define valid-input?
|
|
|
|
|
(cut valid-derivation-input? store <>))
|
|
|
|
|
|
2019-07-05 00:09:27 +02:00
|
|
|
|
(define (closure inputs)
|
|
|
|
|
(let loop ((inputs inputs)
|
|
|
|
|
(closure '())
|
|
|
|
|
(visited (set)))
|
|
|
|
|
(match inputs
|
|
|
|
|
(()
|
|
|
|
|
(reverse closure))
|
|
|
|
|
((input rest ...)
|
|
|
|
|
(let ((key (derivation-input-key input)))
|
|
|
|
|
(cond ((set-contains? visited key)
|
|
|
|
|
(loop rest closure visited))
|
|
|
|
|
((valid-input? input)
|
|
|
|
|
(loop rest closure (set-insert key visited)))
|
|
|
|
|
(else
|
2019-07-03 22:42:19 +02:00
|
|
|
|
(let ((drv (derivation-input-derivation input)))
|
2019-07-05 00:09:27 +02:00
|
|
|
|
(loop (append (derivation-inputs drv) rest)
|
|
|
|
|
(if (substitutable-derivation? drv)
|
|
|
|
|
(cons input closure)
|
|
|
|
|
closure)
|
|
|
|
|
(set-insert key visited))))))))))
|
|
|
|
|
|
|
|
|
|
(let* ((inputs (closure (map (match-lambda
|
|
|
|
|
((? derivation-input? input)
|
|
|
|
|
input)
|
|
|
|
|
((? derivation? drv)
|
|
|
|
|
(derivation-input drv)))
|
|
|
|
|
inputs-or-drv)))
|
|
|
|
|
(items (append-map derivation-input-output-paths inputs))
|
|
|
|
|
(subst (fold (lambda (subst vhash)
|
|
|
|
|
(vhash-cons (substitutable-path subst) subst
|
|
|
|
|
vhash))
|
|
|
|
|
vlist-null
|
|
|
|
|
(substitutable-path-info store items))))
|
2017-05-31 09:55:56 +02:00
|
|
|
|
(lambda (item)
|
|
|
|
|
(match (vhash-assoc item subst)
|
|
|
|
|
(#f #f)
|
|
|
|
|
((key . value) value)))))
|
2015-01-10 00:39:59 +01:00
|
|
|
|
|
2019-07-04 23:09:11 +02:00
|
|
|
|
(define (dependencies-of-substitutables substitutables inputs)
|
|
|
|
|
"Return the subset of INPUTS whose output file names is among the references
|
|
|
|
|
of SUBSTITUTABLES."
|
|
|
|
|
(let ((items (fold set-insert (set)
|
|
|
|
|
(append-map substitutable-references substitutables))))
|
|
|
|
|
(filter (lambda (input)
|
|
|
|
|
(any (cut set-contains? items <>)
|
|
|
|
|
(derivation-input-output-paths input)))
|
|
|
|
|
inputs)))
|
|
|
|
|
|
2019-06-19 22:05:06 +02:00
|
|
|
|
(define* (derivation-build-plan store inputs
|
|
|
|
|
#:key
|
|
|
|
|
(mode (build-mode normal))
|
|
|
|
|
(substitutable-info
|
|
|
|
|
(substitution-oracle
|
2019-07-05 00:09:27 +02:00
|
|
|
|
store inputs #:mode mode)))
|
2019-06-19 22:05:06 +02:00
|
|
|
|
"Given INPUTS, a list of derivation-inputs, return two values: the list of
|
|
|
|
|
derivation to build, and the list of substitutable items that, together,
|
|
|
|
|
allows INPUTS to be realized.
|
|
|
|
|
|
|
|
|
|
SUBSTITUTABLE-INFO must be a one-argument procedure similar to that returned
|
|
|
|
|
by 'substitution-oracle'."
|
|
|
|
|
(define (built? item)
|
|
|
|
|
(valid-path? store item))
|
|
|
|
|
|
|
|
|
|
(define (input-built? input)
|
2015-12-09 10:30:03 +01:00
|
|
|
|
;; In 'check' mode, assume that DRV is not built.
|
|
|
|
|
(and (not (and (eqv? mode (build-mode check))
|
2019-06-19 22:05:06 +02:00
|
|
|
|
(member input inputs)))
|
|
|
|
|
(every built? (derivation-input-output-paths input))))
|
|
|
|
|
|
|
|
|
|
(define (input-substitutable-info input)
|
|
|
|
|
(and (substitutable-derivation? (derivation-input-derivation input))
|
|
|
|
|
(let* ((items (derivation-input-output-paths input))
|
|
|
|
|
(info (filter-map substitutable-info items)))
|
|
|
|
|
(and (= (length info) (length items))
|
2017-05-31 11:06:42 +02:00
|
|
|
|
info))))
|
2013-04-17 00:06:59 +02:00
|
|
|
|
|
2019-06-19 22:05:06 +02:00
|
|
|
|
(let loop ((inputs inputs) ;list of <derivation-input>
|
|
|
|
|
(build '()) ;list of <derivation>
|
|
|
|
|
(substitute '()) ;list of <substitutable>
|
|
|
|
|
(visited (set))) ;set of <derivation-input>
|
|
|
|
|
(match inputs
|
|
|
|
|
(()
|
|
|
|
|
(values build substitute))
|
|
|
|
|
((input rest ...)
|
2019-07-04 23:09:11 +02:00
|
|
|
|
(let ((key (derivation-input-key input))
|
|
|
|
|
(deps (derivation-inputs
|
|
|
|
|
(derivation-input-derivation input))))
|
2019-06-23 11:28:29 +02:00
|
|
|
|
(cond ((set-contains? visited key)
|
|
|
|
|
(loop rest build substitute visited))
|
|
|
|
|
((input-built? input)
|
|
|
|
|
(loop rest build substitute
|
|
|
|
|
(set-insert key visited)))
|
|
|
|
|
((input-substitutable-info input)
|
|
|
|
|
=>
|
|
|
|
|
(lambda (substitutables)
|
2019-07-04 23:09:11 +02:00
|
|
|
|
(loop (append (dependencies-of-substitutables substitutables
|
|
|
|
|
deps)
|
|
|
|
|
rest)
|
|
|
|
|
build
|
2019-06-23 11:28:29 +02:00
|
|
|
|
(append substitutables substitute)
|
|
|
|
|
(set-insert key visited))))
|
|
|
|
|
(else
|
2019-07-04 23:09:11 +02:00
|
|
|
|
(loop (append deps rest)
|
|
|
|
|
(cons (derivation-input-derivation input) build)
|
|
|
|
|
substitute
|
|
|
|
|
(set-insert key visited)))))))))
|
2019-06-19 22:05:06 +02:00
|
|
|
|
|
|
|
|
|
(define-deprecated (derivation-prerequisites-to-build store drv #:rest rest)
|
|
|
|
|
derivation-build-plan
|
|
|
|
|
(let-values (((build download)
|
|
|
|
|
(apply derivation-build-plan store
|
|
|
|
|
(list (derivation-input drv)) rest)))
|
|
|
|
|
(values (map derivation-input build) download)))
|
2012-07-01 00:37:03 +02:00
|
|
|
|
|
2019-06-23 11:28:29 +02:00
|
|
|
|
(define* (read-derivation drv-port
|
|
|
|
|
#:optional (read-derivation-from-file
|
|
|
|
|
read-derivation-from-file))
|
2017-06-12 17:11:22 +02:00
|
|
|
|
"Read the derivation from DRV-PORT and return the corresponding <derivation>
|
2019-06-23 11:28:29 +02:00
|
|
|
|
object. Call READ-DERIVATION-FROM-FILE to read derivations declared as inputs
|
|
|
|
|
of the derivation being parsed.
|
|
|
|
|
|
|
|
|
|
Most of the time you'll want to use 'read-derivation-from-file', which caches
|
|
|
|
|
things as appropriate and is thus more efficient."
|
2012-04-18 23:34:12 +02:00
|
|
|
|
|
|
|
|
|
(define comma (string->symbol ","))
|
|
|
|
|
|
|
|
|
|
(define (ununquote x)
|
|
|
|
|
(match x
|
|
|
|
|
(('unquote x) (ununquote x))
|
|
|
|
|
((x ...) (map ununquote x))
|
|
|
|
|
(_ x)))
|
|
|
|
|
|
|
|
|
|
(define (outputs->alist x)
|
|
|
|
|
(fold-right (lambda (output result)
|
|
|
|
|
(match output
|
|
|
|
|
((name path "" "")
|
|
|
|
|
(alist-cons name
|
2014-02-21 23:03:19 +01:00
|
|
|
|
(make-derivation-output path #f #f #f)
|
2012-04-18 23:34:12 +02:00
|
|
|
|
result))
|
|
|
|
|
((name path hash-algo hash)
|
|
|
|
|
;; fixed-output
|
2014-02-21 23:03:19 +01:00
|
|
|
|
(let* ((rec? (string-prefix? "r:" hash-algo))
|
|
|
|
|
(algo (string->symbol
|
|
|
|
|
(if rec?
|
|
|
|
|
(string-drop hash-algo 2)
|
|
|
|
|
hash-algo)))
|
|
|
|
|
(hash (base16-string->bytevector hash)))
|
2012-04-18 23:34:12 +02:00
|
|
|
|
(alist-cons name
|
2014-02-21 23:03:19 +01:00
|
|
|
|
(make-derivation-output path algo
|
|
|
|
|
hash rec?)
|
2012-04-18 23:34:12 +02:00
|
|
|
|
result)))))
|
|
|
|
|
'()
|
|
|
|
|
x))
|
|
|
|
|
|
|
|
|
|
(define (make-input-drvs x)
|
|
|
|
|
(fold-right (lambda (input result)
|
|
|
|
|
(match input
|
|
|
|
|
((path (sub-drvs ...))
|
2019-06-23 11:28:29 +02:00
|
|
|
|
(let ((drv (read-derivation-from-file path)))
|
|
|
|
|
(cons (make-derivation-input drv sub-drvs)
|
|
|
|
|
result)))))
|
2012-04-18 23:34:12 +02:00
|
|
|
|
'()
|
|
|
|
|
x))
|
|
|
|
|
|
2012-10-06 01:24:46 +02:00
|
|
|
|
;; The contents of a derivation are typically ASCII, but choosing
|
|
|
|
|
;; UTF-8 allows us to take the fast path for Guile's `scm_getc'.
|
|
|
|
|
(set-port-encoding! drv-port "UTF-8")
|
|
|
|
|
|
2012-04-18 23:34:12 +02:00
|
|
|
|
(let loop ((exp (read drv-port))
|
|
|
|
|
(result '()))
|
|
|
|
|
(match exp
|
|
|
|
|
((? eof-object?)
|
|
|
|
|
(let ((result (reverse result)))
|
|
|
|
|
(match result
|
|
|
|
|
(('Derive ((outputs ...) (input-drvs ...)
|
|
|
|
|
(input-srcs ...)
|
|
|
|
|
(? string? system)
|
|
|
|
|
(? string? builder)
|
|
|
|
|
((? string? args) ...)
|
|
|
|
|
((var value) ...)))
|
|
|
|
|
(make-derivation (outputs->alist outputs)
|
|
|
|
|
(make-input-drvs input-drvs)
|
|
|
|
|
input-srcs
|
|
|
|
|
system builder args
|
2013-09-17 23:00:55 +02:00
|
|
|
|
(fold-right alist-cons '() var value)
|
|
|
|
|
(port-filename drv-port)))
|
2012-04-18 23:34:12 +02:00
|
|
|
|
(_
|
|
|
|
|
(error "failed to parse derivation" drv-port result)))))
|
|
|
|
|
((? (cut eq? <> comma))
|
|
|
|
|
(loop (read drv-port) result))
|
|
|
|
|
(_
|
|
|
|
|
(loop (read drv-port)
|
|
|
|
|
(cons (ununquote exp) result))))))
|
|
|
|
|
|
2017-01-05 23:40:59 +01:00
|
|
|
|
(define %derivation-cache
|
|
|
|
|
;; Maps derivation file names to <derivation> objects.
|
|
|
|
|
;; XXX: This is redundant with 'atts-cache' in the store.
|
|
|
|
|
(make-weak-value-hash-table 200))
|
|
|
|
|
|
2017-06-12 17:11:22 +02:00
|
|
|
|
(define (read-derivation-from-file file)
|
|
|
|
|
"Read the derivation in FILE, a '.drv' file, and return the corresponding
|
2013-01-30 18:56:20 +01:00
|
|
|
|
<derivation> object."
|
2017-06-12 17:11:22 +02:00
|
|
|
|
;; Memoize that operation because 'read-derivation' is quite expensive,
|
2017-01-05 23:40:59 +01:00
|
|
|
|
;; and because the same argument is read more than 15 times on average
|
|
|
|
|
;; during something like (package-derivation s gdb).
|
2017-06-12 17:11:22 +02:00
|
|
|
|
(or (and file (hash-ref %derivation-cache file))
|
|
|
|
|
(let ((drv (call-with-input-file file read-derivation)))
|
|
|
|
|
(hash-set! %derivation-cache file drv)
|
|
|
|
|
drv)))
|
2013-01-30 18:56:20 +01:00
|
|
|
|
|
2013-03-16 16:46:46 +01:00
|
|
|
|
(define-inlinable (write-sequence lst write-item port)
|
|
|
|
|
;; Write each element of LST with WRITE-ITEM to PORT, separating them with a
|
|
|
|
|
;; comma.
|
|
|
|
|
(match lst
|
|
|
|
|
(()
|
|
|
|
|
#t)
|
|
|
|
|
((prefix (... ...) last)
|
|
|
|
|
(for-each (lambda (item)
|
|
|
|
|
(write-item item port)
|
|
|
|
|
(display "," port))
|
|
|
|
|
prefix)
|
|
|
|
|
(write-item last port))))
|
|
|
|
|
|
|
|
|
|
(define-inlinable (write-list lst write-item port)
|
|
|
|
|
;; Write LST as a derivation list to PORT, using WRITE-ITEM to write each
|
|
|
|
|
;; element.
|
|
|
|
|
(display "[" port)
|
|
|
|
|
(write-sequence lst write-item port)
|
|
|
|
|
(display "]" port))
|
|
|
|
|
|
|
|
|
|
(define-inlinable (write-tuple lst write-item port)
|
|
|
|
|
;; Same, but write LST as a tuple.
|
|
|
|
|
(display "(" port)
|
|
|
|
|
(write-sequence lst write-item port)
|
|
|
|
|
(display ")" port))
|
|
|
|
|
|
2012-04-18 23:34:12 +02:00
|
|
|
|
(define (write-derivation drv port)
|
|
|
|
|
"Write the ATerm-like serialization of DRV to PORT. See Section 2.4 of
|
|
|
|
|
Eelco Dolstra's PhD dissertation for an overview of a previous version of
|
|
|
|
|
that form."
|
2012-09-01 19:21:06 +02:00
|
|
|
|
|
|
|
|
|
;; Make sure we're using the faster implementation.
|
|
|
|
|
(define format simple-format)
|
|
|
|
|
|
2013-03-16 16:46:46 +01:00
|
|
|
|
(define (write-string-list lst)
|
|
|
|
|
(write-list lst write port))
|
2012-04-18 23:34:12 +02:00
|
|
|
|
|
2013-03-16 16:46:46 +01:00
|
|
|
|
(define (write-output output port)
|
|
|
|
|
(match output
|
2014-02-21 23:03:19 +01:00
|
|
|
|
((name . ($ <derivation-output> path hash-algo hash recursive?))
|
2013-03-16 16:46:46 +01:00
|
|
|
|
(write-tuple (list name path
|
2014-02-21 23:03:19 +01:00
|
|
|
|
(if hash-algo
|
|
|
|
|
(string-append (if recursive? "r:" "")
|
|
|
|
|
(symbol->string hash-algo))
|
|
|
|
|
"")
|
2013-03-16 16:46:46 +01:00
|
|
|
|
(or (and=> hash bytevector->base16-string)
|
|
|
|
|
""))
|
|
|
|
|
write
|
|
|
|
|
port))))
|
|
|
|
|
|
|
|
|
|
(define (write-input input port)
|
|
|
|
|
(match input
|
2019-06-23 11:28:29 +02:00
|
|
|
|
(($ <derivation-input> obj sub-drvs)
|
2017-01-05 21:49:45 +01:00
|
|
|
|
(display "(\"" port)
|
2019-06-23 11:28:29 +02:00
|
|
|
|
|
|
|
|
|
;; 'derivation/masked-inputs' produces objects that contain a string
|
|
|
|
|
;; instead of a <derivation>, so we need to account for that.
|
|
|
|
|
(display (if (derivation? obj)
|
|
|
|
|
(derivation-file-name obj)
|
|
|
|
|
obj)
|
|
|
|
|
port)
|
2017-01-05 21:49:45 +01:00
|
|
|
|
(display "\"," port)
|
2016-05-19 23:27:48 +02:00
|
|
|
|
(write-string-list sub-drvs)
|
2013-03-16 16:46:46 +01:00
|
|
|
|
(display ")" port))))
|
|
|
|
|
|
|
|
|
|
(define (write-env-var env-var port)
|
|
|
|
|
(match env-var
|
|
|
|
|
((name . value)
|
|
|
|
|
(display "(" port)
|
|
|
|
|
(write name port)
|
|
|
|
|
(display "," port)
|
|
|
|
|
(write value port)
|
|
|
|
|
(display ")" port))))
|
|
|
|
|
|
2016-05-19 23:27:48 +02:00
|
|
|
|
;; Assume all the lists we are writing are already sorted.
|
2012-04-18 23:34:12 +02:00
|
|
|
|
(match drv
|
|
|
|
|
(($ <derivation> outputs inputs sources
|
|
|
|
|
system builder args env-vars)
|
|
|
|
|
(display "Derive(" port)
|
2016-05-19 23:27:48 +02:00
|
|
|
|
(write-list outputs write-output port)
|
2012-04-18 23:34:12 +02:00
|
|
|
|
(display "," port)
|
2016-05-19 23:27:48 +02:00
|
|
|
|
(write-list inputs write-input port)
|
2012-04-18 23:34:12 +02:00
|
|
|
|
(display "," port)
|
2016-05-19 23:27:48 +02:00
|
|
|
|
(write-string-list sources)
|
2017-01-05 21:49:45 +01:00
|
|
|
|
(simple-format port ",\"~a\",\"~a\"," system builder)
|
2013-03-16 16:46:46 +01:00
|
|
|
|
(write-string-list args)
|
2012-04-18 23:34:12 +02:00
|
|
|
|
(display "," port)
|
2016-05-19 23:27:48 +02:00
|
|
|
|
(write-list env-vars write-env-var port)
|
2012-04-18 23:34:12 +02:00
|
|
|
|
(display ")" port))))
|
|
|
|
|
|
2017-04-20 18:46:38 +02:00
|
|
|
|
(define derivation->bytevector
|
2017-01-28 17:09:34 +01:00
|
|
|
|
(mlambda (drv)
|
2017-04-20 18:46:38 +02:00
|
|
|
|
"Return the external representation of DRV as a UTF-8-encoded string."
|
2017-01-28 17:09:34 +01:00
|
|
|
|
(with-fluids ((%default-port-encoding "UTF-8"))
|
2017-04-20 18:46:38 +02:00
|
|
|
|
(call-with-values open-bytevector-output-port
|
|
|
|
|
(lambda (port get-bytevector)
|
|
|
|
|
(write-derivation drv port)
|
|
|
|
|
(get-bytevector))))))
|
2014-04-29 18:13:10 +02:00
|
|
|
|
|
derivations: 'derivation' and related procedures return a single value.
* guix/derivations.scm (derivation->output-path,
derivation->output-paths): New procedures.
(derivation-path->output-path): Use 'derivation->output-path'.
(derivation-path->output-paths): Use 'derivation->output-paths'.
(derivation): Accept 'derivation?' objects as inputs. Return a single
value.
(build-derivations): New procedure.
(compiled-modules): Use 'derivation->output-paths'.
(build-expression->derivation)[source-path]: Add case for when the
input matches 'derivation?'.
[prologue]: Accept 'derivation?' objects in INPUTS.
[mod-dir, go-dir]: Use 'derivation->output-path'.
* guix/download.scm (url-fetch): Adjust to the single-value return.
* guix/packages.scm (package-output): Use 'derivation->output-path'.
* guix/scripts/build.scm (guix-build): When the argument is
'derivation-path?', pass it through 'read-derivation'.
Use 'derivation-file-name' to print out the .drv file names, and to
register them. Use 'derivation->output-path' instead of
'derivation-path->output-path'.
* guix/scripts/package.scm (roll-back): Adjust to the single-value
return.
(guix-package): Use 'derivation->output-path'.
* guix/ui.scm (show-what-to-build): Adjust to deal with 'derivation?'
objects instead of .drv file names.
* gnu/system/grub.scm (grub-configuration-file): Use
'derivation->output-path' instead of 'derivation-path->output-path'.
* gnu/system/vm.scm (qemu-image, system-qemu-image): Likewise.
* tests/builders.scm, tests/derivations.scm, tests/packages.scm,
tests/store.scm, tests/union.scm: Adjust to the new calling
convention.
* doc/guix.texi (Defining Packages, The Store, Derivations): Adjust
accordingly.
2013-09-18 17:01:40 +02:00
|
|
|
|
(define* (derivation->output-path drv #:optional (output "out"))
|
2015-01-24 22:50:40 +01:00
|
|
|
|
"Return the store path of its output OUTPUT. Raise a
|
|
|
|
|
'&derivation-missing-output-error' condition if OUTPUT is not an output of
|
|
|
|
|
DRV."
|
|
|
|
|
(let ((output* (assoc-ref (derivation-outputs drv) output)))
|
|
|
|
|
(if output*
|
|
|
|
|
(derivation-output-path output*)
|
|
|
|
|
(raise (condition (&derivation-missing-output-error
|
|
|
|
|
(derivation drv)
|
|
|
|
|
(output output)))))))
|
derivations: 'derivation' and related procedures return a single value.
* guix/derivations.scm (derivation->output-path,
derivation->output-paths): New procedures.
(derivation-path->output-path): Use 'derivation->output-path'.
(derivation-path->output-paths): Use 'derivation->output-paths'.
(derivation): Accept 'derivation?' objects as inputs. Return a single
value.
(build-derivations): New procedure.
(compiled-modules): Use 'derivation->output-paths'.
(build-expression->derivation)[source-path]: Add case for when the
input matches 'derivation?'.
[prologue]: Accept 'derivation?' objects in INPUTS.
[mod-dir, go-dir]: Use 'derivation->output-path'.
* guix/download.scm (url-fetch): Adjust to the single-value return.
* guix/packages.scm (package-output): Use 'derivation->output-path'.
* guix/scripts/build.scm (guix-build): When the argument is
'derivation-path?', pass it through 'read-derivation'.
Use 'derivation-file-name' to print out the .drv file names, and to
register them. Use 'derivation->output-path' instead of
'derivation-path->output-path'.
* guix/scripts/package.scm (roll-back): Adjust to the single-value
return.
(guix-package): Use 'derivation->output-path'.
* guix/ui.scm (show-what-to-build): Adjust to deal with 'derivation?'
objects instead of .drv file names.
* gnu/system/grub.scm (grub-configuration-file): Use
'derivation->output-path' instead of 'derivation-path->output-path'.
* gnu/system/vm.scm (qemu-image, system-qemu-image): Likewise.
* tests/builders.scm, tests/derivations.scm, tests/packages.scm,
tests/store.scm, tests/union.scm: Adjust to the new calling
convention.
* doc/guix.texi (Defining Packages, The Store, Derivations): Adjust
accordingly.
2013-09-18 17:01:40 +02:00
|
|
|
|
|
|
|
|
|
(define (derivation->output-paths drv)
|
|
|
|
|
"Return the list of name/path pairs of the outputs of DRV."
|
|
|
|
|
(map (match-lambda
|
|
|
|
|
((name . output)
|
|
|
|
|
(cons name (derivation-output-path output))))
|
|
|
|
|
(derivation-outputs drv)))
|
|
|
|
|
|
2012-09-01 19:21:06 +02:00
|
|
|
|
(define derivation-path->output-path
|
|
|
|
|
;; This procedure is called frequently, so memoize it.
|
2017-01-28 17:09:34 +01:00
|
|
|
|
(let ((memoized (mlambda (path output)
|
2017-06-12 17:11:22 +02:00
|
|
|
|
(derivation->output-path (read-derivation-from-file path)
|
2017-01-28 17:09:34 +01:00
|
|
|
|
output))))
|
|
|
|
|
(lambda* (path #:optional (output "out"))
|
|
|
|
|
"Read the derivation from PATH (`/gnu/store/xxx.drv'), and return the store
|
2012-06-07 23:15:00 +02:00
|
|
|
|
path of its output OUTPUT."
|
2017-01-28 17:09:34 +01:00
|
|
|
|
(memoized path output))))
|
2012-06-07 23:15:00 +02:00
|
|
|
|
|
2013-01-05 23:51:13 +01:00
|
|
|
|
(define (derivation-path->output-paths path)
|
2014-03-10 23:58:40 +01:00
|
|
|
|
"Read the derivation from PATH (`/gnu/store/xxx.drv'), and return the
|
2013-01-05 23:51:13 +01:00
|
|
|
|
list of name/path pairs of its outputs."
|
2017-06-12 17:11:22 +02:00
|
|
|
|
(derivation->output-paths (read-derivation-from-file path)))
|
2013-01-05 23:51:13 +01:00
|
|
|
|
|
2012-06-07 23:15:00 +02:00
|
|
|
|
|
|
|
|
|
;;;
|
|
|
|
|
;;; Derivation primitive.
|
|
|
|
|
;;;
|
|
|
|
|
|
2019-07-03 22:36:56 +02:00
|
|
|
|
(define derivation-base16-hash
|
|
|
|
|
(mlambdaq (drv)
|
|
|
|
|
"Return a string containing the base16 representation of the hash of DRV."
|
|
|
|
|
(bytevector->base16-string (derivation-hash drv))))
|
2014-10-13 22:33:31 +02:00
|
|
|
|
|
2017-12-13 14:00:20 +01:00
|
|
|
|
(define (derivation/masked-inputs drv)
|
|
|
|
|
"Assuming DRV is a regular derivation (not fixed-output), replace the file
|
|
|
|
|
name of each input with that input's hash."
|
|
|
|
|
(match drv
|
|
|
|
|
(($ <derivation> outputs inputs sources
|
|
|
|
|
system builder args env-vars)
|
|
|
|
|
(let ((inputs (map (match-lambda
|
2019-07-03 22:36:56 +02:00
|
|
|
|
(($ <derivation-input> drv sub-drvs)
|
|
|
|
|
(let ((hash (derivation-base16-hash drv)))
|
2017-12-13 14:00:20 +01:00
|
|
|
|
(make-derivation-input hash sub-drvs))))
|
|
|
|
|
inputs)))
|
|
|
|
|
(make-derivation outputs
|
2019-08-16 18:41:55 +02:00
|
|
|
|
(sort (delete-duplicates inputs)
|
2019-06-23 11:28:29 +02:00
|
|
|
|
(lambda (drv1 drv2)
|
|
|
|
|
(string<? (derivation-input-derivation drv1)
|
|
|
|
|
(derivation-input-derivation drv2))))
|
2017-12-13 14:00:20 +01:00
|
|
|
|
sources
|
|
|
|
|
system builder args env-vars
|
|
|
|
|
#f)))))
|
|
|
|
|
|
2012-06-07 23:15:00 +02:00
|
|
|
|
(define derivation-hash ; `hashDerivationModulo' in derivations.cc
|
2017-12-13 14:35:44 +01:00
|
|
|
|
(lambda (drv)
|
2012-06-07 23:15:00 +02:00
|
|
|
|
"Return the hash of DRV, modulo its fixed-output inputs, as a bytevector."
|
|
|
|
|
(match drv
|
|
|
|
|
(($ <derivation> ((_ . ($ <derivation-output> path
|
2017-01-28 17:09:34 +01:00
|
|
|
|
(? symbol? hash-algo) (? bytevector? hash)
|
|
|
|
|
(? boolean? recursive?)))))
|
2012-06-07 23:15:00 +02:00
|
|
|
|
;; A fixed-output derivation.
|
2012-04-18 23:34:12 +02:00
|
|
|
|
(sha256
|
2012-06-07 23:15:00 +02:00
|
|
|
|
(string->utf8
|
2014-02-21 23:03:19 +01:00
|
|
|
|
(string-append "fixed:out:"
|
|
|
|
|
(if recursive? "r:" "")
|
|
|
|
|
(symbol->string hash-algo)
|
2012-06-09 18:49:19 +02:00
|
|
|
|
":" (bytevector->base16-string hash)
|
|
|
|
|
":" path))))
|
2017-12-13 14:00:20 +01:00
|
|
|
|
(_
|
|
|
|
|
|
|
|
|
|
;; XXX: At this point this remains faster than `port-sha256', because
|
|
|
|
|
;; the SHA256 port's `write' method gets called for every single
|
|
|
|
|
;; character.
|
|
|
|
|
(sha256 (derivation->bytevector (derivation/masked-inputs drv)))))))
|
2012-04-18 23:34:12 +02:00
|
|
|
|
|
2019-07-10 18:18:19 +02:00
|
|
|
|
|
|
|
|
|
(define (warn-about-derivation-deprecation name)
|
|
|
|
|
;; TRANSLATORS: 'derivation' must not be translated; it refers to the
|
|
|
|
|
;; 'derivation' procedure.
|
|
|
|
|
(warning (G_ "in '~a': deprecated 'derivation' calling convention used~%")
|
|
|
|
|
name))
|
|
|
|
|
|
2013-08-26 22:11:04 +02:00
|
|
|
|
(define* (derivation store name builder args
|
|
|
|
|
#:key
|
|
|
|
|
(system (%current-system)) (env-vars '())
|
2019-07-08 18:39:20 +02:00
|
|
|
|
(inputs '()) (sources '())
|
|
|
|
|
(outputs '("out"))
|
2014-02-21 23:48:56 +01:00
|
|
|
|
hash hash-algo recursive?
|
2016-03-20 22:40:31 +01:00
|
|
|
|
references-graphs
|
|
|
|
|
allowed-references disallowed-references
|
2015-07-03 00:05:16 +02:00
|
|
|
|
leaked-env-vars local-build?
|
2018-11-26 22:14:11 +01:00
|
|
|
|
(substitutable? #t)
|
2019-07-10 18:18:19 +02:00
|
|
|
|
(properties '())
|
|
|
|
|
(%deprecation-warning? #t))
|
derivations: 'derivation' and related procedures return a single value.
* guix/derivations.scm (derivation->output-path,
derivation->output-paths): New procedures.
(derivation-path->output-path): Use 'derivation->output-path'.
(derivation-path->output-paths): Use 'derivation->output-paths'.
(derivation): Accept 'derivation?' objects as inputs. Return a single
value.
(build-derivations): New procedure.
(compiled-modules): Use 'derivation->output-paths'.
(build-expression->derivation)[source-path]: Add case for when the
input matches 'derivation?'.
[prologue]: Accept 'derivation?' objects in INPUTS.
[mod-dir, go-dir]: Use 'derivation->output-path'.
* guix/download.scm (url-fetch): Adjust to the single-value return.
* guix/packages.scm (package-output): Use 'derivation->output-path'.
* guix/scripts/build.scm (guix-build): When the argument is
'derivation-path?', pass it through 'read-derivation'.
Use 'derivation-file-name' to print out the .drv file names, and to
register them. Use 'derivation->output-path' instead of
'derivation-path->output-path'.
* guix/scripts/package.scm (roll-back): Adjust to the single-value
return.
(guix-package): Use 'derivation->output-path'.
* guix/ui.scm (show-what-to-build): Adjust to deal with 'derivation?'
objects instead of .drv file names.
* gnu/system/grub.scm (grub-configuration-file): Use
'derivation->output-path' instead of 'derivation-path->output-path'.
* gnu/system/vm.scm (qemu-image, system-qemu-image): Likewise.
* tests/builders.scm, tests/derivations.scm, tests/packages.scm,
tests/store.scm, tests/union.scm: Adjust to the new calling
convention.
* doc/guix.texi (Defining Packages, The Store, Derivations): Adjust
accordingly.
2013-09-18 17:01:40 +02:00
|
|
|
|
"Build a derivation with the given arguments, and return the resulting
|
2014-02-21 23:48:56 +01:00
|
|
|
|
<derivation> object. When HASH and HASH-ALGO are given, a
|
derivations: 'derivation' and related procedures return a single value.
* guix/derivations.scm (derivation->output-path,
derivation->output-paths): New procedures.
(derivation-path->output-path): Use 'derivation->output-path'.
(derivation-path->output-paths): Use 'derivation->output-paths'.
(derivation): Accept 'derivation?' objects as inputs. Return a single
value.
(build-derivations): New procedure.
(compiled-modules): Use 'derivation->output-paths'.
(build-expression->derivation)[source-path]: Add case for when the
input matches 'derivation?'.
[prologue]: Accept 'derivation?' objects in INPUTS.
[mod-dir, go-dir]: Use 'derivation->output-path'.
* guix/download.scm (url-fetch): Adjust to the single-value return.
* guix/packages.scm (package-output): Use 'derivation->output-path'.
* guix/scripts/build.scm (guix-build): When the argument is
'derivation-path?', pass it through 'read-derivation'.
Use 'derivation-file-name' to print out the .drv file names, and to
register them. Use 'derivation->output-path' instead of
'derivation-path->output-path'.
* guix/scripts/package.scm (roll-back): Adjust to the single-value
return.
(guix-package): Use 'derivation->output-path'.
* guix/ui.scm (show-what-to-build): Adjust to deal with 'derivation?'
objects instead of .drv file names.
* gnu/system/grub.scm (grub-configuration-file): Use
'derivation->output-path' instead of 'derivation-path->output-path'.
* gnu/system/vm.scm (qemu-image, system-qemu-image): Likewise.
* tests/builders.scm, tests/derivations.scm, tests/packages.scm,
tests/store.scm, tests/union.scm: Adjust to the new calling
convention.
* doc/guix.texi (Defining Packages, The Store, Derivations): Adjust
accordingly.
2013-09-18 17:01:40 +02:00
|
|
|
|
fixed-output derivation is created---i.e., one whose result is known in
|
2014-02-21 23:03:19 +01:00
|
|
|
|
advance, such as a file download. If, in addition, RECURSIVE? is true, then
|
|
|
|
|
that fixed output may be an executable file or a directory and HASH must be
|
|
|
|
|
the hash of an archive containing this output.
|
2013-08-26 22:12:46 +02:00
|
|
|
|
|
2013-08-27 18:34:49 +02:00
|
|
|
|
When REFERENCES-GRAPHS is true, it must be a list of file name/store path
|
2013-08-26 22:12:46 +02:00
|
|
|
|
pairs. In that case, the reference graph of each store path is exported in
|
2014-01-25 17:04:35 +01:00
|
|
|
|
the build environment in the corresponding file, in a simple text format.
|
|
|
|
|
|
2014-06-01 23:32:26 +02:00
|
|
|
|
When ALLOWED-REFERENCES is true, it must be a list of store items or outputs
|
2016-03-20 22:40:31 +01:00
|
|
|
|
that the derivation's outputs may refer to. Likewise, DISALLOWED-REFERENCES,
|
|
|
|
|
if true, must be a list of things the outputs may not refer to.
|
2014-06-01 23:32:26 +02:00
|
|
|
|
|
2015-04-30 23:51:44 +02:00
|
|
|
|
When LEAKED-ENV-VARS is true, it must be a list of strings denoting
|
|
|
|
|
environment variables that are allowed to \"leak\" from the daemon's
|
|
|
|
|
environment to the build environment. This is only applicable to fixed-output
|
|
|
|
|
derivations--i.e., when HASH is true. The main use is to allow variables such
|
|
|
|
|
as \"http_proxy\" to be passed to derivations that download files.
|
|
|
|
|
|
2014-01-25 17:04:35 +01:00
|
|
|
|
When LOCAL-BUILD? is true, declare that the derivation is not a good candidate
|
|
|
|
|
for offloading and should rather be built locally. This is the case for small
|
2015-07-03 00:05:16 +02:00
|
|
|
|
derivations where the costs of data transfers would outweigh the benefits.
|
|
|
|
|
|
|
|
|
|
When SUBSTITUTABLE? is false, declare that substitutes of the derivation's
|
2018-11-26 22:14:11 +01:00
|
|
|
|
output should not be used.
|
|
|
|
|
|
|
|
|
|
PROPERTIES must be an association list describing \"properties\" of the
|
|
|
|
|
derivation. It is kept as-is, uninterpreted, in the derivation."
|
2012-06-01 23:29:55 +02:00
|
|
|
|
(define (add-output-paths drv)
|
|
|
|
|
;; Return DRV with an actual store path for each of its output and the
|
|
|
|
|
;; corresponding environment variable.
|
|
|
|
|
(match drv
|
|
|
|
|
(($ <derivation> outputs inputs sources
|
|
|
|
|
system builder args env-vars)
|
|
|
|
|
(let* ((drv-hash (derivation-hash drv))
|
|
|
|
|
(outputs (map (match-lambda
|
2012-06-08 21:31:01 +02:00
|
|
|
|
((output-name . ($ <derivation-output>
|
2014-02-21 23:03:19 +01:00
|
|
|
|
_ algo hash rec?))
|
2016-07-20 16:39:19 +02:00
|
|
|
|
(let ((path
|
|
|
|
|
(if hash
|
|
|
|
|
(fixed-output-path name hash
|
|
|
|
|
#:hash-algo algo
|
|
|
|
|
#:output output-name
|
|
|
|
|
#:recursive? rec?)
|
|
|
|
|
(output-path output-name
|
|
|
|
|
drv-hash name))))
|
2012-06-08 21:31:01 +02:00
|
|
|
|
(cons output-name
|
|
|
|
|
(make-derivation-output path algo
|
2014-02-21 23:03:19 +01:00
|
|
|
|
hash rec?)))))
|
2012-06-08 21:31:01 +02:00
|
|
|
|
outputs)))
|
2012-06-01 23:29:55 +02:00
|
|
|
|
(make-derivation outputs inputs sources system builder args
|
|
|
|
|
(map (match-lambda
|
|
|
|
|
((name . value)
|
|
|
|
|
(cons name
|
|
|
|
|
(or (and=> (assoc-ref outputs name)
|
|
|
|
|
derivation-output-path)
|
|
|
|
|
value))))
|
2013-09-17 23:00:55 +02:00
|
|
|
|
env-vars)
|
|
|
|
|
#f)))))
|
2012-06-01 23:29:55 +02:00
|
|
|
|
|
2013-08-26 22:12:46 +02:00
|
|
|
|
(define (user+system-env-vars)
|
|
|
|
|
;; Some options are passed to the build daemon via the env. vars of
|
|
|
|
|
;; derivations (urgh!). We hide that from our API, but here is the place
|
|
|
|
|
;; where we kludgify those options.
|
2014-06-01 23:32:26 +02:00
|
|
|
|
(let ((env-vars `(,@(if local-build?
|
|
|
|
|
`(("preferLocalBuild" . "1"))
|
|
|
|
|
'())
|
2015-07-03 00:05:16 +02:00
|
|
|
|
,@(if (not substitutable?)
|
|
|
|
|
`(("allowSubstitutes" . "0"))
|
|
|
|
|
'())
|
2014-06-01 23:32:26 +02:00
|
|
|
|
,@(if allowed-references
|
|
|
|
|
`(("allowedReferences"
|
|
|
|
|
. ,(string-join allowed-references)))
|
|
|
|
|
'())
|
2016-03-20 22:40:31 +01:00
|
|
|
|
,@(if disallowed-references
|
|
|
|
|
`(("disallowedReferences"
|
|
|
|
|
. ,(string-join disallowed-references)))
|
|
|
|
|
'())
|
2015-04-30 23:51:44 +02:00
|
|
|
|
,@(if leaked-env-vars
|
|
|
|
|
`(("impureEnvVars"
|
|
|
|
|
. ,(string-join leaked-env-vars)))
|
|
|
|
|
'())
|
2018-11-26 22:14:11 +01:00
|
|
|
|
,@(match properties
|
|
|
|
|
(() '())
|
|
|
|
|
(lst `(("guix properties"
|
|
|
|
|
. ,(object->string properties)))))
|
2014-06-01 23:32:26 +02:00
|
|
|
|
,@env-vars)))
|
2014-01-25 17:04:35 +01:00
|
|
|
|
(match references-graphs
|
|
|
|
|
(((file . path) ...)
|
|
|
|
|
(let ((value (map (cut string-append <> " " <>)
|
|
|
|
|
file path)))
|
|
|
|
|
;; XXX: This all breaks down if an element of FILE or PATH contains
|
|
|
|
|
;; white space.
|
|
|
|
|
`(("exportReferencesGraph" . ,(string-join value " "))
|
|
|
|
|
,@env-vars)))
|
|
|
|
|
(#f
|
|
|
|
|
env-vars))))
|
2013-08-26 22:12:46 +02:00
|
|
|
|
|
|
|
|
|
(define (env-vars-with-empty-outputs env-vars)
|
2012-06-01 23:29:55 +02:00
|
|
|
|
;; Return a variant of ENV-VARS where each OUTPUTS is associated with an
|
2012-07-01 22:55:49 +02:00
|
|
|
|
;; empty string, even outputs that do not appear in ENV-VARS.
|
2012-06-01 23:29:55 +02:00
|
|
|
|
(let ((e (map (match-lambda
|
|
|
|
|
((name . val)
|
|
|
|
|
(if (member name outputs)
|
|
|
|
|
(cons name "")
|
|
|
|
|
(cons name val))))
|
|
|
|
|
env-vars)))
|
2012-07-01 22:55:49 +02:00
|
|
|
|
(fold (lambda (output-name env-vars)
|
|
|
|
|
(if (assoc output-name env-vars)
|
|
|
|
|
env-vars
|
|
|
|
|
(append env-vars `((,output-name . "")))))
|
|
|
|
|
e
|
|
|
|
|
outputs)))
|
2012-06-01 23:29:55 +02:00
|
|
|
|
|
2019-07-10 18:18:19 +02:00
|
|
|
|
(define-syntax-rule (warn-deprecation name)
|
|
|
|
|
(when %deprecation-warning?
|
|
|
|
|
(warn-about-derivation-deprecation name)))
|
|
|
|
|
|
2016-05-19 23:27:48 +02:00
|
|
|
|
(define input->derivation-input
|
|
|
|
|
(match-lambda
|
2019-07-08 18:39:20 +02:00
|
|
|
|
((? derivation-input? input)
|
|
|
|
|
input)
|
2016-05-19 23:27:48 +02:00
|
|
|
|
(((? derivation? drv))
|
2019-07-10 18:18:19 +02:00
|
|
|
|
(warn-deprecation name)
|
2019-06-23 11:28:29 +02:00
|
|
|
|
(make-derivation-input drv '("out")))
|
2016-05-19 23:27:48 +02:00
|
|
|
|
(((? derivation? drv) sub-drvs ...)
|
2019-07-10 18:18:19 +02:00
|
|
|
|
(warn-deprecation name)
|
2019-06-23 11:28:29 +02:00
|
|
|
|
(make-derivation-input drv sub-drvs))
|
2019-07-10 18:18:19 +02:00
|
|
|
|
(_
|
|
|
|
|
(warn-deprecation name)
|
|
|
|
|
#f)))
|
2019-06-23 11:28:29 +02:00
|
|
|
|
|
|
|
|
|
(define input->source
|
|
|
|
|
(match-lambda
|
|
|
|
|
(((? string? input) . _)
|
2019-07-10 18:18:19 +02:00
|
|
|
|
(warn-deprecation name)
|
2019-06-23 11:28:29 +02:00
|
|
|
|
(if (direct-store-path? input)
|
|
|
|
|
input
|
|
|
|
|
(add-to-store store (basename input)
|
|
|
|
|
#t "sha256" input)))
|
|
|
|
|
(_ #f)))
|
2016-05-19 23:27:48 +02:00
|
|
|
|
|
|
|
|
|
;; Note: lists are sorted alphabetically, to conform with the behavior of
|
|
|
|
|
;; C++ `std::map' in Nix itself.
|
|
|
|
|
|
2012-06-01 23:29:55 +02:00
|
|
|
|
(let* ((outputs (map (lambda (name)
|
|
|
|
|
;; Return outputs with an empty path.
|
|
|
|
|
(cons name
|
2014-02-21 23:03:19 +01:00
|
|
|
|
(make-derivation-output "" hash-algo
|
|
|
|
|
hash recursive?)))
|
2016-05-19 23:27:48 +02:00
|
|
|
|
(sort outputs string<?)))
|
2019-06-23 11:28:29 +02:00
|
|
|
|
(sources (sort (delete-duplicates
|
2019-07-08 18:39:20 +02:00
|
|
|
|
(append (filter-map input->source inputs)
|
|
|
|
|
sources))
|
2019-06-23 11:28:29 +02:00
|
|
|
|
string<?))
|
2016-05-19 23:27:48 +02:00
|
|
|
|
(inputs (sort (coalesce-duplicate-inputs
|
2019-06-23 11:28:29 +02:00
|
|
|
|
(filter-map input->derivation-input inputs))
|
2016-05-19 23:27:48 +02:00
|
|
|
|
derivation-input<?))
|
|
|
|
|
(env-vars (sort (env-vars-with-empty-outputs
|
|
|
|
|
(user+system-env-vars))
|
|
|
|
|
(lambda (e1 e2)
|
|
|
|
|
(string<? (car e1) (car e2)))))
|
2019-06-23 11:28:29 +02:00
|
|
|
|
(drv-masked (make-derivation outputs inputs sources
|
2013-09-17 23:00:55 +02:00
|
|
|
|
system builder args env-vars #f))
|
2012-06-01 23:29:55 +02:00
|
|
|
|
(drv (add-output-paths drv-masked)))
|
2012-06-07 23:15:00 +02:00
|
|
|
|
|
2017-04-20 18:46:38 +02:00
|
|
|
|
(let* ((file (add-data-to-store store (string-append name ".drv")
|
|
|
|
|
(derivation->bytevector drv)
|
2019-06-23 11:28:29 +02:00
|
|
|
|
(append (map derivation-input-path inputs)
|
|
|
|
|
sources)))
|
2016-12-17 15:12:19 +01:00
|
|
|
|
(drv* (set-field drv (derivation-file-name) file)))
|
2019-06-23 11:40:16 +02:00
|
|
|
|
;; Preserve pointer equality. This improves the performance of
|
|
|
|
|
;; 'eq?'-memoization on derivations.
|
|
|
|
|
(or (hash-ref %derivation-cache file)
|
|
|
|
|
(begin
|
|
|
|
|
(hash-set! %derivation-cache file drv*)
|
|
|
|
|
drv*)))))
|
derivations: 'derivation' and related procedures return a single value.
* guix/derivations.scm (derivation->output-path,
derivation->output-paths): New procedures.
(derivation-path->output-path): Use 'derivation->output-path'.
(derivation-path->output-paths): Use 'derivation->output-paths'.
(derivation): Accept 'derivation?' objects as inputs. Return a single
value.
(build-derivations): New procedure.
(compiled-modules): Use 'derivation->output-paths'.
(build-expression->derivation)[source-path]: Add case for when the
input matches 'derivation?'.
[prologue]: Accept 'derivation?' objects in INPUTS.
[mod-dir, go-dir]: Use 'derivation->output-path'.
* guix/download.scm (url-fetch): Adjust to the single-value return.
* guix/packages.scm (package-output): Use 'derivation->output-path'.
* guix/scripts/build.scm (guix-build): When the argument is
'derivation-path?', pass it through 'read-derivation'.
Use 'derivation-file-name' to print out the .drv file names, and to
register them. Use 'derivation->output-path' instead of
'derivation-path->output-path'.
* guix/scripts/package.scm (roll-back): Adjust to the single-value
return.
(guix-package): Use 'derivation->output-path'.
* guix/ui.scm (show-what-to-build): Adjust to deal with 'derivation?'
objects instead of .drv file names.
* gnu/system/grub.scm (grub-configuration-file): Use
'derivation->output-path' instead of 'derivation-path->output-path'.
* gnu/system/vm.scm (qemu-image, system-qemu-image): Likewise.
* tests/builders.scm, tests/derivations.scm, tests/packages.scm,
tests/store.scm, tests/union.scm: Adjust to the new calling
convention.
* doc/guix.texi (Defining Packages, The Store, Derivations): Adjust
accordingly.
2013-09-18 17:01:40 +02:00
|
|
|
|
|
2017-12-13 15:01:07 +01:00
|
|
|
|
(define (invalidate-derivation-caches!)
|
|
|
|
|
"Invalidate internal derivation caches. This is mostly useful for
|
|
|
|
|
long-running processes that know what they're doing. Use with care!"
|
|
|
|
|
;; Typically this is meant to be used by Cuirass and Hydra, which can clear
|
|
|
|
|
;; caches when they start evaluating packages for another architecture.
|
|
|
|
|
(invalidate-memoization! derivation->bytevector)
|
2019-07-03 22:36:56 +02:00
|
|
|
|
(invalidate-memoization! derivation-base16-hash)
|
2019-07-03 20:05:23 +02:00
|
|
|
|
|
|
|
|
|
;; FIXME: Comment out to work around <https://bugs.gnu.org/36487>.
|
|
|
|
|
;; (hash-clear! %derivation-cache)
|
|
|
|
|
)
|
2017-12-13 15:01:07 +01:00
|
|
|
|
|
2018-11-26 22:14:11 +01:00
|
|
|
|
(define derivation-properties
|
|
|
|
|
(mlambdaq (drv)
|
|
|
|
|
"Return the property alist associated with DRV."
|
|
|
|
|
(match (assoc "guix properties"
|
|
|
|
|
(derivation-builder-environment-vars drv))
|
|
|
|
|
((_ . str) (call-with-input-string str read))
|
|
|
|
|
(#f '()))))
|
|
|
|
|
|
2013-11-13 00:25:57 +01:00
|
|
|
|
(define* (map-derivation store drv mapping
|
|
|
|
|
#:key (system (%current-system)))
|
|
|
|
|
"Given MAPPING, a list of pairs of derivations, return a derivation based on
|
|
|
|
|
DRV where all the 'car's of MAPPING have been replaced by its 'cdr's,
|
|
|
|
|
recursively."
|
|
|
|
|
(define (substitute str initial replacements)
|
|
|
|
|
(fold (lambda (path replacement result)
|
|
|
|
|
(string-replace-substring result path
|
|
|
|
|
replacement))
|
|
|
|
|
str
|
|
|
|
|
initial replacements))
|
|
|
|
|
|
|
|
|
|
(define (substitute-file file initial replacements)
|
|
|
|
|
(define contents
|
|
|
|
|
(with-fluids ((%default-port-encoding #f))
|
2016-10-19 14:28:56 +02:00
|
|
|
|
(call-with-input-file file read-string)))
|
2013-11-13 00:25:57 +01:00
|
|
|
|
|
|
|
|
|
(let ((updated (substitute contents initial replacements)))
|
|
|
|
|
(if (string=? updated contents)
|
|
|
|
|
file
|
|
|
|
|
;; XXX: permissions aren't preserved.
|
|
|
|
|
(add-text-to-store store (store-path-package-name file)
|
|
|
|
|
updated))))
|
|
|
|
|
|
|
|
|
|
(define input->output-paths
|
|
|
|
|
(match-lambda
|
2019-07-09 23:51:44 +02:00
|
|
|
|
((? derivation-input? input)
|
|
|
|
|
(derivation-input-output-paths input))
|
|
|
|
|
((? string? file)
|
|
|
|
|
(list file))))
|
2013-11-13 00:25:57 +01:00
|
|
|
|
|
|
|
|
|
(let ((mapping (fold (lambda (pair result)
|
|
|
|
|
(match pair
|
2013-11-13 11:22:07 +01:00
|
|
|
|
(((? derivation? orig) . replacement)
|
2013-11-13 00:25:57 +01:00
|
|
|
|
(vhash-cons (derivation-file-name orig)
|
2013-11-13 11:22:07 +01:00
|
|
|
|
replacement result))
|
|
|
|
|
((file . replacement)
|
|
|
|
|
(vhash-cons file replacement result))))
|
2013-11-13 00:25:57 +01:00
|
|
|
|
vlist-null
|
|
|
|
|
mapping)))
|
|
|
|
|
(define rewritten-input
|
|
|
|
|
;; Rewrite the given input according to MAPPING, and return an input
|
|
|
|
|
;; in the format used in 'derivation' calls.
|
2017-01-28 17:09:34 +01:00
|
|
|
|
(mlambda (input loop)
|
|
|
|
|
(match input
|
2019-07-03 22:27:17 +02:00
|
|
|
|
(($ <derivation-input> drv (sub-drvs ...))
|
|
|
|
|
(match (vhash-assoc (derivation-file-name drv) mapping)
|
2017-01-28 17:09:34 +01:00
|
|
|
|
((_ . (? derivation? replacement))
|
2019-07-09 23:51:44 +02:00
|
|
|
|
(derivation-input replacement sub-drvs))
|
|
|
|
|
((_ . (? string? source))
|
|
|
|
|
source)
|
2017-01-28 17:09:34 +01:00
|
|
|
|
(#f
|
2019-07-09 23:51:44 +02:00
|
|
|
|
(derivation-input (loop drv) sub-drvs)))))))
|
2013-11-13 00:25:57 +01:00
|
|
|
|
|
|
|
|
|
(let loop ((drv drv))
|
|
|
|
|
(let* ((inputs (map (cut rewritten-input <> loop)
|
|
|
|
|
(derivation-inputs drv)))
|
|
|
|
|
(initial (append-map derivation-input-output-paths
|
|
|
|
|
(derivation-inputs drv)))
|
|
|
|
|
(replacements (append-map input->output-paths inputs))
|
|
|
|
|
|
|
|
|
|
;; Sources typically refer to the output directories of the
|
|
|
|
|
;; original inputs, INITIAL. Rewrite them by substituting
|
|
|
|
|
;; REPLACEMENTS.
|
2013-11-13 11:22:07 +01:00
|
|
|
|
(sources (map (lambda (source)
|
|
|
|
|
(match (vhash-assoc source mapping)
|
|
|
|
|
((_ . replacement)
|
|
|
|
|
replacement)
|
|
|
|
|
(#f
|
|
|
|
|
(substitute-file source
|
|
|
|
|
initial replacements))))
|
2013-11-13 00:25:57 +01:00
|
|
|
|
(derivation-sources drv)))
|
|
|
|
|
|
|
|
|
|
;; Now augment the lists of initials and replacements.
|
|
|
|
|
(initial (append (derivation-sources drv) initial))
|
|
|
|
|
(replacements (append sources replacements))
|
|
|
|
|
(name (store-path-package-name
|
|
|
|
|
(string-drop-right (derivation-file-name drv)
|
|
|
|
|
4))))
|
|
|
|
|
(derivation store name
|
|
|
|
|
(substitute (derivation-builder drv)
|
|
|
|
|
initial replacements)
|
|
|
|
|
(map (cut substitute <> initial replacements)
|
|
|
|
|
(derivation-builder-arguments drv))
|
|
|
|
|
#:system system
|
|
|
|
|
#:env-vars (map (match-lambda
|
|
|
|
|
((var . value)
|
|
|
|
|
`(,var
|
|
|
|
|
. ,(substitute value initial
|
|
|
|
|
replacements))))
|
|
|
|
|
(derivation-builder-environment-vars drv))
|
2019-07-09 23:51:44 +02:00
|
|
|
|
#:inputs (filter derivation-input? inputs)
|
|
|
|
|
#:sources (append sources (filter string? inputs))
|
2015-01-09 23:33:42 +01:00
|
|
|
|
#:outputs (derivation-output-names drv)
|
2013-11-13 00:25:57 +01:00
|
|
|
|
#:hash (match (derivation-outputs drv)
|
|
|
|
|
((($ <derivation-output> _ algo hash))
|
|
|
|
|
hash)
|
|
|
|
|
(_ #f))
|
|
|
|
|
#:hash-algo (match (derivation-outputs drv)
|
|
|
|
|
((($ <derivation-output> _ algo hash))
|
|
|
|
|
algo)
|
|
|
|
|
(_ #f)))))))
|
|
|
|
|
|
derivations: 'derivation' and related procedures return a single value.
* guix/derivations.scm (derivation->output-path,
derivation->output-paths): New procedures.
(derivation-path->output-path): Use 'derivation->output-path'.
(derivation-path->output-paths): Use 'derivation->output-paths'.
(derivation): Accept 'derivation?' objects as inputs. Return a single
value.
(build-derivations): New procedure.
(compiled-modules): Use 'derivation->output-paths'.
(build-expression->derivation)[source-path]: Add case for when the
input matches 'derivation?'.
[prologue]: Accept 'derivation?' objects in INPUTS.
[mod-dir, go-dir]: Use 'derivation->output-path'.
* guix/download.scm (url-fetch): Adjust to the single-value return.
* guix/packages.scm (package-output): Use 'derivation->output-path'.
* guix/scripts/build.scm (guix-build): When the argument is
'derivation-path?', pass it through 'read-derivation'.
Use 'derivation-file-name' to print out the .drv file names, and to
register them. Use 'derivation->output-path' instead of
'derivation-path->output-path'.
* guix/scripts/package.scm (roll-back): Adjust to the single-value
return.
(guix-package): Use 'derivation->output-path'.
* guix/ui.scm (show-what-to-build): Adjust to deal with 'derivation?'
objects instead of .drv file names.
* gnu/system/grub.scm (grub-configuration-file): Use
'derivation->output-path' instead of 'derivation-path->output-path'.
* gnu/system/vm.scm (qemu-image, system-qemu-image): Likewise.
* tests/builders.scm, tests/derivations.scm, tests/packages.scm,
tests/store.scm, tests/union.scm: Adjust to the new calling
convention.
* doc/guix.texi (Defining Packages, The Store, Derivations): Adjust
accordingly.
2013-09-18 17:01:40 +02:00
|
|
|
|
|
|
|
|
|
;;;
|
|
|
|
|
;;; Store compatibility layer.
|
|
|
|
|
;;;
|
|
|
|
|
|
2015-12-09 11:04:57 +01:00
|
|
|
|
(define* (build-derivations store derivations
|
|
|
|
|
#:optional (mode (build-mode normal)))
|
2019-07-02 16:41:33 +02:00
|
|
|
|
"Build DERIVATIONS, a list of <derivation> or <derivation-input> objects,
|
|
|
|
|
.drv file names, or derivation/output pairs, using the specified MODE."
|
2015-02-02 12:46:09 +01:00
|
|
|
|
(build-things store (map (match-lambda
|
2019-06-10 22:10:21 +02:00
|
|
|
|
((? derivation? drv)
|
|
|
|
|
(derivation-file-name drv))
|
2019-06-23 12:39:39 +02:00
|
|
|
|
((? derivation-input? input)
|
|
|
|
|
(cons (derivation-input-path input)
|
|
|
|
|
(string-join
|
|
|
|
|
(derivation-input-sub-derivations input)
|
|
|
|
|
",")))
|
2015-02-02 12:46:09 +01:00
|
|
|
|
((? string? file) file)
|
2019-06-10 22:10:21 +02:00
|
|
|
|
(((? derivation? drv) . output)
|
|
|
|
|
(cons (derivation-file-name drv)
|
|
|
|
|
output))
|
|
|
|
|
(((? string? file) . output)
|
|
|
|
|
(cons file output)))
|
2015-12-09 11:04:57 +01:00
|
|
|
|
derivations)
|
|
|
|
|
mode))
|
2012-06-08 21:31:01 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;
|
|
|
|
|
;;; Guile-based builders.
|
|
|
|
|
;;;
|
|
|
|
|
|
2012-10-22 23:30:35 +02:00
|
|
|
|
(define (parent-directories file-name)
|
|
|
|
|
"Return the list of parent dirs of FILE-NAME, in the order in which an
|
|
|
|
|
`mkdir -p' implementation would make them."
|
|
|
|
|
(let ((not-slash (char-set-complement (char-set #\/))))
|
|
|
|
|
(reverse
|
|
|
|
|
(fold (lambda (dir result)
|
|
|
|
|
(match result
|
|
|
|
|
(()
|
|
|
|
|
(list dir))
|
|
|
|
|
((prev _ ...)
|
|
|
|
|
(cons (string-append prev "/" dir)
|
|
|
|
|
result))))
|
|
|
|
|
'()
|
|
|
|
|
(remove (cut string=? <> ".")
|
|
|
|
|
(string-tokenize (dirname file-name) not-slash))))))
|
|
|
|
|
|
2015-02-13 17:23:17 +01:00
|
|
|
|
(define* (imported-files store files ;deprecated
|
2012-10-25 18:03:48 +02:00
|
|
|
|
#:key (name "file-import")
|
|
|
|
|
(system (%current-system))
|
|
|
|
|
(guile (%guile-for-build)))
|
2012-06-11 23:12:55 +02:00
|
|
|
|
"Return a derivation that imports FILES into STORE. FILES must be a list
|
|
|
|
|
of (FINAL-PATH . FILE-NAME) pairs; each FILE-NAME is read from the file
|
|
|
|
|
system, imported, and appears under FINAL-PATH in the resulting store path."
|
|
|
|
|
(let* ((files (map (match-lambda
|
|
|
|
|
((final-path . file-name)
|
2012-06-13 17:21:27 +02:00
|
|
|
|
(list final-path
|
2013-01-30 16:30:49 +01:00
|
|
|
|
(add-to-store store (basename final-path) #f
|
2012-06-11 23:12:55 +02:00
|
|
|
|
"sha256" file-name))))
|
|
|
|
|
files))
|
|
|
|
|
(builder
|
|
|
|
|
`(begin
|
|
|
|
|
(mkdir %output) (chdir %output)
|
|
|
|
|
,@(append-map (match-lambda
|
2012-06-13 17:21:27 +02:00
|
|
|
|
((final-path store-path)
|
2012-10-22 23:30:35 +02:00
|
|
|
|
(append (match (parent-directories final-path)
|
2012-06-11 23:12:55 +02:00
|
|
|
|
(() '())
|
|
|
|
|
((head ... tail)
|
|
|
|
|
(append (map (lambda (d)
|
|
|
|
|
`(false-if-exception
|
|
|
|
|
(mkdir ,d)))
|
|
|
|
|
head)
|
2012-06-12 23:30:00 +02:00
|
|
|
|
`((or (file-exists? ,tail)
|
|
|
|
|
(mkdir ,tail))))))
|
2012-06-11 23:12:55 +02:00
|
|
|
|
`((symlink ,store-path ,final-path)))))
|
|
|
|
|
files))))
|
derivations: Use more keyword parameters for 'build-expression->derivation'.
* guix/derivations.scm (build-expression->derivation): Turn 'system' and
'inputs' into keyword parameters.
Adjust callers accordingly.
* gnu/system/linux.scm, gnu/system/vm.scm, guix/build-system/cmake.scm,
guix/build-system/gnu.scm, guix/build-system/perl.scm,
guix/build-system/python.scm, guix/build-system/trivial.scm,
guix/download.scm, guix/packages.scm, guix/profiles.scm,
guix/scripts/pull.scm, tests/derivations.scm, tests/guix-build.sh,
tests/monads.scm, tests/store.scm, tests/union.scm: Adjust users of
'build-expression->derivation' and 'derivation-expression'
accordingly.
* doc/guix.texi (Derivations): Adjust 'build-expression->derivation'
documentation accordingly.
(The Store Monad): Likewise for 'derivation-expression'.
2013-12-04 16:07:36 +01:00
|
|
|
|
(build-expression->derivation store name builder
|
|
|
|
|
#:system system
|
|
|
|
|
#:inputs files
|
2014-01-25 17:22:53 +01:00
|
|
|
|
#:guile-for-build guile
|
|
|
|
|
#:local-build? #t)))
|
2012-06-11 23:12:55 +02:00
|
|
|
|
|
2016-03-22 15:00:53 +01:00
|
|
|
|
;; The "file not found" error condition.
|
|
|
|
|
(define-condition-type &file-search-error &error
|
|
|
|
|
file-search-error?
|
|
|
|
|
(file file-search-error-file-name)
|
|
|
|
|
(path file-search-error-search-path))
|
|
|
|
|
|
2014-10-13 23:00:06 +02:00
|
|
|
|
(define search-path*
|
|
|
|
|
;; A memoizing version of 'search-path' so 'imported-modules' does not end
|
|
|
|
|
;; up looking for the same files over and over again.
|
2017-01-28 17:09:34 +01:00
|
|
|
|
(mlambda (path file)
|
|
|
|
|
"Search for FILE in PATH and memoize the result. Raise a
|
2016-03-22 15:00:53 +01:00
|
|
|
|
'&file-search-error' condition if it could not be found."
|
2017-01-28 17:09:34 +01:00
|
|
|
|
(or (search-path path file)
|
|
|
|
|
(raise (condition
|
|
|
|
|
(&file-search-error (file file)
|
|
|
|
|
(path path)))))))
|
2014-10-13 23:00:06 +02:00
|
|
|
|
|
2016-03-22 14:58:59 +01:00
|
|
|
|
(define (module->source-file-name module)
|
|
|
|
|
"Return the file name corresponding to MODULE, a Guile module name (a list
|
|
|
|
|
of symbols.)"
|
|
|
|
|
(string-append (string-join (map symbol->string module) "/")
|
|
|
|
|
".scm"))
|
|
|
|
|
|
2015-02-13 17:23:17 +01:00
|
|
|
|
(define* (%imported-modules store modules ;deprecated
|
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 13:34:52 +01:00
|
|
|
|
#:key (name "module-import")
|
|
|
|
|
(system (%current-system))
|
|
|
|
|
(guile (%guile-for-build))
|
|
|
|
|
(module-path %load-path))
|
2012-06-12 00:18:14 +02:00
|
|
|
|
"Return a derivation that contains the source files of MODULES, a list of
|
2013-02-20 21:08:09 +01:00
|
|
|
|
module names such as `(ice-9 q)'. All of MODULES must be in the MODULE-PATH
|
2012-06-12 00:18:14 +02:00
|
|
|
|
search path."
|
|
|
|
|
;; TODO: Determine the closure of MODULES, build the `.go' files,
|
|
|
|
|
;; canonicalize the source files through read/write, etc.
|
|
|
|
|
(let ((files (map (lambda (m)
|
2016-03-22 14:58:59 +01:00
|
|
|
|
(let ((f (module->source-file-name m)))
|
2014-10-13 23:00:06 +02:00
|
|
|
|
(cons f (search-path* module-path f))))
|
2012-06-12 00:18:14 +02:00
|
|
|
|
modules)))
|
2012-10-25 18:03:48 +02:00
|
|
|
|
(imported-files store files #:name name #:system system
|
|
|
|
|
#:guile guile)))
|
2012-06-12 00:18:14 +02:00
|
|
|
|
|
2015-02-13 17:23:17 +01:00
|
|
|
|
(define* (%compiled-modules store modules ;deprecated
|
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 13:34:52 +01:00
|
|
|
|
#:key (name "module-import-compiled")
|
|
|
|
|
(system (%current-system))
|
|
|
|
|
(guile (%guile-for-build))
|
|
|
|
|
(module-path %load-path))
|
2012-10-22 23:30:35 +02:00
|
|
|
|
"Return a derivation that builds a tree containing the `.go' files
|
|
|
|
|
corresponding to MODULES. All the MODULES are built in a context where
|
|
|
|
|
they can refer to each other."
|
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 13:34:52 +01:00
|
|
|
|
(let* ((module-drv (%imported-modules store modules
|
|
|
|
|
#:system system
|
|
|
|
|
#:guile guile
|
|
|
|
|
#:module-path module-path))
|
derivations: 'derivation' and related procedures return a single value.
* guix/derivations.scm (derivation->output-path,
derivation->output-paths): New procedures.
(derivation-path->output-path): Use 'derivation->output-path'.
(derivation-path->output-paths): Use 'derivation->output-paths'.
(derivation): Accept 'derivation?' objects as inputs. Return a single
value.
(build-derivations): New procedure.
(compiled-modules): Use 'derivation->output-paths'.
(build-expression->derivation)[source-path]: Add case for when the
input matches 'derivation?'.
[prologue]: Accept 'derivation?' objects in INPUTS.
[mod-dir, go-dir]: Use 'derivation->output-path'.
* guix/download.scm (url-fetch): Adjust to the single-value return.
* guix/packages.scm (package-output): Use 'derivation->output-path'.
* guix/scripts/build.scm (guix-build): When the argument is
'derivation-path?', pass it through 'read-derivation'.
Use 'derivation-file-name' to print out the .drv file names, and to
register them. Use 'derivation->output-path' instead of
'derivation-path->output-path'.
* guix/scripts/package.scm (roll-back): Adjust to the single-value
return.
(guix-package): Use 'derivation->output-path'.
* guix/ui.scm (show-what-to-build): Adjust to deal with 'derivation?'
objects instead of .drv file names.
* gnu/system/grub.scm (grub-configuration-file): Use
'derivation->output-path' instead of 'derivation-path->output-path'.
* gnu/system/vm.scm (qemu-image, system-qemu-image): Likewise.
* tests/builders.scm, tests/derivations.scm, tests/packages.scm,
tests/store.scm, tests/union.scm: Adjust to the new calling
convention.
* doc/guix.texi (Defining Packages, The Store, Derivations): Adjust
accordingly.
2013-09-18 17:01:40 +02:00
|
|
|
|
(module-dir (derivation->output-path module-drv))
|
2012-10-22 23:30:35 +02:00
|
|
|
|
(files (map (lambda (m)
|
|
|
|
|
(let ((f (string-join (map symbol->string m)
|
|
|
|
|
"/")))
|
|
|
|
|
(cons (string-append f ".go")
|
|
|
|
|
(string-append module-dir "/" f ".scm"))))
|
|
|
|
|
modules)))
|
|
|
|
|
(define builder
|
|
|
|
|
`(begin
|
|
|
|
|
(use-modules (system base compile))
|
|
|
|
|
(let ((out (assoc-ref %outputs "out")))
|
|
|
|
|
(mkdir out)
|
|
|
|
|
(chdir out))
|
|
|
|
|
|
|
|
|
|
(set! %load-path
|
|
|
|
|
(cons ,module-dir %load-path))
|
|
|
|
|
|
|
|
|
|
,@(map (match-lambda
|
|
|
|
|
((output . input)
|
|
|
|
|
(let ((make-parent-dirs (map (lambda (dir)
|
|
|
|
|
`(unless (file-exists? ,dir)
|
|
|
|
|
(mkdir ,dir)))
|
|
|
|
|
(parent-directories output))))
|
|
|
|
|
`(begin
|
|
|
|
|
,@make-parent-dirs
|
|
|
|
|
(compile-file ,input
|
|
|
|
|
#:output-file ,output
|
|
|
|
|
#:opts %auto-compilation-options)))))
|
|
|
|
|
files)))
|
|
|
|
|
|
derivations: Use more keyword parameters for 'build-expression->derivation'.
* guix/derivations.scm (build-expression->derivation): Turn 'system' and
'inputs' into keyword parameters.
Adjust callers accordingly.
* gnu/system/linux.scm, gnu/system/vm.scm, guix/build-system/cmake.scm,
guix/build-system/gnu.scm, guix/build-system/perl.scm,
guix/build-system/python.scm, guix/build-system/trivial.scm,
guix/download.scm, guix/packages.scm, guix/profiles.scm,
guix/scripts/pull.scm, tests/derivations.scm, tests/guix-build.sh,
tests/monads.scm, tests/store.scm, tests/union.scm: Adjust users of
'build-expression->derivation' and 'derivation-expression'
accordingly.
* doc/guix.texi (Derivations): Adjust 'build-expression->derivation'
documentation accordingly.
(The Store Monad): Likewise for 'derivation-expression'.
2013-12-04 16:07:36 +01:00
|
|
|
|
(build-expression->derivation store name builder
|
|
|
|
|
#:inputs `(("modules" ,module-drv))
|
|
|
|
|
#:system system
|
2014-01-25 17:22:53 +01:00
|
|
|
|
#:guile-for-build guile
|
|
|
|
|
#:local-build? #t)))
|
2012-06-12 00:18:14 +02:00
|
|
|
|
|
2015-02-13 17:23:17 +01:00
|
|
|
|
(define* (build-expression->derivation store name exp ;deprecated
|
derivations: Use more keyword parameters for 'build-expression->derivation'.
* guix/derivations.scm (build-expression->derivation): Turn 'system' and
'inputs' into keyword parameters.
Adjust callers accordingly.
* gnu/system/linux.scm, gnu/system/vm.scm, guix/build-system/cmake.scm,
guix/build-system/gnu.scm, guix/build-system/perl.scm,
guix/build-system/python.scm, guix/build-system/trivial.scm,
guix/download.scm, guix/packages.scm, guix/profiles.scm,
guix/scripts/pull.scm, tests/derivations.scm, tests/guix-build.sh,
tests/monads.scm, tests/store.scm, tests/union.scm: Adjust users of
'build-expression->derivation' and 'derivation-expression'
accordingly.
* doc/guix.texi (Derivations): Adjust 'build-expression->derivation'
documentation accordingly.
(The Store Monad): Likewise for 'derivation-expression'.
2013-12-04 16:07:36 +01:00
|
|
|
|
#:key
|
|
|
|
|
(system (%current-system))
|
|
|
|
|
(inputs '())
|
|
|
|
|
(outputs '("out"))
|
2014-02-21 23:03:19 +01:00
|
|
|
|
hash hash-algo recursive?
|
2012-09-01 11:33:20 +02:00
|
|
|
|
(env-vars '())
|
2012-09-01 11:45:52 +02:00
|
|
|
|
(modules '())
|
2013-08-26 22:19:21 +02:00
|
|
|
|
guile-for-build
|
2014-01-25 17:04:35 +01:00
|
|
|
|
references-graphs
|
2014-06-06 17:07:26 +02:00
|
|
|
|
allowed-references
|
2016-03-20 22:40:31 +01:00
|
|
|
|
disallowed-references
|
2018-11-26 22:14:11 +01:00
|
|
|
|
local-build? (substitutable? #t)
|
|
|
|
|
(properties '()))
|
2013-01-16 23:09:06 +01:00
|
|
|
|
"Return a derivation that executes Scheme expression EXP as a builder
|
|
|
|
|
for derivation NAME. INPUTS must be a list of (NAME DRV-PATH SUB-DRV)
|
|
|
|
|
tuples; when SUB-DRV is omitted, \"out\" is assumed. MODULES is a list
|
|
|
|
|
of names of Guile modules from the current search path to be copied in
|
|
|
|
|
the store, compiled, and made available in the load path during the
|
|
|
|
|
execution of EXP.
|
|
|
|
|
|
|
|
|
|
EXP is evaluated in an environment where %OUTPUT is bound to the main
|
|
|
|
|
output path, %OUTPUTS is bound to a list of output/path pairs, and where
|
|
|
|
|
%BUILD-INPUTS is bound to an alist of string/output-path pairs made from
|
|
|
|
|
INPUTS. Optionally, ENV-VARS is a list of string pairs specifying the
|
|
|
|
|
name and value of environment variables visible to the builder. The
|
|
|
|
|
builder terminates by passing the result of EXP to `exit'; thus, when
|
|
|
|
|
EXP returns #f, the build is considered to have failed.
|
2012-09-01 11:45:52 +02:00
|
|
|
|
|
|
|
|
|
EXP is built using GUILE-FOR-BUILD (a derivation). When GUILE-FOR-BUILD is
|
2013-08-26 22:19:21 +02:00
|
|
|
|
omitted or is #f, the value of the `%guile-for-build' fluid is used instead.
|
|
|
|
|
|
2014-06-06 17:07:26 +02:00
|
|
|
|
See the `derivation' procedure for the meaning of REFERENCES-GRAPHS,
|
2018-11-26 22:14:11 +01:00
|
|
|
|
ALLOWED-REFERENCES, DISALLOWED-REFERENCES, LOCAL-BUILD?, SUBSTITUTABLE?,
|
|
|
|
|
and PROPERTIES."
|
2012-10-25 18:03:48 +02:00
|
|
|
|
(define guile-drv
|
|
|
|
|
(or guile-for-build (%guile-for-build)))
|
|
|
|
|
|
2012-06-08 21:31:01 +02:00
|
|
|
|
(define guile
|
derivations: 'derivation' and related procedures return a single value.
* guix/derivations.scm (derivation->output-path,
derivation->output-paths): New procedures.
(derivation-path->output-path): Use 'derivation->output-path'.
(derivation-path->output-paths): Use 'derivation->output-paths'.
(derivation): Accept 'derivation?' objects as inputs. Return a single
value.
(build-derivations): New procedure.
(compiled-modules): Use 'derivation->output-paths'.
(build-expression->derivation)[source-path]: Add case for when the
input matches 'derivation?'.
[prologue]: Accept 'derivation?' objects in INPUTS.
[mod-dir, go-dir]: Use 'derivation->output-path'.
* guix/download.scm (url-fetch): Adjust to the single-value return.
* guix/packages.scm (package-output): Use 'derivation->output-path'.
* guix/scripts/build.scm (guix-build): When the argument is
'derivation-path?', pass it through 'read-derivation'.
Use 'derivation-file-name' to print out the .drv file names, and to
register them. Use 'derivation->output-path' instead of
'derivation-path->output-path'.
* guix/scripts/package.scm (roll-back): Adjust to the single-value
return.
(guix-package): Use 'derivation->output-path'.
* guix/ui.scm (show-what-to-build): Adjust to deal with 'derivation?'
objects instead of .drv file names.
* gnu/system/grub.scm (grub-configuration-file): Use
'derivation->output-path' instead of 'derivation-path->output-path'.
* gnu/system/vm.scm (qemu-image, system-qemu-image): Likewise.
* tests/builders.scm, tests/derivations.scm, tests/packages.scm,
tests/store.scm, tests/union.scm: Adjust to the new calling
convention.
* doc/guix.texi (Defining Packages, The Store, Derivations): Adjust
accordingly.
2013-09-18 17:01:40 +02:00
|
|
|
|
(string-append (derivation->output-path guile-drv)
|
2012-06-08 21:31:01 +02:00
|
|
|
|
"/bin/guile"))
|
|
|
|
|
|
2012-06-17 16:43:40 +02:00
|
|
|
|
(define module-form?
|
|
|
|
|
(match-lambda
|
2013-08-26 22:11:04 +02:00
|
|
|
|
(((or 'define-module 'use-modules) _ ...) #t)
|
|
|
|
|
(_ #f)))
|
2012-06-17 16:43:40 +02:00
|
|
|
|
|
2012-11-09 00:07:10 +01:00
|
|
|
|
(define source-path
|
|
|
|
|
;; When passed an input that is a source, return its path; otherwise
|
|
|
|
|
;; return #f.
|
|
|
|
|
(match-lambda
|
derivations: 'derivation' and related procedures return a single value.
* guix/derivations.scm (derivation->output-path,
derivation->output-paths): New procedures.
(derivation-path->output-path): Use 'derivation->output-path'.
(derivation-path->output-paths): Use 'derivation->output-paths'.
(derivation): Accept 'derivation?' objects as inputs. Return a single
value.
(build-derivations): New procedure.
(compiled-modules): Use 'derivation->output-paths'.
(build-expression->derivation)[source-path]: Add case for when the
input matches 'derivation?'.
[prologue]: Accept 'derivation?' objects in INPUTS.
[mod-dir, go-dir]: Use 'derivation->output-path'.
* guix/download.scm (url-fetch): Adjust to the single-value return.
* guix/packages.scm (package-output): Use 'derivation->output-path'.
* guix/scripts/build.scm (guix-build): When the argument is
'derivation-path?', pass it through 'read-derivation'.
Use 'derivation-file-name' to print out the .drv file names, and to
register them. Use 'derivation->output-path' instead of
'derivation-path->output-path'.
* guix/scripts/package.scm (roll-back): Adjust to the single-value
return.
(guix-package): Use 'derivation->output-path'.
* guix/ui.scm (show-what-to-build): Adjust to deal with 'derivation?'
objects instead of .drv file names.
* gnu/system/grub.scm (grub-configuration-file): Use
'derivation->output-path' instead of 'derivation-path->output-path'.
* gnu/system/vm.scm (qemu-image, system-qemu-image): Likewise.
* tests/builders.scm, tests/derivations.scm, tests/packages.scm,
tests/store.scm, tests/union.scm: Adjust to the new calling
convention.
* doc/guix.texi (Defining Packages, The Store, Derivations): Adjust
accordingly.
2013-09-18 17:01:40 +02:00
|
|
|
|
((_ (? derivation?) _ ...)
|
|
|
|
|
#f)
|
2012-11-09 00:07:10 +01:00
|
|
|
|
((_ path _ ...)
|
|
|
|
|
(and (not (derivation-path? path))
|
|
|
|
|
path))))
|
|
|
|
|
|
2012-06-08 21:31:01 +02:00
|
|
|
|
(let* ((prologue `(begin
|
2012-06-17 16:43:40 +02:00
|
|
|
|
,@(match exp
|
|
|
|
|
((_ ...)
|
|
|
|
|
;; Module forms must appear at the top-level so
|
|
|
|
|
;; that any macros they export can be expanded.
|
|
|
|
|
(filter module-form? exp))
|
|
|
|
|
(_ `(,exp)))
|
|
|
|
|
|
2012-06-08 21:31:01 +02:00
|
|
|
|
(define %output (getenv "out"))
|
2012-06-09 23:16:55 +02:00
|
|
|
|
(define %outputs
|
|
|
|
|
(map (lambda (o)
|
|
|
|
|
(cons o (getenv o)))
|
|
|
|
|
',outputs))
|
2012-06-08 21:31:01 +02:00
|
|
|
|
(define %build-inputs
|
|
|
|
|
',(map (match-lambda
|
2012-06-13 17:21:27 +02:00
|
|
|
|
((name drv . rest)
|
|
|
|
|
(let ((sub (match rest
|
|
|
|
|
(() "out")
|
|
|
|
|
((x) x))))
|
|
|
|
|
(cons name
|
derivations: 'derivation' and related procedures return a single value.
* guix/derivations.scm (derivation->output-path,
derivation->output-paths): New procedures.
(derivation-path->output-path): Use 'derivation->output-path'.
(derivation-path->output-paths): Use 'derivation->output-paths'.
(derivation): Accept 'derivation?' objects as inputs. Return a single
value.
(build-derivations): New procedure.
(compiled-modules): Use 'derivation->output-paths'.
(build-expression->derivation)[source-path]: Add case for when the
input matches 'derivation?'.
[prologue]: Accept 'derivation?' objects in INPUTS.
[mod-dir, go-dir]: Use 'derivation->output-path'.
* guix/download.scm (url-fetch): Adjust to the single-value return.
* guix/packages.scm (package-output): Use 'derivation->output-path'.
* guix/scripts/build.scm (guix-build): When the argument is
'derivation-path?', pass it through 'read-derivation'.
Use 'derivation-file-name' to print out the .drv file names, and to
register them. Use 'derivation->output-path' instead of
'derivation-path->output-path'.
* guix/scripts/package.scm (roll-back): Adjust to the single-value
return.
(guix-package): Use 'derivation->output-path'.
* guix/ui.scm (show-what-to-build): Adjust to deal with 'derivation?'
objects instead of .drv file names.
* gnu/system/grub.scm (grub-configuration-file): Use
'derivation->output-path' instead of 'derivation-path->output-path'.
* gnu/system/vm.scm (qemu-image, system-qemu-image): Likewise.
* tests/builders.scm, tests/derivations.scm, tests/packages.scm,
tests/store.scm, tests/union.scm: Adjust to the new calling
convention.
* doc/guix.texi (Defining Packages, The Store, Derivations): Adjust
accordingly.
2013-09-18 17:01:40 +02:00
|
|
|
|
(cond
|
|
|
|
|
((derivation? drv)
|
|
|
|
|
(derivation->output-path drv sub))
|
|
|
|
|
((derivation-path? drv)
|
|
|
|
|
(derivation-path->output-path drv
|
|
|
|
|
sub))
|
|
|
|
|
(else drv))))))
|
2012-07-07 22:38:08 +02:00
|
|
|
|
inputs))
|
|
|
|
|
|
2012-10-22 23:30:35 +02:00
|
|
|
|
,@(if (null? modules)
|
|
|
|
|
'()
|
|
|
|
|
;; Remove our own settings.
|
|
|
|
|
'((unsetenv "GUILE_LOAD_COMPILED_PATH")))
|
|
|
|
|
|
2012-07-07 22:38:08 +02:00
|
|
|
|
;; Guile sets it, but remove it to avoid conflicts when
|
|
|
|
|
;; building Guile-using packages.
|
|
|
|
|
(unsetenv "LD_LIBRARY_PATH")))
|
2017-04-21 22:43:28 +02:00
|
|
|
|
(builder (add-text-to-store store
|
2012-06-08 21:31:01 +02:00
|
|
|
|
(string-append name "-guile-builder")
|
2013-03-16 17:22:20 +01:00
|
|
|
|
|
|
|
|
|
;; Explicitly use UTF-8 for determinism,
|
|
|
|
|
;; and also because UTF-8 output is faster.
|
|
|
|
|
(with-fluids ((%default-port-encoding
|
|
|
|
|
"UTF-8"))
|
2017-04-21 22:43:28 +02:00
|
|
|
|
(call-with-output-string
|
|
|
|
|
(lambda (port)
|
2017-04-20 18:46:38 +02:00
|
|
|
|
(write prologue port)
|
|
|
|
|
(write
|
|
|
|
|
`(exit
|
|
|
|
|
,(match exp
|
|
|
|
|
((_ ...)
|
|
|
|
|
(remove module-form? exp))
|
|
|
|
|
(_ `(,exp))))
|
2017-04-21 22:43:28 +02:00
|
|
|
|
port))))
|
2012-11-09 00:07:10 +01:00
|
|
|
|
|
|
|
|
|
;; The references don't really matter
|
|
|
|
|
;; since the builder is always used in
|
|
|
|
|
;; conjunction with the drv that needs
|
|
|
|
|
;; it. For clarity, we add references
|
|
|
|
|
;; to the subset of INPUTS that are
|
|
|
|
|
;; sources, avoiding references to other
|
|
|
|
|
;; .drv; otherwise, BUILDER's hash would
|
|
|
|
|
;; depend on those, even if they are
|
|
|
|
|
;; fixed-output.
|
|
|
|
|
(filter-map source-path inputs)))
|
|
|
|
|
|
2012-10-22 23:30:35 +02:00
|
|
|
|
(mod-drv (and (pair? modules)
|
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 13:34:52 +01:00
|
|
|
|
(%imported-modules store modules
|
|
|
|
|
#:guile guile-drv
|
|
|
|
|
#:system system)))
|
2012-06-12 00:18:14 +02:00
|
|
|
|
(mod-dir (and mod-drv
|
derivations: 'derivation' and related procedures return a single value.
* guix/derivations.scm (derivation->output-path,
derivation->output-paths): New procedures.
(derivation-path->output-path): Use 'derivation->output-path'.
(derivation-path->output-paths): Use 'derivation->output-paths'.
(derivation): Accept 'derivation?' objects as inputs. Return a single
value.
(build-derivations): New procedure.
(compiled-modules): Use 'derivation->output-paths'.
(build-expression->derivation)[source-path]: Add case for when the
input matches 'derivation?'.
[prologue]: Accept 'derivation?' objects in INPUTS.
[mod-dir, go-dir]: Use 'derivation->output-path'.
* guix/download.scm (url-fetch): Adjust to the single-value return.
* guix/packages.scm (package-output): Use 'derivation->output-path'.
* guix/scripts/build.scm (guix-build): When the argument is
'derivation-path?', pass it through 'read-derivation'.
Use 'derivation-file-name' to print out the .drv file names, and to
register them. Use 'derivation->output-path' instead of
'derivation-path->output-path'.
* guix/scripts/package.scm (roll-back): Adjust to the single-value
return.
(guix-package): Use 'derivation->output-path'.
* guix/ui.scm (show-what-to-build): Adjust to deal with 'derivation?'
objects instead of .drv file names.
* gnu/system/grub.scm (grub-configuration-file): Use
'derivation->output-path' instead of 'derivation-path->output-path'.
* gnu/system/vm.scm (qemu-image, system-qemu-image): Likewise.
* tests/builders.scm, tests/derivations.scm, tests/packages.scm,
tests/store.scm, tests/union.scm: Adjust to the new calling
convention.
* doc/guix.texi (Defining Packages, The Store, Derivations): Adjust
accordingly.
2013-09-18 17:01:40 +02:00
|
|
|
|
(derivation->output-path mod-drv)))
|
2012-10-22 23:30:35 +02:00
|
|
|
|
(go-drv (and (pair? modules)
|
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 13:34:52 +01:00
|
|
|
|
(%compiled-modules store modules
|
|
|
|
|
#:guile guile-drv
|
|
|
|
|
#:system system)))
|
2012-10-22 23:30:35 +02:00
|
|
|
|
(go-dir (and go-drv
|
derivations: 'derivation' and related procedures return a single value.
* guix/derivations.scm (derivation->output-path,
derivation->output-paths): New procedures.
(derivation-path->output-path): Use 'derivation->output-path'.
(derivation-path->output-paths): Use 'derivation->output-paths'.
(derivation): Accept 'derivation?' objects as inputs. Return a single
value.
(build-derivations): New procedure.
(compiled-modules): Use 'derivation->output-paths'.
(build-expression->derivation)[source-path]: Add case for when the
input matches 'derivation?'.
[prologue]: Accept 'derivation?' objects in INPUTS.
[mod-dir, go-dir]: Use 'derivation->output-path'.
* guix/download.scm (url-fetch): Adjust to the single-value return.
* guix/packages.scm (package-output): Use 'derivation->output-path'.
* guix/scripts/build.scm (guix-build): When the argument is
'derivation-path?', pass it through 'read-derivation'.
Use 'derivation-file-name' to print out the .drv file names, and to
register them. Use 'derivation->output-path' instead of
'derivation-path->output-path'.
* guix/scripts/package.scm (roll-back): Adjust to the single-value
return.
(guix-package): Use 'derivation->output-path'.
* guix/ui.scm (show-what-to-build): Adjust to deal with 'derivation?'
objects instead of .drv file names.
* gnu/system/grub.scm (grub-configuration-file): Use
'derivation->output-path' instead of 'derivation-path->output-path'.
* gnu/system/vm.scm (qemu-image, system-qemu-image): Likewise.
* tests/builders.scm, tests/derivations.scm, tests/packages.scm,
tests/store.scm, tests/union.scm: Adjust to the new calling
convention.
* doc/guix.texi (Defining Packages, The Store, Derivations): Adjust
accordingly.
2013-09-18 17:01:40 +02:00
|
|
|
|
(derivation->output-path go-drv))))
|
2013-08-26 22:11:04 +02:00
|
|
|
|
(derivation store name guile
|
2012-06-12 00:18:14 +02:00
|
|
|
|
`("--no-auto-compile"
|
|
|
|
|
,@(if mod-dir `("-L" ,mod-dir) '())
|
|
|
|
|
,builder)
|
2012-10-22 23:30:35 +02:00
|
|
|
|
|
2019-07-10 18:18:19 +02:00
|
|
|
|
;; 'build-expression->derivation' is somewhat deprecated so
|
|
|
|
|
;; don't bother warning here.
|
|
|
|
|
#:%deprecation-warning? #f
|
|
|
|
|
|
2013-08-26 22:11:04 +02:00
|
|
|
|
#:system system
|
|
|
|
|
|
|
|
|
|
#:inputs `((,(or guile-for-build (%guile-for-build)))
|
|
|
|
|
(,builder)
|
|
|
|
|
,@(map cdr inputs)
|
|
|
|
|
,@(if mod-drv `((,mod-drv) (,go-drv)) '()))
|
|
|
|
|
|
2012-10-22 23:30:35 +02:00
|
|
|
|
;; When MODULES is non-empty, shamelessly clobber
|
|
|
|
|
;; $GUILE_LOAD_COMPILED_PATH.
|
2013-08-26 22:11:04 +02:00
|
|
|
|
#:env-vars (if go-dir
|
|
|
|
|
`(("GUILE_LOAD_COMPILED_PATH" . ,go-dir)
|
|
|
|
|
,@(alist-delete "GUILE_LOAD_COMPILED_PATH"
|
|
|
|
|
env-vars))
|
|
|
|
|
env-vars)
|
|
|
|
|
|
2012-06-09 23:16:55 +02:00
|
|
|
|
#:hash hash #:hash-algo hash-algo
|
2014-02-21 23:03:19 +01:00
|
|
|
|
#:recursive? recursive?
|
2013-08-26 22:19:21 +02:00
|
|
|
|
#:outputs outputs
|
2014-01-25 17:04:35 +01:00
|
|
|
|
#:references-graphs references-graphs
|
2014-06-06 17:07:26 +02:00
|
|
|
|
#:allowed-references allowed-references
|
2016-03-20 22:40:31 +01:00
|
|
|
|
#:disallowed-references disallowed-references
|
2015-07-03 00:05:16 +02:00
|
|
|
|
#:local-build? local-build?
|
2018-11-26 22:14:11 +01:00
|
|
|
|
#:substitutable? substitutable?
|
|
|
|
|
#:properties properties)))
|
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 13:34:52 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;
|
|
|
|
|
;;; Monadic interface.
|
|
|
|
|
;;;
|
|
|
|
|
|
|
|
|
|
(define built-derivations
|
|
|
|
|
(store-lift build-derivations))
|
2016-11-19 16:56:47 +01:00
|
|
|
|
|
|
|
|
|
(define raw-derivation
|
|
|
|
|
(store-lift derivation))
|