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: [PATCH] emacs: Add 'guix-devel-build-package-source'.
Date: Fri, 09 Oct 2015 17:00:23 +0300	[thread overview]
Message-ID: <87bnc8rvk8.fsf_-_@gmail.com> (raw)
In-Reply-To: <87twq1twg2.fsf@gnu.org> ("Ludovic \=\?utf-8\?Q\?Court\=C3\=A8s\=22'\?\= \=\?utf-8\?Q\?s\?\= message of "Thu, 08 Oct 2015 13:46:05 +0200")

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

Ludovic Courtès (2015-10-08 14:46 +0300) wrote:

[...]
> The command to call ‘package-source-derivation’ for the package at point
> is still welcome, though.  :-)

Thanks, here it is.

‘build-package-source’ procedure (as I see it) is very similar to
‘build-package’, so maybe it is worth to make a macro or something,
WDYT?


[-- Attachment #2: 0001-emacs-Add-guix-devel-build-package-source.patch --]
[-- Type: text/x-patch, Size: 4381 bytes --]

From d2f72a9375fe592ebf5fe5ee84ad6db614ea2c03 Mon Sep 17 00:00:00 2001
From: Alex Kost <alezost@gmail.com>
Date: Fri, 9 Oct 2015 16:45:24 +0300
Subject: [PATCH] emacs: Add 'guix-devel-build-package-source'.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Suggested by Ludovic Courtès <ludo@gnu.org>.

* guix/scripts.scm (build-package-source): New procedure.
* emacs/guix-devel.el (guix-devel-build-package-source): New command.
  (guix-devel-keys-map): Add key binding for it.
* doc/emacs.texi (Emacs Development): Document it.
---
 doc/emacs.texi      |  6 ++++++
 emacs/guix-devel.el | 16 ++++++++++++++++
 guix/scripts.scm    | 20 +++++++++++++++++++-
 3 files changed, 41 insertions(+), 1 deletion(-)

diff --git a/doc/emacs.texi b/doc/emacs.texi
index 325e14e..ab69515 100644
--- a/doc/emacs.texi
+++ b/doc/emacs.texi
@@ -667,6 +667,12 @@ this command---for example, with @kbd{C-M-x} (@pxref{To eval or not to
 eval,,, geiser, Geiser User Manual})
 (@code{guix-devel-build-package-definition}).
 
+@item C-c . s
+Build a source derivation of the package defined by the current variable
+definition.  This command has the same meaning as @code{guix build -S}
+shell command (@pxref{Invoking guix build})
+(@code{guix-devel-build-package-source}).
+
 @item C-c . l
 Lint (check) a package defined by the current variable definition
 (@pxref{Invoking guix lint}) (@code{guix-devel-lint-package}).
diff --git a/emacs/guix-devel.el b/emacs/guix-devel.el
index 547044f..b833028 100644
--- a/emacs/guix-devel.el
+++ b/emacs/guix-devel.el
@@ -122,6 +122,21 @@ run BODY."
                                       guix-use-substitutes)
                 "#:dry-run?" (guix-guile-boolean guix-dry-run)))))))
 
+(defun guix-devel-build-package-source ()
+  "Build the source of the current package definition."
+  (interactive)
+  (guix-devel-with-definition def
+    (when (or (not guix-operation-confirm)
+              (guix-operation-prompt
+               (format "Build '%s' package source?" def)))
+      (guix-geiser-eval-in-repl
+       (concat ",run-in-store "
+               (guix-guile-make-call-expression
+                "build-package-source" def
+                "#:use-substitutes?" (guix-guile-boolean
+                                      guix-use-substitutes)
+                "#:dry-run?" (guix-guile-boolean guix-dry-run)))))))
+
 (defun guix-devel-lint-package ()
   "Check the current package.
 See Info node `(guix) Invoking guix lint' for details."
@@ -177,6 +192,7 @@ to find 'modify-phases' keywords."
 (defvar guix-devel-keys-map
   (let ((map (make-sparse-keymap)))
     (define-key map (kbd "b") 'guix-devel-build-package-definition)
+    (define-key map (kbd "s") 'guix-devel-build-package-source)
     (define-key map (kbd "l") 'guix-devel-lint-package)
     (define-key map (kbd "k") 'guix-devel-copy-module-as-kill)
     (define-key map (kbd "u") 'guix-devel-use-module)
diff --git a/guix/scripts.scm b/guix/scripts.scm
index e34d389..d84375f 100644
--- a/guix/scripts.scm
+++ b/guix/scripts.scm
@@ -31,7 +31,8 @@
   #:export (args-fold*
             parse-command-line
             maybe-build
-            build-package))
+            build-package
+            build-package-source))
 
 ;;; Commentary:
 ;;;
@@ -115,4 +116,21 @@ Show what and how will/would be built."
                      #:dry-run? dry-run?)
         (return (show-derivation-outputs derivation))))))
 
+(define* (build-package-source package
+                               #:key dry-run? (use-substitutes? #t)
+                               #:allow-other-keys
+                               #:rest build-options)
+  "Build PACKAGE source using BUILD-OPTIONS."
+  (mbegin %store-monad
+    (apply set-build-options*
+           #:use-substitutes? use-substitutes?
+           (strip-keyword-arguments '(#:dry-run?) build-options))
+    (mlet %store-monad ((derivation (origin->derivation
+                                     (package-source 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
-- 
2.5.0


  parent reply	other threads:[~2015-10-09 14:00 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-02 13:04 emacs: devel: Add lint/download commands Alex Kost
2015-10-02 13:04 ` [PATCH 1/4] emacs: Add 'guix-devel-with-definition' Alex Kost
2015-10-03 20:31   ` Ludovic Courtès
2015-10-02 13:04 ` [PATCH 2/4] emacs: Add 'guix-devel-download-package-source' Alex Kost
2015-10-03 20:35   ` Ludovic Courtès
2015-10-04 13:39     ` Alex Kost
2015-10-04 16:57       ` Ludovic Courtès
2015-10-04 18:28         ` Alex Kost
2015-10-05 15:55           ` Ludovic Courtès
2015-10-06 15:11             ` Alex Kost
2015-10-07  2:07               ` Checking signatures on source tarballs Mark H Weaver
2015-10-07  3:18                 ` Christopher Allan Webber
2015-10-07  8:29                 ` Andreas Enge
2015-10-07 12:06                 ` Ludovic Courtès
2015-10-07 14:09                   ` Mark H Weaver
2015-10-07 18:05                     ` Leo Famulari
2015-10-07 20:59                     ` Ludovic Courtès
2015-10-08 11:44                       ` Ludovic Courtès
2015-10-12  8:37                         ` Brandon Invergo
2015-10-12  9:18                           ` [bug-gsrc] " Brandon Invergo
2015-10-12 16:38                             ` Ludovic Courtès
2015-10-12 21:26                               ` Brandon Invergo
2015-10-12 21:34                                 ` Ludovic Courtès
2015-10-12 22:06                                   ` Brandon Invergo
2015-10-13  9:47                                     ` Ludovic Courtès
2015-10-12 16:39                           ` Ludovic Courtès
2016-02-22  4:20                             ` Christopher Allan Webber
2015-10-10  7:22                       ` Alex Vong
2015-10-10 17:03                       ` Mark H Weaver
2015-10-11 17:44                         ` Ludovic Courtès
2015-10-14  5:33                       ` Rastus Vernon
2015-10-15 13:33                         ` Mark H Weaver
2015-10-07 17:45                 ` Alex Kost
2015-10-07 12:23               ` [PATCH 2/4] emacs: Add 'guix-devel-download-package-source' Ludovic Courtès
2015-10-07 17:25                 ` Alex Kost
2015-10-07 19:15                   ` Ian Denhardt
2015-10-09 12:14                     ` Alex Kost
2015-10-07 22:10                   ` Ludovic Courtès
2015-10-08 11:27                     ` Alex Kost
2015-10-08 11:46                       ` Ludovic Courtès
2015-10-09 12:08                         ` Alex Kost
2015-10-09 12:17                           ` Ludovic Courtès
2015-10-09 14:00                         ` Alex Kost [this message]
2015-10-11 18:33                           ` [PATCH] emacs: Add 'guix-devel-build-package-source' Ludovic Courtès
2015-10-08 14:43                       ` [PATCH 2/4] emacs: Add 'guix-devel-download-package-source' Christopher Allan Webber
2015-10-08 15:03                         ` Ludovic Courtès
2015-10-02 13:04 ` [PATCH 3/4] lint: Export 'run-checkers' Alex Kost
2015-10-03 20:36   ` Ludovic Courtès
2015-10-02 13:04 ` [PATCH 4/4] emacs: Add 'guix-devel-lint-package' Alex Kost
2015-10-03 20:44   ` 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=87bnc8rvk8.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).