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'.
master
Alex Kost 2016-05-08 23:27:42 +03:00
parent 7a0094a5f2
commit d01ebd05d1
No known key found for this signature in database
GPG Key ID: 82460C082A0EE98F
3 changed files with 72 additions and 2 deletions

View File

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

View File

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

View File

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