summaryrefslogtreecommitdiff
path: root/emacs/guix-ui-package.el
diff options
context:
space:
mode:
Diffstat (limited to 'emacs/guix-ui-package.el')
-rw-r--r--emacs/guix-ui-package.el105
1 files changed, 103 insertions, 2 deletions
diff --git a/emacs/guix-ui-package.el b/emacs/guix-ui-package.el
index edc36486fc..4280246bb8 100644
--- a/emacs/guix-ui-package.el
+++ b/emacs/guix-ui-package.el
@@ -111,6 +111,19 @@ is found and `guix-package-list-single' is nil."
(list (if (= 0 package-id) package-id-str package-id)
output))))
+(defun guix-package-build-log-file (id)
+ "Return build log file name of a package defined by ID."
+ (guix-eval-read
+ (guix-make-guile-expression 'package-build-log-file id)))
+
+(defun guix-package-find-build-log (id)
+ "Show build log of a package defined by ID."
+ (require 'guix-build-log)
+ (let ((file (guix-package-build-log-file id)))
+ (if file
+ (guix-build-log-find-file file)
+ (message "Couldn't find the package build log."))))
+
;;; Processing package actions
@@ -222,6 +235,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 +323,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)
@@ -325,6 +345,14 @@ prompt depending on `guix-operation-confirm' variable)."
:type 'boolean
:group 'guix-package-info)
+(defcustom guix-package-info-button-functions
+ '(guix-package-info-insert-build-button
+ guix-package-info-insert-build-log-button)
+ "List of functions used to insert package buttons in Info buffer.
+Each function is called with 2 arguments: package ID and full name."
+ :type '(repeat function)
+ :group 'guix-package-info)
+
(defvar guix-package-info-download-buffer nil
"Buffer from which a current download operation was performed.")
@@ -521,6 +549,78 @@ 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))
+ (full-name (guix-package-entry->name-specification entry))
+ (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))
+ (when guix-package-info-button-functions
+ (insert "\n")
+ (guix-mapinsert (lambda (fun)
+ (funcall fun package-id full-name))
+ guix-package-info-button-functions
+ (guix-info-get-indent)
+ :indent guix-info-indent
+ :column (guix-info-fill-column))))))
+
+(defun guix-package-info-insert-build-button (id full-name)
+ "Insert button to build a package defined by ID."
+ (guix-info-insert-action-button
+ "Build"
+ (lambda (btn)
+ (guix-build-package (button-get btn 'id)
+ (format "Build '%s' package?" full-name)))
+ (format "Build the current package")
+ 'id id))
+
+(defun guix-package-info-insert-build-log-button (id _name)
+ "Insert button to show build log of a package defined by ID."
+ (guix-info-insert-action-button
+ "Build Log"
+ (lambda (btn)
+ (guix-package-find-build-log (button-get btn 'id)))
+ "View build log of the current package"
+ 'id 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 +917,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))