Re: [PATCH 6/7] guix build: Add 'build-package'.

2015-09-22 Thread Alex Kost
Ludovic Courtès (2015-09-22 18:12 +0300) wrote:

> Alex Kost  skribis:
[...]
>> 'build-package' will be placed 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:
>> .
>
> ‘guix package --install-from-file’ was committed but I don’t think it
> actually needs ‘build-package’.

David also suggested the same option for ‘guix build’, and that's what I
talked about (not ‘guix package’) — it wasn't implemented (presumably
because there was no ‘build-package’ analog).

>> From ce35de1359ae11a2e73f129db4f7685985f3d041 Mon Sep 17 00:00:00 2001
>> From: Alex Kost 
>> 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 
>
> OK!

Thank you, I have pushed this patch and the commits for the elisp side
you OKeyed a month ago.  So I also send the rest patches to finish this
"guix-devel.el" stuff.

-- 
Alex



Re: [PATCH 6/7] guix build: Add 'build-package'.

2015-09-22 Thread Ludovic Courtès
Alex Kost  skribis:

> Ludovic Courtès (2015-09-08 23:10 +0300) wrote:
>
>> Alex Kost  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

Correct.

> '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:
> .

‘guix package --install-from-file’ was committed but I don’t think it
actually needs ‘build-package’.

> From ce35de1359ae11a2e73f129db4f7685985f3d041 Mon Sep 17 00:00:00 2001
> From: Alex Kost 
> 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 

OK!

Thanks,
Ludo’.



Re: [PATCH 6/7] guix build: Add 'build-package'.

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

> Alex Kost  skribis:
[...]
>> 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.
>
> [...]
>
>> +(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  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:
.

>From ce35de1359ae11a2e73f129db4f7685985f3d041 Mon Sep 17 00:00:00 2001
From: Alex Kost 
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 
---
 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 
 ;;; Copyright © 2014 Deck Pickard 
+;;; Copyright © 2015 Alex Kost 
 ;;;
 ;;; 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
+  

Re: [PATCH 6/7] guix build: Add 'build-package'.

2015-09-08 Thread Ludovic Courtès
Alex Kost  skribis:

> Now about the second patch.  At first, I don't agree with it :-).  I
> added #:dry-run? to ‘build-package’ procedure as I think it may be
> useful, then I found a nice ‘maybe-build’ procedure in (guix scripts
> system), and I just moved it to (guix scripts build) which doesn't seem
> right.
>
> We have some code in (guix scripts …) that is rather common (I mean not
> specific to the current module), but there is no better place for it,
> usually because it uses (guix ui).
>
> So what about making (guix scripts) module for such general stuff?
> I think we can move there ‘maybe-build’, ‘%standard-build-options’,
> ‘set-build-options-from-command-line(*)’, ‘show-build-options-help’,
> perhaps exported procedures from (guix scripts package).  And
> ‘build-package’ may also go there, WDYT?
>
> Or maybe just put those things into (guix ui)?

(guix ui) has become fat; (guix scripts) sounds like a good idea.  Then
things like ‘args-fold*’, ‘parse-command-line’, ‘run-guix-command’,
‘run-guix’, ‘guix-main’, and ‘program-name’ should probably move there
as well (unless I’m overlooking something that would prevent this),
along with ‘maybe-build’ and ‘build-package’.

How does that sound?

> 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 

[...]

> +(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?).

Thanks,
Ludo’.



Re: [PATCH 6/7] guix build: Add 'build-package'.

2015-09-06 Thread Alex Kost
Alex Kost (2015-09-06 12:03 +0300) wrote:

[...]
> diff --git a/guix/store.scm b/guix/store.scm
> index 132b8a3..93f2c77 100644
> --- a/guix/store.scm
> +++ b/guix/store.scm
> @@ -58,6 +58,7 @@
>  close-connection
>  with-store
>  set-build-options
> +set-build-options*
>  valid-path?
>  query-path-hash
>  hash-part->path
> @@ -535,6 +536,9 @@ encoding conversion errors."
>  (let loop ((done? (process-stderr server)))
>(or done? (process-stderr server)
>  
> +(define set-build-options*
> +  (store-lift set-build-options))

Arr, sorry, I sent the wrong patch: ‘set-build-options*’ should be moved
after ‘store-lift’ is defined.  In the current patch I put it after
‘build’ procedure.

>From 4569ff4868a01e205b9b13b41dc587f8b8d67f76 Mon Sep 17 00:00:00 2001
From: Alex Kost 
Date: Thu, 3 Sep 2015 18:33:51 +0300
Subject: [PATCH] store: Add 'set-build-options*'.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Suggested by: Ludovic Courtès 

* guix/store.scm (set-build-options*): New procedure.
---
 guix/store.scm | 4 
 1 file changed, 4 insertions(+)

diff --git a/guix/store.scm b/guix/store.scm
index 132b8a3..5f37e72 100644
--- a/guix/store.scm
+++ b/guix/store.scm
@@ -58,6 +58,7 @@
 close-connection
 with-store
 set-build-options
+set-build-options*
 valid-path?
 query-path-hash
 hash-part->path
@@ -986,6 +987,9 @@ permission bits are kept."
   ;; Monadic variant of 'build-things'.
   (store-lift build-things))
 
+(define set-build-options*
+  (store-lift set-build-options))
+
 (define %guile-for-build
   ;; The derivation of the Guile to be used within the build environment,
   ;; when using 'gexp->derivation' and co.
-- 
2.5.0



Re: [PATCH 6/7] guix build: Add 'build-package'.

2015-08-28 Thread Ludovic Courtès
Alex Kost alez...@gmail.com skribis:

 Ludovic Courtès (2015-08-26 14:12 +0300) wrote:

 Alex Kost alez...@gmail.com skribis:

 Ludovic Courtès (2015-08-18 17:15 +0300) wrote:

 Alex Kost alez...@gmail.com skribis:

 * guix/scripts/build.scm (build-package): New procedure.

 [...]

 +(define (build-package package . build-options)
 +  Build PACKAGE using BUILD-OPTIONS.
 +  (with-store store
 +(let* ((drv (run-with-store store
 +  (package-derivation package)))
 +   (drvs (list drv)))
 +  (apply set-build-options store build-options)
 +  (show-what-to-build store drvs)
 +  (build-derivations store drvs)
 +  (show-derivation-outputs drv

 I think this doesn’t fit here because it isn’t actually used by ‘guix
 build’.  Maybe keep it in emacs/ for now?

 If you mean guix-main.scm, I don't think it's the right place either,
 as all this guix-devel stuff does not depend on Guix REPL (or on any
 code from guix-main.scm in general).  Besides, guix-main.scm doesn't
 provide a module.

 What about making some additional module?: (guix devel) or something.
 Other similar code may be put there in future.  For example, you are
 editing a package definition and you may want to download the current
 origin source.  It will probably also require some specific scheme code,
 which may be added to that module.

 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.)

Could you send an updated patch?

Sorry for the delay and round trips!

Ludo’.



Re: [PATCH 6/7] guix build: Add 'build-package'.

2015-08-26 Thread Alex Kost
Ludovic Courtès (2015-08-26 14:12 +0300) wrote:

 Alex Kost alez...@gmail.com skribis:

 Ludovic Courtès (2015-08-18 17:15 +0300) wrote:

 Alex Kost alez...@gmail.com skribis:

 * guix/scripts/build.scm (build-package): New procedure.

 [...]

 +(define (build-package package . build-options)
 +  Build PACKAGE using BUILD-OPTIONS.
 +  (with-store store
 +(let* ((drv (run-with-store store
 +  (package-derivation package)))
 +   (drvs (list drv)))
 +  (apply set-build-options store build-options)
 +  (show-what-to-build store drvs)
 +  (build-derivations store drvs)
 +  (show-derivation-outputs drv

 I think this doesn’t fit here because it isn’t actually used by ‘guix
 build’.  Maybe keep it in emacs/ for now?

 If you mean guix-main.scm, I don't think it's the right place either,
 as all this guix-devel stuff does not depend on Guix REPL (or on any
 code from guix-main.scm in general).  Besides, guix-main.scm doesn't
 provide a module.

 What about making some additional module?: (guix devel) or something.
 Other similar code may be put there in future.  For example, you are
 editing a package definition and you may want to download the current
 origin source.  It will probably also require some specific scheme code,
 which may be added to that module.

 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?

-- 
Alex



Re: [PATCH 6/7] guix build: Add 'build-package'.

2015-08-26 Thread Ludovic Courtès
Alex Kost alez...@gmail.com skribis:

 Ludovic Courtès (2015-08-18 17:15 +0300) wrote:

 Alex Kost alez...@gmail.com skribis:

 * guix/scripts/build.scm (build-package): New procedure.

 [...]

 +(define (build-package package . build-options)
 +  Build PACKAGE using BUILD-OPTIONS.
 +  (with-store store
 +(let* ((drv (run-with-store store
 +  (package-derivation package)))
 +   (drvs (list drv)))
 +  (apply set-build-options store build-options)
 +  (show-what-to-build store drvs)
 +  (build-derivations store drvs)
 +  (show-derivation-outputs drv

 I think this doesn’t fit here because it isn’t actually used by ‘guix
 build’.  Maybe keep it in emacs/ for now?

 If you mean guix-main.scm, I don't think it's the right place either,
 as all this guix-devel stuff does not depend on Guix REPL (or on any
 code from guix-main.scm in general).  Besides, guix-main.scm doesn't
 provide a module.

 What about making some additional module?: (guix devel) or something.
 Other similar code may be put there in future.  For example, you are
 editing a package definition and you may want to download the current
 origin source.  It will probably also require some specific scheme code,
 which may be added to that module.

Maybe ‘build-package’ could go to (guix packages)?

 Bonus points for making it all monadic-style:

   (mbegin %store-monad
 (set-build-options* opts)
 (mlet* %store-monad ((drv  (package-derivation))
  (drvs (list drv)))
   (mbegin %store-monad
 (show-what-to-build* drvs)
 (built-derivations drvs)
 (return (show-derivation-outputs drv)

 and (define set-build-options* (store-lift set-build-options)) in
 (guix store).

 WDYT?

 OK, I'll look at it.  I suppose adding 'set-build-options*' to (guix
 store) should be done in a separate commit, right?

Yes please.

Thank you,
Ludo’.



Re: [PATCH 6/7] guix build: Add 'build-package'.

2015-08-19 Thread Alex Kost
Ludovic Courtès (2015-08-18 17:15 +0300) wrote:

 Alex Kost alez...@gmail.com skribis:

 * guix/scripts/build.scm (build-package): New procedure.

 [...]

 +(define (build-package package . build-options)
 +  Build PACKAGE using BUILD-OPTIONS.
 +  (with-store store
 +(let* ((drv (run-with-store store
 +  (package-derivation package)))
 +   (drvs (list drv)))
 +  (apply set-build-options store build-options)
 +  (show-what-to-build store drvs)
 +  (build-derivations store drvs)
 +  (show-derivation-outputs drv

 I think this doesn’t fit here because it isn’t actually used by ‘guix
 build’.  Maybe keep it in emacs/ for now?

If you mean guix-main.scm, I don't think it's the right place either,
as all this guix-devel stuff does not depend on Guix REPL (or on any
code from guix-main.scm in general).  Besides, guix-main.scm doesn't
provide a module.

What about making some additional module?: (guix devel) or something.
Other similar code may be put there in future.  For example, you are
editing a package definition and you may want to download the current
origin source.  It will probably also require some specific scheme code,
which may be added to that module.

 Also, it’s best to call ‘set-build-options’ before anything else, to
 make sure all the options are taken into account.

OK

 Bonus points for making it all monadic-style:

   (mbegin %store-monad
 (set-build-options* opts)
 (mlet* %store-monad ((drv  (package-derivation))
  (drvs (list drv)))
   (mbegin %store-monad
 (show-what-to-build* drvs)
 (built-derivations drvs)
 (return (show-derivation-outputs drv)

 and (define set-build-options* (store-lift set-build-options)) in
 (guix store).

 WDYT?

OK, I'll look at it.  I suppose adding 'set-build-options*' to (guix
store) should be done in a separate commit, right?

-- 
Alex



Re: [PATCH 6/7] guix build: Add 'build-package'.

2015-08-18 Thread Ludovic Courtès
Alex Kost alez...@gmail.com skribis:

 * guix/scripts/build.scm (build-package): New procedure.

[...]

 +(define (build-package package . build-options)
 +  Build PACKAGE using BUILD-OPTIONS.
 +  (with-store store
 +(let* ((drv (run-with-store store
 +  (package-derivation package)))
 +   (drvs (list drv)))
 +  (apply set-build-options store build-options)
 +  (show-what-to-build store drvs)
 +  (build-derivations store drvs)
 +  (show-derivation-outputs drv

I think this doesn’t fit here because it isn’t actually used by ‘guix
build’.  Maybe keep it in emacs/ for now?

Also, it’s best to call ‘set-build-options’ before anything else, to
make sure all the options are taken into account.

Bonus points for making it all monadic-style:

  (mbegin %store-monad
(set-build-options* opts)
(mlet* %store-monad ((drv  (package-derivation))
 (drvs (list drv)))
  (mbegin %store-monad
(show-what-to-build* drvs)
(built-derivations drvs)
(return (show-derivation-outputs drv)

and (define set-build-options* (store-lift set-build-options)) in
(guix store).

WDYT?

Ludo’.