aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Kost <alezost@gmail.com>2016-05-08 23:27:42 +0300
committerAlex Kost <alezost@gmail.com>2016-05-31 23:51:54 +0300
commitd01ebd05d11775dea7c8d0a084c3ab02b958e18b (patch)
treefe2fb9ddb62700d93962bccc7f3be46d0a759855
parent7a0094a5f29cd6f49213c020ac55cb2f17f5d8cb (diff)
downloadguix-d01ebd05d11775dea7c8d0a084c3ab02b958e18b.tar
guix-d01ebd05d11775dea7c8d0a084c3ab02b958e18b.tar.gz
emacs: Show built output directories in Package Info.
* emacs/guix-main.scm (package-store-path): New procedure. * emacs/guix-base.el (guix-package-store-path): New procedure. * emacs/guix-ui-package.el (guix-package-info-auto-find-package): New variable. (guix-package-info-show-store-path, guix-package-info-insert-misc): New procedures. (guix-package-info-format, guix-output-info-format): Add 'guix-package-info-insert-misc'.
-rw-r--r--emacs/guix-base.el7
-rw-r--r--emacs/guix-main.scm11
-rw-r--r--emacs/guix-ui-package.el56
3 files changed, 72 insertions, 2 deletions
diff --git a/emacs/guix-base.el b/emacs/guix-base.el
index 888836428f..962010050b 100644
--- a/emacs/guix-base.el
+++ b/emacs/guix-base.el
@@ -207,6 +207,13 @@ Ask a user with PROMPT for continuing an operation."
(guix-make-guile-expression
'package-source-path package-id)))
+(defun guix-package-store-path (package-id)
+ "Return a list of store directories of outputs of package PACKAGE-ID."
+ (message "Calculating the package derivation ...")
+ (guix-eval-read
+ (guix-make-guile-expression
+ 'package-store-path package-id)))
+
(defvar guix-after-source-download-hook nil
"Hook run after successful performing a 'source-download' operation.")
diff --git a/emacs/guix-main.scm b/emacs/guix-main.scm
index e645a85e7d..c4f1b4ada0 100644
--- a/emacs/guix-main.scm
+++ b/emacs/guix-main.scm
@@ -953,6 +953,17 @@ GENERATIONS is a list of generation numbers."
((package _ ...) package)))
(compose location->string package-location)))
+(define (package-store-path package-id)
+ "Return a list of store directories of outputs of package PACKAGE-ID."
+ (match (package-by-id package-id)
+ (#f '())
+ (package
+ (with-store store
+ (map (match-lambda
+ ((_ . drv)
+ (derivation-output-path drv)))
+ (derivation-outputs (package-derivation store package)))))))
+
(define (package-source-derivation->store-path derivation)
"Return a store path of the package source DERIVATION."
(match (derivation-outputs derivation)
diff --git a/emacs/guix-ui-package.el b/emacs/guix-ui-package.el
index edc36486fc..eebecc7077 100644
--- a/emacs/guix-ui-package.el
+++ b/emacs/guix-ui-package.el
@@ -222,6 +222,7 @@ ENTRIES is a list of package entries to get info about packages."
(description ignore (simple guix-package-info-description))
ignore
(outputs simple guix-package-info-insert-outputs)
+ guix-package-info-insert-misc
(source simple guix-package-info-insert-source)
(location simple guix-package-info-insert-location)
(home-url format (format guix-url))
@@ -309,9 +310,15 @@ ENTRIES is a list of package entries to get info about packages."
"Face used if a package is obsolete."
:group 'guix-package-info-faces)
+(defcustom guix-package-info-auto-find-package t
+ "If non-nil, open store directory after pressing \"Show\" package button.
+If nil, just display the store directory (or directories) without finding."
+ :type 'boolean
+ :group 'guix-package-info)
+
(defcustom guix-package-info-auto-find-source nil
- "If non-nil, find a source file after pressing a \"Show\" button.
-If nil, just display the source file path without finding."
+ "If non-nil, open source file after pressing \"Show\" source button.
+If nil, just display the source file name without finding."
:type 'boolean
:group 'guix-package-info)
@@ -521,6 +528,50 @@ ENTRY is an alist with package info."
(guix-entry-id entry))
'output output)))
+(defun guix-package-info-show-store-path (entry-id package-id)
+ "Show store directories of the package outputs in the current buffer.
+ENTRY-ID is an ID of the current entry (package or output).
+PACKAGE-ID is an ID of the package which store path to show."
+ (let* ((entries (guix-buffer-current-entries))
+ (entry (guix-entry-by-id entry-id entries))
+ (dirs (guix-package-store-path package-id)))
+ (or dirs
+ (error "Couldn't define store directory of the package"))
+ (let* ((new-entry (cons (cons 'store-path dirs)
+ entry))
+ (new-entries (guix-replace-entry entry-id new-entry entries)))
+ (setf (guix-buffer-item-entries guix-buffer-item)
+ new-entries)
+ (guix-buffer-redisplay-goto-button)
+ (let ((dir (car dirs)))
+ (if (file-exists-p dir)
+ (if guix-package-info-auto-find-package
+ (find-file dir)
+ (message nil))
+ (message "'%s' does not exist.\nTry to build this package."
+ dir))))))
+
+(defun guix-package-info-insert-misc (entry)
+ "Insert various buttons and other info for package ENTRY at point."
+ (if (guix-entry-value entry 'obsolete)
+ (guix-format-insert nil)
+ (let* ((entry-id (guix-entry-id entry))
+ (package-id (or (guix-entry-value entry 'package-id)
+ entry-id))
+ (store-path (guix-entry-value entry 'store-path)))
+ (guix-info-insert-title-simple "Package")
+ (if store-path
+ (guix-info-insert-value-indent store-path 'guix-file)
+ (guix-info-insert-action-button
+ "Show"
+ (lambda (btn)
+ (guix-package-info-show-store-path
+ (button-get btn 'entry-id)
+ (button-get btn 'package-id)))
+ "Show the store directory of the current package"
+ 'entry-id entry-id
+ 'package-id package-id)))))
+
(defun guix-package-info-show-source (entry-id package-id)
"Show file name of a package source in the current info buffer.
Find the file if needed (see `guix-package-info-auto-find-source').
@@ -817,6 +868,7 @@ for all ARGS."
(version format guix-output-info-insert-version)
(output format guix-output-info-insert-output)
(synopsis simple (indent guix-package-info-synopsis))
+ guix-package-info-insert-misc
(source simple guix-package-info-insert-source)
(path simple (indent guix-file))
(dependencies simple (indent guix-file))