>From 9ffc27f7a076e4213ef3bee00e5cebad501685ac Mon Sep 17 00:00:00 2001 From: Alex Kost Date: Thu, 23 Jul 2015 16:16:41 +0300 Subject: [PATCH 2/2] guix build: Add 'build-package'. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * guix/scripts/system.scm (maybe-build): Move to ... * guix/scripts/build.scm: ...here. (build-package): New procedure. Co-authored-by: Ludovic Courtès --- guix/scripts/build.scm | 41 ++++++++++++++++++++++++++++++++++++++++- guix/scripts/system.scm | 13 ------------- 2 files changed, 40 insertions(+), 14 deletions(-) diff --git a/guix/scripts/build.scm b/guix/scripts/build.scm index f169853..ee4a3d6 100644 --- a/guix/scripts/build.scm +++ b/guix/scripts/build.scm @@ -1,6 +1,7 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2012, 2013, 2014, 2015 Ludovic Courtès ;;; Copyright © 2013 Mark H Weaver +;;; Copyright © 2015 Alex Kost ;;; ;;; This file is part of GNU Guix. ;;; @@ -39,9 +40,47 @@ set-build-options-from-command-line set-build-options-from-command-line* show-build-options-help - + maybe-build + build-package guix-build)) +;; XXX This procedure does not belong this module: it is used by +;; 'build-package' and (guix scripts system). +(define* (maybe-build drvs + #:key dry-run? use-substitutes?) + "Show what will/would be built, and actually build DRVS, unless DRY-RUN? is +true." + (with-monad %store-monad + (>>= (show-what-to-build* drvs + #:dry-run? dry-run? + #:use-substitutes? use-substitutes?) + (lambda (_) + (if dry-run? + (return #f) + (built-derivations drvs)))))) + +;; XXX This procedure does not belong this module, but currently there +;; is no better place for it. It is used by Emacs development tools +;; ("emacs/guix-devel.el"). +(define* (build-package package + #:key (use-substitutes? #t) (dry-run? #f) + #:allow-other-keys + #:rest build-options) + "Build PACKAGE using BUILD-OPTIONS. +Show what and how will/would be built." + (with-store store + (run-with-store store + (mbegin %store-monad + (apply set-build-options* + #:use-substitutes? use-substitutes? + (strip-keyword-arguments '(#:dry-run?) build-options)) + (mlet %store-monad ((derivation (package->derivation package))) + (mbegin %store-monad + (maybe-build (list derivation) + #:use-substitutes? use-substitutes? + #:dry-run? dry-run?) + (return (show-derivation-outputs derivation)))))))) + (define (register-root store paths root) "Register ROOT as an indirect GC root for all of PATHS." (let* ((root (string-append (canonicalize-path (dirname root)) diff --git a/guix/scripts/system.scm b/guix/scripts/system.scm index 45f5982..0db4953 100644 --- a/guix/scripts/system.scm +++ b/guix/scripts/system.scm @@ -298,19 +298,6 @@ it atomically, and then run OS's activation script." ((disk-image) (system-disk-image os #:disk-image-size image-size)))) -(define* (maybe-build drvs - #:key dry-run? use-substitutes?) - "Show what will/would be built, and actually build DRVS, unless DRY-RUN? is -true." - (with-monad %store-monad - (>>= (show-what-to-build* drvs - #:dry-run? dry-run? - #:use-substitutes? use-substitutes?) - (lambda (_) - (if dry-run? - (return #f) - (built-derivations drvs)))))) - (define* (perform-action action os #:key grub? dry-run? use-substitutes? device target -- 2.5.0