unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Alex Kost <alezost@gmail.com>
To: "Ludovic Courtès" <ludo@gnu.org>
Cc: guix-devel@gnu.org
Subject: Re: [PATCH 6/7] guix build: Add 'build-package'.
Date: Fri, 18 Sep 2015 21:51:36 +0300	[thread overview]
Message-ID: <87fv2bh87b.fsf@gmail.com> (raw)
In-Reply-To: 87io7ku0ys.fsf@gnu.org

[-- Attachment #1: Type: text/plain, Size: 2340 bytes --]

Ludovic Courtès (2015-09-08 23:10 +0300) wrote:

> Alex Kost <alezost@gmail.com> skribis:
[...]
>> From 9ffc27f7a076e4213ef3bee00e5cebad501685ac Mon Sep 17 00:00:00 2001
>> From: Alex Kost <alezost@gmail.com>
>> 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.
>
> [...]
>
>> +(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*
>
> Please remove ‘with-store’ and ‘run-with-store’.  This should be done on
> the Emacs side (maybe via the ,run-in-store meta-command?).

Sure, ",run-in-store" sounds great.  I have pushed the patches for
adding (guix scripts), 'set-build-options*' and
'show-derivation-outputs', so the attached patch (for adding
'build-package') is applied cleanly to master.

Ludovic Courtès (2015-08-28 12:24 +0300) wrote:

> Alex Kost <alezost@gmail.com> skribis:
>
>> Ludovic Courtès (2015-08-26 14:12 +0300) wrote:
>>
>>> Maybe ‘build-package’ could go to (guix packages)?
>>
>> ‘build-package’ uses ‘show-…’ procedures from (guix ui) module.  I
>> thought that adding this module to (guix packages) was not desired, or
>> is it OK?
>
> Right, sorry.  So maybe leave in (guix build scripts) with a comment
> explaining that it doesn’t have a better place and is for use by the
> Emacs UI.  (Make sure to use the monadic style as suggested in a
> previous message.)

So I suppose this comment is not needed anymore (right?) as
'build-package' will beplaced in (guix scripts), and it looks like a
rather general procedure.  For example, it may be used for something
like ‘guix build --package-from-file’ suggested by David:
<http://lists.gnu.org/archive/html/guix-devel/2015-08/msg00107.html>.


[-- Attachment #2: 0001-scripts-Add-build-package.patch --]
[-- Type: text/x-patch, Size: 4024 bytes --]

From ce35de1359ae11a2e73f129db4f7685985f3d041 Mon Sep 17 00:00:00 2001
From: Alex Kost <alezost@gmail.com>
Date: Thu, 23 Jul 2015 16:16:41 +0300
Subject: [PATCH] scripts: 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.scm: ...here.
  (build-package): New procedure.

Co-authored-by: Ludovic Courtès <ludo@gnu.org>
---
 guix/scripts.scm        | 39 ++++++++++++++++++++++++++++++++++++++-
 guix/scripts/system.scm | 13 -------------
 2 files changed, 38 insertions(+), 14 deletions(-)

diff --git a/guix/scripts.scm b/guix/scripts.scm
index 6bb3e21..e34d389 100644
--- a/guix/scripts.scm
+++ b/guix/scripts.scm
@@ -1,6 +1,7 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2013, 2014, 2015 Ludovic Courtès <ludo@gnu.org>
 ;;; Copyright © 2014 Deck Pickard <deck.r.pickard@gmail.com>
+;;; Copyright © 2015 Alex Kost <alezost@gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -20,11 +21,17 @@
 (define-module (guix scripts)
   #:use-module (guix utils)
   #:use-module (guix ui)
+  #:use-module (guix store)
+  #:use-module (guix monads)
+  #:use-module (guix packages)
+  #:use-module (guix derivations)
   #:use-module (srfi srfi-1)
   #:use-module (srfi srfi-37)
   #:use-module (ice-9 match)
   #:export (args-fold*
-            parse-command-line))
+            parse-command-line
+            maybe-build
+            build-package))
 
 ;;; Commentary:
 ;;;
@@ -78,4 +85,34 @@ parameter of 'args-fold'."
       ;; ARGS take precedence over what the environment variable specifies.
       (parse-options-from args seeds))))
 
+(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* (build-package package
+                        #:key dry-run? (use-substitutes? #t)
+                        #:allow-other-keys
+                        #:rest build-options)
+  "Build PACKAGE using BUILD-OPTIONS acceptable by 'set-build-options'.
+Show what and how will/would be built."
+  (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))))))
+
 ;;; scripts.scm ends here
diff --git a/guix/scripts/system.scm b/guix/scripts/system.scm
index 32d4057..5e2d226 100644
--- a/guix/scripts/system.scm
+++ b/guix/scripts/system.scm
@@ -299,19 +299,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


  parent reply	other threads:[~2015-09-18 18:51 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-25  8:49 [PATCH 0/7] Add "guix-devel-…" commands Alex Kost
2015-07-25  8:49 ` [PATCH 1/7] emacs: Move guile related code to "guix-guile.el" Alex Kost
2015-08-18 13:50   ` Ludovic Courtès
2015-08-18 13:51   ` Ludovic Courtès
2015-07-25  8:49 ` [PATCH 2/7] emacs: Move code for evaluating to "guix-geiser.el" Alex Kost
2015-08-18 13:52   ` Ludovic Courtès
2015-07-25  8:49 ` [PATCH 3/7] emacs: Add code to call guile procedures Alex Kost
2015-08-18 13:52   ` Ludovic Courtès
2015-07-25  8:49 ` [PATCH 4/7] emacs: Add 'guix-devel-use-current-module' Alex Kost
2015-07-25 18:51   ` Mathieu Lirzin
2015-07-26  8:29     ` Alex Kost
2015-07-26 14:00       ` Mathieu Lirzin
2015-07-26 18:11         ` Alex Kost
2015-07-28  9:19           ` Mathieu Lirzin
2015-08-18 14:05   ` Ludovic Courtès
2015-08-19 20:47     ` Alex Kost
2015-08-26 11:07       ` Ludovic Courtès
2015-07-25  8:49 ` [PATCH 5/7] ui: Add 'show-derivation-outputs' Alex Kost
2015-08-18 14:07   ` Ludovic Courtès
2015-07-25  8:49 ` [PATCH 6/7] guix build: Add 'build-package' Alex Kost
2015-08-18 14:15   ` Ludovic Courtès
2015-08-19 20:50     ` Alex Kost
2015-08-26 11:12       ` Ludovic Courtès
2015-08-26 17:44         ` Alex Kost
2015-08-28  9:24           ` Ludovic Courtès
2015-09-06  9:03             ` Alex Kost
2015-09-06  9:32               ` Alex Kost
2015-09-08 19:59                 ` Ludovic Courtès
2015-09-08 20:10               ` Ludovic Courtès
2015-09-10 10:25                 ` [PATCH] Add (guix scripts) Alex Kost
2015-09-14 13:34                   ` Ludovic Courtès
2015-09-14 18:39                     ` Alex Kost
2015-09-16 20:21                       ` Ludovic Courtès
2015-09-18 18:52                         ` Alex Kost
2015-09-18 18:51                 ` Alex Kost [this message]
2015-09-22 15:12                   ` [PATCH 6/7] guix build: Add 'build-package' Ludovic Courtès
2015-09-22 19:10                     ` Alex Kost
2015-09-22 21:39                       ` Ludovic Courtès
2015-07-25  8:49 ` [PATCH 7/7] emacs: Add 'guix-devel-use-current-module' Alex Kost
2015-08-18 14:17   ` Ludovic Courtès
2015-08-19 20:51     ` [PATCH 7/7] emacs: Add 'guix-devel-build-current-package-definition' Alex Kost
2015-08-26 11:14       ` Ludovic Courtès
2015-09-22 19:10         ` [PATCH 1/2] emacs: Add development utils Alex Kost
2015-09-22 21:44           ` Ludovic Courtès
2015-08-18 13:50 ` [PATCH 0/7] Add "guix-devel-…" commands Ludovic Courtès
2015-08-19 20:47   ` Alex Kost
2015-08-25 20:59     ` Ludovic Courtès
2015-09-22 19:11       ` [PATCH 2/2] emacs: Add 'guix-devel-build-package-definition' Alex Kost
2015-09-22 21:47         ` Ludovic Courtès

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87fv2bh87b.fsf@gmail.com \
    --to=alezost@gmail.com \
    --cc=guix-devel@gnu.org \
    --cc=ludo@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).