Commit Graph

157 Commits

Author SHA1 Message Date
Ludovic Courtès 7adf9b8469 derivations: Move grafts to (guix grafts).
* guix/derivations.scm (<graft>, graft-derivation, %graft?)
(set-grafting): Move to...
* guix/grafts.scm: ... here.  New file.
* guix/gexp.scm, guix/packages.scm, tests/packages.scm,
guix/scripts/build.scm: Use it.
* Makefile.am (MODULES): Add it.
(SCM_TESTS): Add tests/grafts.scm.
* tests/derivations.scm ("graft-derivation"): Move to...
* tests/grafts.scm: ... here.  New file.
2016-02-22 22:11:37 +01:00
Ludovic Courtès a8d65643fb guix build: Add '--check'.
* guix/derivations.scm (build-derivations): Add optional 'mode'
parameter.
* guix/scripts/build.scm (%default-options): Add 'build-mode'.
(show-help, %options): Add '--check'.
(guix-build): Honor 'build-mode' key of OPTS.  Pass it to
'show-what-to-build' and 'build-derivations'.
* doc/guix.texi (Invoking guix build): Document it.
(Substitutes): Mention it.
2015-12-09 14:29:41 +01:00
Ludovic Courtès 58c08df054 derivations: Determine what's built in 'check' mode.
* guix/derivations.scm (substitution-oracle): Add #:mode parameter and
honor it.
(derivation-prerequisites-to-build): Likewise.
[derivation-built?]: Take it into account.
* guix/ui.scm (show-what-to-build): Add #:mode parameter.  Pass it to
'substitute-oracle' and 'derivations-prerequisites-to-build'.
* tests/derivations.scm ("derivation-prerequisites-to-build in 'check'
mode"): New test.
2015-12-09 14:29:41 +01:00
Ludovic Courtès 1eabf4ec63 derivations: Improve docstring of 'substitution-oracle'.
* guix/derivations.scm (substitution-oracle): Improve docstring.
2015-07-22 22:56:41 +02:00
Ludovic Courtès b59df2434a derivations: Improve complexity of 'substitution-oracle'.
* guix/derivations.scm (substitution-oracle): Use a final 'concatenate'
  instead of repeated 'append's.
2015-07-22 22:56:41 +02:00
Ludovic Courtès 4a6aeb670f derivations: Add #:substitutable?, distinguished from #:local-build?.
Fixes <http://bugs.gnu.org/18747>.

* guix/derivations.scm (substitutable-derivation?): Rewrite to check for
  "allowSubstitutes".
  (derivation): Add #:substitutable? parameter.
  [user+system-env-vars]: Honor it.
  (build-expression->derivation): Add #:substitutable? and honor it.
* guix/gexp.scm (gexp->derivation): Likewise.
* tests/derivations.scm ("derivation-prerequisites-to-build and substitutes,
  non-substitutable build"): Use #:substitutable? instead of #:local-build?.
  ("substitutable-derivation?", "derivation-prerequisites-to-build and
  substitutes, local build"): New tests.
* guix/download.scm (url-fetch): Adjust comment.
* guix/git-download.scm (git-fetch): Likewise.
* guix/build-system/gnu.scm (gnu-build, gnu-cross-build): Use #:substitutable?
  instead of #:local-build?.
* doc/guix.texi (Derivations, G-Expressions): Adjust accordingly.
2015-07-03 00:30:55 +02:00
Ludovic Courtès c04681554d derivations: Add #:leaked-env-vars parameter.
Suggested by Joshua Randall <jcrandall@alum.mit.edu>
in <http://bugs.gnu.org/20402>.

* guix/derivations.scm (derivation): Add #:leaked-env-vars parameter.
  [user+system-env-vars]: Honor it.
* guix/gexp.scm (gexp->derivation): Add #:leaked-env-vars and pass it to
  'raw-derivation'.
* doc/guix.texi (Derivations, G-Expressions): Adjust accordingly.
2015-05-01 00:06:17 +02:00
Ludovic Courtès c3a450fb49 derivations: 'substitution-oracle' now ignores sub-trees that are valid.
Before that, "guix build qt", when only qt itself is missing, would lead
'substitution-oracle' to call 'substitutable-paths' with 318 items.
Now, this is down to 6 items, because it doesn't ask about prerequisites
that are already valid.

* guix/derivations.scm (substitution-oracle)[valid-input?,
  dependencies]: New procedures.
  Use 'dependencies' and remove call to 'remove'.
2015-03-25 10:46:22 +01:00
Ludovic Courtès 3681db5d2c derivations: Add a 'cut?' parameter to 'derivation-prerequisites'.
* guix/derivations.scm (valid-derivation-input?): New procedure.
  (derivation-prerequisites): Add 'cut?' parameter and honor it.
* tests/derivations.scm ("derivation-prerequisites and
  derivation-input-is-valid?"): New test.
2015-03-25 10:46:22 +01:00
Ludovic Courtès c7d1d88f6c derivations: Don't invoke the substituter when an item is already in store.
Fixes <http://bugs.gnu.org/20188>.
Reported by Mark H Weaver <mhw@netris.org>.

* guix/derivations.scm (substitution-oracle): Add 'valid?' procedure.
  Remove 'valid?' items from PATHS.
2015-03-24 23:22:23 +01:00
Ludovic Courtès 9d8100f4c7 packages: Move grafting parameter to (guix derivations).
* guix/packages.scm (%graft?, set-grafting): Move to...
* guix/derivations.scm: ... here.
2015-03-17 22:25:55 +01:00
Ludovic Courtès aa72d9afdf gexp: Implement 'imported-modules' & co. using 'gexp->derivation'.
* guix/derivations.scm (imported-files): Keep private.
  (%imported-modules, %compiled-modules, build-expression->derivation):
  Mark as deprecated.
  (imported-modules, compiled-modules): Remove.
* guix/gexp.scm (%mkdir-p-definition): New variable.
  (imported-files, search-path*, imported-modules, compiled-modules):
  New procedures.
* tests/derivations.scm ("imported-files"): Remove.
* tests/gexp.scm ("imported-files", "gexp->derivation #:modules"): New
  tests.
2015-02-13 17:28:19 +01:00
Ludovic Courtès fbe952c99f derivations: Make the "grafting..." message directly visible.
* guix/derivations.scm (graft-derivation)[build]: Add call to
  'force-output'.
2015-02-11 11:11:01 +01:00
Ludovic Courtès 01d8ac64ab store: Remove 'build-derivations'.
* guix/store.scm (build-derivations): Remove.
* guix/derivations.scm (build-derivations): Write in terms of
  'build-things'.
* doc/guix.texi (Invoking guix build): Adjust text accordingly.
2015-02-02 12:46:36 +01:00
Ludovic Courtès f304c9c237 derivations: Raise an error for references to non-existent outputs.
Fixes <http://bugs.gnu.org/19630>.
Reported by Ricardo Wurmus <ricardo.wurmus@mdc-berlin.de>.

* guix/derivations.scm (&derivation-error,
  &derivation-missing-output-error): New error conditions.
  (derivation->output-path): Raise a '&derivation-missing-output-error'
  if OUTPUT is not an output of DRV.
* guix/ui.scm (call-with-error-handling): Add case for
  'derivation-missing-output-error?'.
  (show-what-to-build): Check whether (derivation-outputs drv) is
  empty.
* tests/packages.scm ("reference to non-existent output"): Add test.
2015-01-24 22:57:49 +01:00
Ludovic Courtès e87f0591f3 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
Ludovic Courtès c06d140c03 derivations: Use a set for 'substitution-oracle'.
* guix/derivations.scm (substitution-oracle): Use sets instead of lists.
2015-01-11 23:50:01 +01:00
Ludovic Courtès ed3592a980 derivations: Use sets for 'derivations-prerequisites'.
This yields a 46% improvement in 'derivation-prerequisites' invocations
on the Emacs derivation.

* guix/derivations.scm (derivation-prerequisites): Add 'input-set'
  variable, and use it in iterations.
2015-01-11 23:50:01 +01:00
Ludovic Courtès e9651e39b3 derivations: Add 'substitution-oracle' and use it.
This makes 'guix environment PACKAGE' significantly faster when
substitutes are enabled.  Before that, it would lead to many invocations
of 'guix substitute-binary', one per 'derivation-prerequisites-to-build'
call.  Now, all these are replaced by a single invocation.

* guix/derivations.scm (derivation-output-paths, substitution-oracle):
  New procedures.
  (derivation-prerequisites-to-build): Replace #:use-substitutes? with
  #:substitutable?.  Remove the local 'derivation-output-paths' and
  'substitutable?'.
* guix/ui.scm (show-what-to-build): Add 'substitutable?'.  Pass it to
  'derivation-prerequisites-to-build'.
  [built-or-substitutable?]: Use it instead of 'has-substitutes?'.
* tests/derivations.scm ("derivation-prerequisites-to-build and
  substitutes"): Use #:substitutable? instead of #:use-substitutes?.
2015-01-10 00:39:59 +01:00
Ludovic Courtès 0b6af195fe derivations: Add 'derivation-output-names'.
* guix/derivations.scm (derivation-output-names): New procedure.
  (derivation-prerequisites-to-build): Use it for #:outputs.
  (map-derivation): Likewise.
* tests/derivations.scm ("derivation-output-names"): New test.
2015-01-09 23:36:24 +01:00
Ludovic Courtès 7ce7361b76 derivations: Export 'derivation-builder'.
* guix/derivations.scm: Export 'derivation-builder'.
2014-12-02 16:51:43 +01:00
Ludovic Courtès 7f614a747c derivations: Clarify message produced by 'graft-derivation'.
* guix/derivations.scm (graft-derivation): Use the term "grafting" in
  the build message.
2014-11-13 11:35:13 +01:00
Ludovic Courtès e786293e76 derivations: Add 'derivation-name'.
* guix/derivations.scm (derivation-name): New procedure.
* tests/derivations.scm ("derivation-name"): New test.
2014-11-02 21:22:12 +01:00
Ludovic Courtès d2d0514b58 derivations: Fix 'derivation-prerequisites-to-build' when #:local-build?.
* guix/derivations.scm (derivation-prerequisites-to-build)[derivation-substitutable?]:
  Call 'substitutable-derivation?'.
  <body>: When 'substitutable-derivation?' returns #f, add DRV to BUILD.
2014-10-29 00:31:23 +01:00
Ludovic Courtès fc93e30919 derivations: Add 'offloadable-derivation?' and 'substitutable-derivation?'.
* guix/derivations.scm (offloadable-derivation?,
  substitutable-derivation?): New procedures.
* tests/derivations.scm ("offloadable-derivation?"): New test.
2014-10-29 00:31:23 +01:00
Ludovic Courtès e5997888fa derivations: 'graft-derivation' correctly handles multiple-output sources.
* guix/derivations.scm (graft-derivation): Add DRV as input for each one
  of OUTPUT-NAMES.
2014-10-17 23:23:20 +02:00
Ludovic Courtès 3d7d17b318 derivations: Add #:system parameter to 'graft-derivation'.
* guix/derivations.scm (graft-derivation): Add #:system parameter.
2014-10-17 23:23:20 +02:00
Ludovic Courtès 969df97487 derivations: Introduce 'graft' record type.
* guix/derivations.scm (<graft>): New record type.
  (graft-derivation): Rename 'replacements' to 'grafts', and expect it
  to be a list of <graft> records.  Adjust accordingly.
* tests/derivations.scm ("graft-derivation"): Use 'graft' instead of
  pairs in argument to 'graft-derivation'.
2014-10-17 23:23:20 +02:00
Ludovic Courtès 8601d0ddcf derivations: Micro-optimize 'imported-modules'.
This reduces run time of (package-derivation s emacs) by ~5%.

* guix/derivations.scm (search-path*): New procedure.
  (imported-modules): Use it instead of 'search-path'.
2014-10-13 23:34:09 +02:00
Ludovic Courtès 1391dcb054 derivations: Memoize 'derivation-path->base16-hash'.
This reduces run time of (package-derivation s emacs) by ~10%.

* guix/derivations.scm (derivation-path->base16-hash): New procedure.
  (derivation-hash): Use it.
2014-10-13 23:34:09 +02:00
Ludovic Courtès 78a90c7f47 derivations: Add #:guile parameter to 'graft-derivation'.
* guix/derivations.scm (graft-derivation): Add #:guile parameter; pass
  it to 'build-expression->derivation'.
2014-10-12 22:32:38 +02:00
Ludovic Courtès fb59e275dd derivations: Add 'graft-derivation'.
* guix/derivations.scm (graft-derivation): New procedure.
* guix/build/graft.scm: New file.
* Makefile.am (MODULES): Add it.
* tests/derivations.scm ("graft-derivation"): New test.
2014-10-08 12:01:49 +02:00
Ludovic Courtès 63a4282468 derivations: 'build-expression->derivation' supports #:allowed-references.
* guix/derivations.scm (build-expression->derivation): Add
  #:allowed-references and pass it to 'derivation.
* doc/guix.texi (Derivations): Adjust accordingly.
2014-06-06 17:07:26 +02:00
Ludovic Courtès b53be755e4 derivations: Add #:allowed-references 'derivation' parameter.
* guix/derivations.scm (derivation): Add #:allowed-references
  parameter.
  [user+system-env-vars]: Honor it.
* tests/derivations.scm ("derivation #:allowed-references, ok",
  "derivation #:allowed-references, not allowed",
  "derivation #:allowed-references, self allowed",
  "derivation #:allowed-references, self not allowed"): New tests.
* doc/guix.texi (Derivations): Document #:allowed-references.
2014-06-01 23:32:26 +02:00
Ludovic Courtès be4e38fb6f derivations: Micro-optimize 'derivation'.
* guix/derivations.scm (derivation->string): New procedure.
  (derivation-hash, derivation): Use it.
  Memoization here yields a 5% improvement on "guix build -e '(@ (gnu
  packages emacs) emacs)' -n --no-substitutes".
2014-04-29 18:13:10 +02:00
Ludovic Courtès 99e17dc927 derivations: Fix 'fixed-output-derivation?'.
Reported by Nikita Karetnikov <nikita@karetnikov.org>.

* guix/derivations.scm (fixed-output-derivation?): Fix pattern.
* tests/derivations.scm ("fixed-output-derivation?"): Add test.
2014-04-13 00:42:07 +02:00
Ludovic Courtès 0562dbe5d3 Merge branch 'master' into core-updates 2014-03-17 18:26:46 +01:00
Ludovic Courtès 6f58d58243 More /gnu/store replacements.
* gnu/packages/gcc.scm (gcc-4.7): Change /nix/store in comment.
* gnu/system/vm.scm (operating-system-default-contents):
  Use (%store-prefix) instead of "/nix/store".
* guix/derivations.scm (derivation-path->output-path,
  derivation-path->output-paths): Change to /gnu/store in docstring.
2014-03-10 23:58:40 +01:00
Ludovic Courtès b2bfa32d25 Merge branch 'master' into core-updates
Conflicts:
	gnu-system.am
2014-02-22 00:27:57 +01:00
Ludovic Courtès 2096ef47aa derivations: Remove unused 'derivation' parameter.
* guix/derivations.scm (derivation): Remove unused #:hash-mode parameter.
* doc/guix.texi (Derivations): Adjust accordingly.
2014-02-21 23:49:53 +01:00
Ludovic Courtès 36bbbbd150 derivations: Add support for recursive fixed-output derivations.
* guix/derivations.scm (<derivation-output>): Add 'recursive?' field.
  Adjust 'make-derivation-output' callers.
  (%read-derivation) <fixed-output>: When HASH-ALGO starts with 'r:',
  set the 'recursive?' field and drop 'r:' from the hash algo name.
  (write-derivation)[write-output]: Write the algo as 'r:HASH-ALGO' when
  the RECURSIVE? field is set.
  (derivation-hash) <fixed-output>: Prepend "r:" when RECURSIVE? is set.
  (fixed-output-path): New procedure.
  (derivation): Add #:recursive? parameter.  Use 'fixed-output-path' to
  compute the output file name of a fixed output derivation.
  (build-expression->derivation): Add #:recursive? parameter.  Pass it
  to 'derivation'.
* tests/derivations.scm ("fixed-output derivation, recursive",
  "build-expression->derivation produces recursive fixed-output",
  "build-expression->derivation uses recursive fixed-output"): New
  tests.
* doc/guix.texi (Derivations): Document #:recursive? for 'derivation'.
  Add #:recursive? for 'build-expression->derivation'.
2014-02-21 23:49:52 +01:00
Ludovic Courtès 6ce206cb92 Prefer local builds for "small" derivations.
* gnu/system.scm (union, file-union, links): Pass #:local-build? #t to
  'derivation-expression'.
* guix/derivations.scm (imported-files, compiled-modules): Likewise.
* guix/profiles.scm (profile-derivation): Likewise.
2014-01-25 17:22:53 +01:00
Ludovic Courtès 1909431c5b derivations: Add #:local-build? parameter for derivations.
* guix/derivations.scm (derivation): Add #:local-build? parameter and
  honor it.
  (build-expression->derivation): Likewise.
* doc/guix.texi (Derivations): Update documentation of these
  procedures.
2014-01-25 17:04:35 +01:00
Ludovic Courtès dd1a5a152c 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:53 +01:00
Ludovic Courtès a716e36de9 derivations: Allow 'map-derivations' to replace sources.
* guix/derivations.scm (map-derivation)[input->output-paths]: Allow
  non-derivation inputs.
  Allow replacements to be store files.  Replace in SOURCES too.
* tests/derivations.scm ("map-derivation, sources"): New test.
2013-11-13 11:22:07 +01:00
Ludovic Courtès 9336e5b5e7 store: Make 'direct-store-path?' public.
* guix/store.scm (direct-store-path?): New procedure.
* guix/derivations.scm (derivation)[direct-store-path?]: Remove.
* tests/store.scm ("direct-store-path?"): New test.
2013-11-13 00:29:05 +01:00
Ludovic Courtès e387ab7c10 derivations: Add 'map-derivation'.
* guix/derivations.scm (map-derivation): New procedure.
* tests/derivations.scm ("map-derivation"): New test.
2013-11-13 00:29:05 +01:00
Ludovic Courtès d0dc4907d6 derivations: 'derivation-path->output-path' honors the 'output' parameter.
* guix/derivations.scm (derivation-path->output-path): Pass OUTPUT.
* tests/derivations.scm ("multiple-output derivation,
  derivation-path->output-path"): New test.
2013-10-30 22:09:32 +01:00
Ludovic Courtès 59688fc4b5 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 18:49:53 +02:00
Ludovic Courtès 07c86312ca derivations: Add a nicer printer.
* guix/derivations.scm (<derivation>): Add a printer.
2013-09-18 11:10:02 +02:00
Ludovic Courtès 6a446d5680 derivations: Keep the .drv file name in <derivation> objects.
* guix/derivations.scm (<derivation>): Add 'file-name' field.
  (%read-derivation): Use (port-filename DRV-PORT) as the file name for
  the result.
  (derivation): Set the 'file-name' field in the result.
* tests/derivations.scm ("build derivation with 1 source"): Assert that
  'derivation-file-name' returns the right thing.
2013-09-17 23:02:13 +02:00
Ludovic Courtès f989fa392f gnu: linux-initrd: Allow Guile modules to be embedded in the initrd.
* gnu/packages/linux-initrd.scm (raw-build-system): New macro.
  (module-package, compiled-module-package): New procedures.
  (expression->initrd): Add `modules' keyword parameter.
  Add "modules" and "modules/compiled" inputs; copy them onto the
  initrd.
* guix/derivations.scm (imported-modules, compiled-modules): Publicize.
2013-08-29 00:05:03 +02:00
Ludovic Courtès 858e92823f derivations: Rename #:dependency-graphs to #:references-graphs.
* guix/derivations.scm (derivation, build-expression->derivation):
  Rename #:dependency-graphs to #:references-graphs, for consistency in
  the terminology.
* tests/derivations.scm: Adjust accordingly.
2013-08-28 00:55:40 +02:00
Ludovic Courtès 9c629a27a4 derivations: Add #:dependency-graphs to `build-expression->derivation'.
* guix/derivations.scm (build-expression->derivation): Add
  #:dependency-graphs keyword argument.  Pass it to `derivation'.
* tests/derivations.scm ("build-expression->derivation with
  #:dependency-graphs"): New test.
* doc/guix.texi (Derivations): Update `build-expression->derivation'
  description.
2013-08-26 22:20:58 +02:00
Ludovic Courtès 5b0c9d1635 derivations: Add #:dependency-graphs `derivation' parameter.
* guix/derivations.scm (derivation): Add `dependency-graphs' keyword
  parameter; honor it.
* tests/derivations.scm (bootstrap-binary): New procedure.
  (%bash): Use it.
  (%mkdir): New variable.
  (directory-contents): Add `slurp' optional parameter.
  ("derivation with #:dependency-graphs"): New test.
* doc/guix.texi (Derivations): Update accordingly.
2013-08-26 22:20:53 +02:00
Ludovic Courtès a987d2c025 derivations: Move 3 positional parameters into keyword parameters.
* guix/derivations.scm (derivation): Turn `system', `env-vars', and
  `inputs' into keyword parameters.
  (build-expression->derivation): Adjust accordingly.
* gnu/packages/bootstrap.scm (%bootstrap-guile): Likewise.
* tests/derivations.scm, tests/store.scm: Likewise.
* doc/guix.texi (Derivations): Likewise.
2013-08-26 22:20:27 +02:00
Ludovic Courtès b0fad8a2d4 Use `port-sha256' and `open-sha256-port'.
* guix/derivations.scm (derivation-hash): Add comment as to why we keep
  the plain `sha256' call.
* guix/scripts/download.scm (guix-download): Use `port-sha256' instead
  of (compose sha256 get-bytevector-all).
* guix/scripts/refresh.scm (update-package): Likewise.
2013-07-03 01:18:24 +02:00
Ludovic Courtès 72626a71a9 Move `sha256' to (guix hash).
* guix/utils.scm (sha256): Move to...
* guix/hash.scm: ... here.  New file.
* Makefile.am (MODULES): Add it.
* guix/derivations.scm, guix/scripts/download.scm,
  guix/scripts/hash.scm, guix/scripts/refresh.scm, tests/base32.scm,
  tests/derivations.scm, tests/store.scm: Use (guix hash).
2013-07-01 23:28:21 +02:00
Ludovic Courtès 0bd31a2188 derivations: Micro-optimize `derivation-hash'.
* guix/derivations.scm (derivation-hash): Use a UTF-8-encoded string
  output port.  This makes things deterministic, and slightly faster.
2013-06-14 15:48:29 +02:00
Ludovic Courtès dd36b51bf7 scripts: Report what will be substituted.
* guix/derivations.scm (derivation-input-output-paths): New procedure.
  (derivation-prerequisites-to-build): New `use-substitutes?' keyword
  argument.  Change two return the list of substitutable paths as a
  second argument.
* guix/ui.scm (show-what-to-build): Turn `dry-run?' into a keyword
  argument.  New `use-substitutes?' keyword argument.  Use `fold2' and
  adjust to use both return values of
  `derivation-prerequisites-to-build'.  Display what will/would be
  downloaded.
* guix/scripts/build.scm (guix-build): Adjust accordingly.
* guix/scripts/package.scm (guix-package): Likewise.
* tests/derivations.scm ("derivation-prerequisites-to-build and
  substitutes"): New test.
2013-04-17 00:08:21 +02:00
Ludovic Courtès 0bb1aa9e05 derivations: Optimize `build-expression->derivation'.
This reduces the execution time of
"guix build -e '(@ (gnu packages emacs) emacs)' -d" by 6%, from
1.15s to 1.08s.

* guix/derivations.scm (build-expression->derivation): Write the builder
  as UTF-8.
2013-03-16 17:23:17 +01:00
Ludovic Courtès d80855999a derivations: Optimize `write-derivation'.
This reduces the execution time of
"guix build -e '(@ (gnu packages emacs) emacs)' -d" by 25%, from
1.54 s. to 1.15s.

* guix/derivations.scm (write-sequence, write-list, write-tuple): New
  procedures.
  (write-derivation)[list->string, write-list]: Remove.
  [write-string-list, write-output, write-input, write-env-var]: New helpers.
  Rewrite in terms of these new helpers.
2013-03-16 16:48:22 +01:00
Ludovic Courtès 8dcb0c55ab derivations: Add a search path parameter for module derivations.
* guix/derivations.scm (imported-modules, compiled-modules): Add a
  `module-path' parameter.  Use it instead of %LOAD-PATH.
2013-02-20 21:08:09 +01:00
Ludovic Courtès d0840e4a23 derivations: Memoize `read-derivation'.
* guix/derivations.scm (read-derivation): Rename to...
  (%read-derivation): ... this.
  (read-derivation): New procedure.
  This reduces the execution of "guix-build gdb" from 2.5s to 1.7s.
2013-01-30 18:58:38 +01:00
Ludovic Courtès a9ebd9efd0 store: Remove the `fixed?' parameter from `add-to-store'.
* guix/store.scm (add-to-store): Remove the `fixed?' parameter from the
  public interface.
* gnu/packages/bootstrap.scm, guix-download.in, guix/derivations.scm,
  guix/packages.scm, tests/derivations.scm: Update all callers
  accordingly.
2013-01-30 16:30:49 +01:00
Ludovic Courtès 874e687428 doc: Start documenting derivations.
* doc/guix.texi (Defining Packages): Add cross-reference to
  "Derivations".
  (The Store): Add `build-derivations'.
  (Derivations): Populate.
2013-01-16 23:09:53 +01:00
Ludovic Courtès 784bb1f37b derivations: Fix `derivation-prerequisites-to-build' when outputs are there.
Before it would list inputs not built, even if the outputs of the given
derivation were already available.

* guix/derivations.scm (derivation-prerequisites-to-build): Add
  `outputs' keyword parameter.
  [built?, derivation-built?]: New procedures.
  [loop]: Add `sub-drvs' parameter.  Use `derivation-built?' to check if
  the SUB-DRVS of DRV are built before checking its inputs.
2013-01-09 08:38:57 +01:00
Ludovic Courtès 233e76769a Update license headers.
Change all license headers, except guix/build/* and ld-wrapper.scm, with
this code:

  (use-modules (guix build utils)
	       (srfi srfi-1))

  (fluid-set! %default-port-encoding "UTF-8")

  (substitute* (remove (lambda (f)
			 (or (string-contains f ".tar.")
			     (string-contains f ".git/")
			     (string-contains f ".so")
			     (string-suffix? ".o" f)
			     (string-suffix? ".a" f)
			     (string-suffix? ".go" f)
			     (string-suffix? ".pdf" f)
			     (string-suffix? ".png" f)
			     (string-suffix? ".info" f)
			     (equal? (basename f) "guix-daemon")
			     (equal? (basename f) "nix-setuid-helper")
			     (string-contains f "nix-upstream/")
			     (string-contains f "distro/packages/bootstrap/")))
		       (find-files "." "\\.[a-z]+$"))
    (("^([[:graph:]]+) This file is part of Guix." _ comment-start)
     (string-append comment-start " This file is part of GNU Guix."))
    (("^([[:graph:]]+) Guix --- Nix package management.*" _ comment-start)
     (string-append comment-start
		    " GNU Guix --- Functional package management for GNU\n"))
    (("^([[:graph:]]+) Guix is " _ comment-start)
     (string-append comment-start " GNU Guix is "))
    (("^([[:graph:]]+) along with Guix." _ comment-start)
     (string-append comment-start " along with GNU Guix."))
    (("^([[:graph:]]+) Copyright \\(C\\)" _ comment-start)
     (string-append comment-start " Copyright ©")))

Change headers using C-style comments manually.
2013-01-06 00:47:50 +01:00
Ludovic Courtès 7244a5f74e derivations: Add `derivation-path->output-paths'.
* guix/derivations.scm (derivation-path->output-paths): New procedure.
* tests/derivations.scm ("multiple-output derivation"): Test it.
2013-01-05 23:51:13 +01:00
Ludovic Courtès 200dc93761 derivations: Distinguish direct store paths from files within a store path.
* guix/derivations.scm (derivation)[direct-store-path?]: New procedure.
  Use it to determine which inputs must be added to the store.
2012-12-10 00:44:17 +01:00
Ludovic Courtès 860a6f1ae0 derivations: Fix erroneous call to `add-to-store' for local files as input.
* guix/derivations.scm (derivation)[inputs]: Fix typo in call to
  `add-to-store'.
* tests/derivations.scm ("derivation with local file as input"): New test.
* tests/packages.scm ("trivial with local file as input"): New test.
2012-12-04 23:46:50 +01:00
Ludovic Courtès ddc29a782e 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
Ludovic Courtès 7bdd1f0e3c derivations: build-expression->derivation: Builder only refers to sources.
* guix/derivations.scm (build-expression->derivation)[source-path]: New
  procedure.
  [builder]: Pass only sources as references.  This fixes a bug whereby
  changing a fixed-output drv referred to by a builder would cause the
  builder's hash to change, thereby leading to a full rebuild.
* tests/derivations.scm ("build-expression->derivation with a
  fixed-output input"): New test.
2012-11-09 00:07:10 +01:00
Ludovic Courtès ae39d1b233 derivations: Make sure `build-expression->derivation' & co. pass `system'.
* guix/derivations.scm (imported-files): Call
  `build-expression->derivation' with SYSTEM, not (%current-system).
  (build-expression->derivation): Pass SYSTEM to `imported-modules' and
  `compiled-modules'.
2012-10-25 23:14:27 +02:00
Ludovic Courtès b272c47433 derivations: Pass the derivation of guile-for-build to `imported-files' & co.
* guix/derivations.scm (%guile-for-build): Initialize to #f.
  (imported-files, imported-modules, compiled-modules): Add `guile'
  keyword parameter.  Pass it down to `build-expression->derivation'.
  (build-expression->derivation)[guile-drv]: New variable.  Pass it as
  the #:guile parameter for `imported-modules' and `compiled-modules'.

* tests/derivations.scm: Set %GUILE-FOR-BUILD to the derivation of
  %BOOTSTRAP-GUILE.
2012-10-25 18:03:48 +02:00
Ludovic Courtès d90248844b derivations: Compile the #:modules passed to `build-expression->derivation'.
* guix/derivations.scm (imported-files)[parent-dirs]: Move to...
  (parent-directories): ... here.  New procedure.
  (compiled-modules): New procedure.
  (build-expression->derivation): Use it.

* tests/derivations.scm ("build-expression->derivation with modules"):
  New test.
2012-10-24 00:09:25 +02:00
Ludovic Courtès df7bbd3813 derivations: Set input port to UTF-8 in `read-derivation'.
* guix/derivations.scm (read-derivation): Set DRV-PORT's encoding to
  UTF-8.
2012-10-07 22:28:07 +02:00
Ludovic Courtès aaa848f3af Optimize `write-derivation' and `derivation-path->output-path'.
* guix/derivations.scm (write-derivation): Explicitly use
  `simple-format'.
  (derivation-path->output-path): Memoize.
2012-09-02 01:51:52 +02:00
Ludovic Courtès 6dd7787c39 Add a `guile-for-build' parameter to `build-expression->derivation'.
* guix/derivations.scm (%guile-for-build): Use `nixpkgs-derivation*'
  instead of `nixpkgs-derivation'.
  (build-expression->derivation): New `guile-for-build' keyword
  parameter.  Use it.
2012-09-01 11:45:52 +02:00
Ludovic Courtès 4c1eddf766 Add an `env-vars' keyword parameter to `build-expression->derivation'.
* guix/derivations.scm (build-expression->derivation): New `env-vars'
  keyword parameter; default to '().  Use it.
2012-09-01 11:33:20 +02:00
Ludovic Courtès d44bc84b15 Unset `LD_LIBRARY_PATH' in `build-expression->derivation'.
* guix/derivations.scm (build-expression->derivation)[prolog]: Unset
  `LD_LIBRARY_PATH'.
2012-07-07 22:38:08 +02:00
Ludovic Courtès d66ac374e9 derivation: Coalesce multiple occurrences of the same input.
* guix/derivations.scm (write-derivation)[coalesce-duplicate-inputs]:
  New procedure.
  Use it to process INPUTS.

* tests/derivations.scm ("user of multiple-output derivation"): New
  test.
2012-07-02 01:35:39 +02:00
Ludovic Courtès 561eaf7144 derivation: Move sorting code to `write-derivation'.
* guix/derivations.scm (write-derivation): Sorte OUTPUTS, INPUTS,
  SOURCES, and ENV-VARS alphabetically.
  (derivation-hash): Leave INPUTS, SOURCES, and OUTPUTS unsorted.
  (derivation)[env-vars-with-empty-outputs]: Leave ENV-VARS unsorted.
2012-07-02 01:35:39 +02:00
Ludovic Courtès 4b1786aa2c Fix `derivation-hash' for outputs not sorted alphabetically.
* guix/derivations.scm (derivation-hash): Reorder OUTPUTS.
* tests/derivations.scm ("multiple-output derivation, non-alphabetic
  order"): New test.
2012-07-02 01:35:39 +02:00
Ludovic Courtès 9a20830e57 Add `derivation-prerequisites' and `derivation-prerequisites-to-build'.
* guix/derivations.scm (derivation-prerequisites,
  derivation-prerequisites-to-build): New procedures.

* tests/derivations.scm ("build-expression->derivation and
  derivation-prerequisites", "build-expression->derivation and
  derivation-prerequisites-to-build"): New tests.
2012-07-01 00:37:03 +02:00
Ludovic Courtès d26ad5e45b derivation: Remove duplicate inputs.
* guix/derivations.scm (derivation): Remove duplicates from INPUT.
2012-06-29 00:27:32 +02:00
Ludovic Courtès 0d56a551bf build-expression->derivation: Move module forms at the top-level.
* guix/derivations.scm (build-expression->derivation)[module-form?]: New
  procedure.
  [prologue]: Add any form of EXP that matches MODULE-FORM?.
  [builder]: Remove any MODULE-FORM? from EXP.
2012-06-17 16:43:40 +02:00
Ludovic Courtès db393b333f build-expression->derivation: Have the build fail when EXP returns #f.
* guix/derivations.scm (build-expression->derivation)[builder]: Pass the
  result of EXP to `exit'.

* tests/derivations.scm ("build-expression->derivation with expression
  returning #f"): New test.
2012-06-16 16:46:29 +02:00
Ludovic Courtès 2acb2cb6d0 Change `build-expression->derivation' to support sub-derivation inputs.
* guix/derivations.scm (build-expression->derivation): Change to expect
  INPUTS to have the form (NAME DRV-PATH SUB-DRV) or (NAME DRV-PATH),
  instead of (NAME . DRV-PATH).  Update callers accordingly.

* guix/gnu-build-system.scm, tests/builders.scm, tests/derivations.scm:
  Update accordingly.
2012-06-13 17:21:27 +02:00
Ludovic Courtès c36db98c8e Add supporting tools for the GNU Build System.
* guix/derivations.scm (build-expression->derivation): Add all of INPUTS
  as inputs to the final derivation.

* guix/build/gnu-build-system.scm, guix/build/utils.scm,
  guix/gnu-build-system.scm: New files.

* tests/builders.scm ("gnu-build"): New test.
2012-06-13 17:03:34 +02:00
Ludovic Courtès bcdd83ec69 Fix the order of the derivation's sources in `derivation-hash'.
* guix/derivations.scm (derivation-hash): Sort SOURCES alphabetically as
  well.
2012-06-13 16:45:54 +02:00
Ludovic Courtès 224f7ad6a3 Fix `imported-files' for files with a common prefix.
* guix/derivations.scm (imported-files)[builder]: For TAIL, check
  whether it exists before (mkdir TAIL).

* tests/derivations.scm ("imported-files"): Add file with a common
  prefix.
2012-06-12 23:30:00 +02:00
Ludovic Courtès 3eb982377e Augment `build-expression->derivation' with #:modules; add `http-fetch'.
* guix/derivations.scm (imported-modules): New procedure.
  (build-expression->derivation): New keyword argument `modules'.
  Use `imported-modules' when MODULES is non-empty, and pass it with
  `-L' to GUILE.

* guix/build/http.scm, guix/http.scm, tests/builders.scm: New files.
2012-06-12 00:18:14 +02:00
Ludovic Courtès 99634e3ff4 Add `imported-files'.
* guix/derivations.scm (imported-files): New procedure.
  (build-expression->derivation): Correctly handle inputs that are
  sources and not derivation paths.

* tests/derivations.scm ("imported-files"): New test.
2012-06-11 23:12:55 +02:00
Ludovic Courtès 9bc07f4df0 Add multiple-output support to `build-expression->derivation'.
* guix/derivations.scm (build-expression->derivation): Add `outputs'
  keyword parameter; pass it to `derivation'.  Define `%outputs' in the
  prologue.

* tests/derivations.scm ("build-expression->derivation with two
  outputs"): New test.
2012-06-09 23:16:55 +02:00
Ludovic Courtès af7f9e5f13 Sort environment variables alphabetically in `derivation'.
* guix/derivations.scm (derivation)[env-vars-with-empty-outputs]: Sort
  the result alphabetically.

* tests/derivations.scm ("build derivation with 1 source"): Add
  environment variables.
2012-06-09 21:50:30 +02:00
Ludovic Courtès 26b969dee0 Add support for fixed-output derivations in `build-expression->derivation'.
* guix/derivations.scm (build-expression->derivation): Pass HASH and
  HASH-ALGO to `derivation'.

* tests/derivations.scm ("build-expression->derivation for fixed-output
  derivation"): New test.
2012-06-09 18:52:16 +02:00
Ludovic Courtès 749c656755 Add support for fixed-output derivations.
* guix/derivations.scm (read-derivation)[outputs->alist]: For
  fixed-outputs, convert HASH with `base16-string->bytevector'.
  (write-derivation): Likewise, convert HASH-ALGO to a string and HASH
  to a base16 string.
  (derivation-hash): Expect HASH to be a bytevector, not a string;
  convert HASH with `bytevector->base16-string'.

* tests/derivations.scm ("fixed-output derivation"): New test.
2012-06-09 18:49:19 +02:00
Ludovic Courtès d9085c23c4 Add `build-expression->derivation'.
* guix/derivations.scm (%guile-for-build): New parameter.
  (build-expression->derivation): New procedure.

* tests/derivations.scm ("build-expression->derivation without inputs",
  "build-expression->derivation with one input"): New tests.
2012-06-08 21:31:01 +02:00
Ludovic Courtès de4c3f26cb Allow derivations with input derivations.
* guix/derivations.scm (derivation-path->output-path): New procedure.
  (derivation-hash): Call `memoize'.  In the fixed-output case, convert
  HASH-ALGO to a string.  In the other case, sort inputs in the
  alphabetical order of their hex hash.  For inputs with no sub-drvs,
  add "out" as the sub-drv.

* guix/utils.scm (%nixpkgs-directory): New parameter.
  (nixpkgs-derivation, memoize): New procedures.

* tests/derivations.scm ("build derivation with 1 source"): Remove
  useless shebang.
  (%coreutils): New variable.
  ("build derivation with coreutils"): New test.
2012-06-07 23:15:00 +02:00