guix-ui-package.el 46 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169
  1. ;;; guix-ui-package.el --- Interface for displaying packages -*- lexical-binding: t -*-
  2. ;; Copyright © 2014–2016 Alex Kost <alezost@gmail.com>
  3. ;; This file is part of Emacs-Guix.
  4. ;; Emacs-Guix is free software; you can redistribute it and/or modify
  5. ;; it under the terms of the GNU General Public License as published by
  6. ;; the Free Software Foundation, either version 3 of the License, or
  7. ;; (at your option) any later version.
  8. ;;
  9. ;; Emacs-Guix is distributed in the hope that it will be useful,
  10. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. ;; GNU General Public License for more details.
  13. ;;
  14. ;; You should have received a copy of the GNU General Public License
  15. ;; along with Emacs-Guix. If not, see <http://www.gnu.org/licenses/>.
  16. ;;; Commentary:
  17. ;; This file provides an interface for displaying packages and outputs
  18. ;; in 'list' and 'info' buffers, and commands for working with them.
  19. ;;; Code:
  20. (require 'cl-lib)
  21. (require 'dash)
  22. (require 'bui)
  23. (require 'guix nil t)
  24. (require 'guix-ui)
  25. (require 'guix-misc)
  26. (require 'guix-repl)
  27. (require 'guix-guile)
  28. (require 'guix-utils)
  29. (require 'guix-hydra)
  30. (require 'guix-hydra-build)
  31. (require 'guix-read)
  32. (require 'guix-license)
  33. (require 'guix-location)
  34. (require 'guix-profiles)
  35. (guix-ui-define-entry-type package)
  36. (guix-ui-define-entry-type output)
  37. (defcustom guix-package-list-type 'output
  38. "Define how to display packages in 'list' buffer.
  39. Should be a symbol `package' or `output' (if `output', display each
  40. output on a separate line; if `package', display each package on
  41. a separate line)."
  42. :type '(choice (const :tag "List of packages" package)
  43. (const :tag "List of outputs" output))
  44. :group 'guix-package)
  45. (defun guix-package-list-type ()
  46. "Return BUI list entry-type by `guix-package-list-type' variable."
  47. (guix-make-symbol guix-package-list-type))
  48. ;; To avoid compilation warning: this variable is actually defined later
  49. ;; along with the rest "package-list" interface stuff.
  50. (defvar guix-package-list-show-single)
  51. (defun guix-package-get-display (profile search-type &rest search-values)
  52. "Search for packages/outputs and show results.
  53. If PROFILE is nil, use `guix-current-profile'.
  54. See `guix-ui-get-entries' for the meaning of SEARCH-TYPE and
  55. SEARCH-VALUES.
  56. Results are displayed in the list buffer, unless a single package
  57. is found and `guix-package-list-show-single' is nil."
  58. (let* ((args (cl-list* (or profile guix-current-profile)
  59. search-type search-values))
  60. (entries (bui-get-entries (guix-package-list-type) 'list args)))
  61. (if (or guix-package-list-show-single
  62. (null entries)
  63. (cdr entries))
  64. (bui-display-entries entries (guix-package-list-type) 'list args)
  65. (bui-get-display-entries 'guix-package 'info args))))
  66. (defun guix-package-entry->name-specification (entry &optional output)
  67. "Return name specification of the package ENTRY and OUTPUT."
  68. (guix-package-name-specification
  69. (bui-entry-non-void-value entry 'name)
  70. (bui-entry-non-void-value entry 'version)
  71. (or output (bui-entry-non-void-value entry 'output))))
  72. (defun guix-package-entries->name-specifications (entries)
  73. "Return name specifications by the package or output ENTRIES."
  74. (cl-remove-duplicates (mapcar #'guix-package-entry->name-specification
  75. entries)
  76. :test #'string=))
  77. (defun guix-package-installed-outputs (entry)
  78. "Return a list of installed outputs for the package ENTRY."
  79. (--map (bui-entry-non-void-value it 'output)
  80. (bui-entry-non-void-value entry 'installed)))
  81. (defun guix-package-id-and-output-by-output-id (output-id)
  82. "Return a list (PACKAGE-ID OUTPUT) by OUTPUT-ID."
  83. (cl-multiple-value-bind (package-id-str output)
  84. (split-string output-id ":")
  85. (let ((package-id (string-to-number package-id-str)))
  86. (list (if (= 0 package-id) package-id-str package-id)
  87. output))))
  88. (defun guix-package-build-log-file (id)
  89. "Return build log file name of a package defined by ID."
  90. (guix-eval-read
  91. (guix-make-guile-expression 'package-build-log-file id)))
  92. (declare-function guix-build-log-find-file "guix-build-log" (file))
  93. (defun guix-package-find-build-log (id)
  94. "Show build log of a package defined by ID."
  95. (require 'guix-build-log)
  96. (let ((file (guix-package-build-log-file id)))
  97. (if file
  98. (guix-build-log-find-file file)
  99. (message "Couldn't find the package build log."))))
  100. ;;; Processing package actions
  101. (defvar guix-package-name-width 40
  102. "Width of a package name \"column\".
  103. This variable is used in a buffer to confirm operation.")
  104. (defun guix-process-package-actions (profile actions
  105. &optional operation-buffer)
  106. "Process package ACTIONS on PROFILE.
  107. Each action is a list of the form:
  108. (ACTION-TYPE PACKAGE-SPEC ...)
  109. ACTION-TYPE is one of the following symbols: `install',
  110. `upgrade', `remove'/`delete'.
  111. PACKAGE-SPEC should have the following form: (ID [OUTPUT] ...)."
  112. (let (install upgrade remove)
  113. (mapc (lambda (action)
  114. (let ((action-type (car action))
  115. (specs (cdr action)))
  116. (cl-case action-type
  117. (install (setq install (append install specs)))
  118. (upgrade (setq upgrade (append upgrade specs)))
  119. ((remove delete) (setq remove (append remove specs))))))
  120. actions)
  121. (when (guix-continue-package-operation-p
  122. profile
  123. :install install :upgrade upgrade :remove remove)
  124. (guix-eval-in-repl
  125. (guix-make-guile-expression
  126. 'process-package-actions profile
  127. :install install :upgrade upgrade :remove remove
  128. :use-substitutes? (or guix-use-substitutes 'f)
  129. :dry-run? (or guix-dry-run 'f))
  130. (and (not guix-dry-run) operation-buffer)))))
  131. (cl-defun guix-continue-package-operation-p (profile
  132. &key install upgrade remove)
  133. "Return non-nil if a package operation should be continued.
  134. Ask a user if needed (see `guix-operation-confirm').
  135. INSTALL, UPGRADE, REMOVE are 'package action specifications'.
  136. See `guix-process-package-actions' for details."
  137. (or (null guix-operation-confirm)
  138. (let* ((entries (guix-ui-get-entries
  139. profile 'package 'id
  140. (append (mapcar #'car install)
  141. (mapcar #'car upgrade)
  142. (mapcar #'car remove))
  143. '(id name version location)))
  144. (install-strings (guix-get-package-strings install entries))
  145. (upgrade-strings (guix-get-package-strings upgrade entries))
  146. (remove-strings (guix-get-package-strings remove entries)))
  147. (if (or install-strings upgrade-strings remove-strings)
  148. (let ((buf (get-buffer-create guix-temp-buffer-name)))
  149. (with-current-buffer buf
  150. (setq-local cursor-type nil)
  151. (setq buffer-read-only nil)
  152. (erase-buffer)
  153. (insert (propertize "Profile" 'face 'bold)
  154. ": " profile "\n\n")
  155. (guix-insert-package-strings install-strings "install")
  156. (guix-insert-package-strings upgrade-strings "upgrade")
  157. (guix-insert-package-strings remove-strings "remove")
  158. (let ((win (temp-buffer-window-show
  159. buf
  160. '((display-buffer-reuse-window
  161. display-buffer-at-bottom)
  162. (window-height . fit-window-to-buffer)))))
  163. (prog1 (guix-operation-prompt)
  164. (quit-window nil win)))))
  165. (message "Nothing to be done.
  166. If Guix REPL was restarted, the data is not up-to-date.")
  167. nil))))
  168. (defun guix-get-package-strings (specs entries)
  169. "Return short package descriptions for performing package actions.
  170. See `guix-process-package-actions' for the meaning of SPECS.
  171. ENTRIES is a list of package entries to get info about packages."
  172. (-non-nil
  173. (-map (-lambda ((id . outputs))
  174. (--when-let (bui-entry-by-id entries id)
  175. (let ((location (bui-entry-non-void-value it 'location))
  176. (name (guix-package-entry->name-specification it)))
  177. (with-temp-buffer
  178. (insert name)
  179. (when outputs
  180. (insert ":" (guix-concat-strings outputs ",")))
  181. (when location
  182. (indent-to guix-package-name-width 2)
  183. (insert "(" location ")"))
  184. (buffer-string)))))
  185. specs)))
  186. (defun guix-insert-package-strings (strings action)
  187. "Insert information STRINGS at point for performing package ACTION."
  188. (when strings
  189. (insert "Package(s) to " (propertize action 'face 'bold) ":\n")
  190. (dolist (str strings)
  191. (insert " " str "\n"))
  192. (bui-newline)))
  193. ;;; Package 'info'
  194. (guix-ui-define-interface package info
  195. :mode-name "Package-Info"
  196. :buffer-name "*Guix Package Info*"
  197. :get-entries-function 'guix-package-info-get-entries
  198. :format '(guix-package-info-insert-heading
  199. nil
  200. (synopsis nil (simple guix-package-info-synopsis))
  201. nil
  202. (description nil (simple guix-package-info-description))
  203. nil
  204. (outputs simple guix-package-info-insert-outputs)
  205. guix-package-info-insert-misc
  206. (source simple guix-package-info-insert-source)
  207. (location simple guix-package-info-insert-location)
  208. (home-url format (format bui-url))
  209. (license format (format guix-package-license))
  210. (systems format guix-package-info-insert-systems)
  211. (inputs format (format guix-package-input))
  212. (native-inputs format (format guix-package-native-input))
  213. (propagated-inputs format
  214. (format guix-package-propagated-input)))
  215. :titles '((home-url . "Home page")
  216. (systems . "Supported systems"))
  217. :required '(id name version installed non-unique))
  218. (bui-define-interface guix-installed-output info
  219. :format '((file-name simple (indent bui-file))
  220. (dependencies simple (indent bui-file)))
  221. :titles '((file-name . "Store directory"))
  222. :reduced? t)
  223. (defface guix-package-info-heading
  224. '((t :inherit bui-info-heading))
  225. "Face for package name and version headings."
  226. :group 'guix-package-info-faces)
  227. (defface guix-package-info-name-button
  228. '((t :inherit button))
  229. "Face used for a full name that can be used to describe a package."
  230. :group 'guix-package-info-faces)
  231. ;; Currently, `guix-package-info-name' and `guix-package-info-version'
  232. ;; faces are not used, but they were in the past and may be used in
  233. ;; future, so they were not removed.
  234. (defface guix-package-info-name
  235. '((t :inherit font-lock-keyword-face))
  236. "Face used for a name of a package."
  237. :group 'guix-package-info-faces)
  238. (defface guix-package-info-version
  239. '((t :inherit font-lock-builtin-face))
  240. "Face used for a version of a package."
  241. :group 'guix-package-info-faces)
  242. (defface guix-package-info-synopsis
  243. '((((type tty pc) (class color)) :weight bold)
  244. (t :height 1.1 :weight bold :inherit variable-pitch))
  245. "Face used for a synopsis of a package."
  246. :group 'guix-package-info-faces)
  247. (defface guix-package-info-description
  248. '((t))
  249. "Face used for a description of a package."
  250. :group 'guix-package-info-faces)
  251. (defface guix-package-info-license
  252. '((t :inherit font-lock-string-face))
  253. "Face used for a license of a package."
  254. :group 'guix-package-info-faces)
  255. (defface guix-package-info-location
  256. '((t :inherit bui-file-name))
  257. "Face used for a location of a package."
  258. :group 'guix-package-info-faces)
  259. (defface guix-package-info-source
  260. '((t :inherit bui-url :underline nil))
  261. "Face used for a source URL of a package."
  262. :group 'guix-package-info-faces)
  263. (defface guix-package-info-installed-outputs
  264. '((default :weight bold)
  265. (((class color) (min-colors 88) (background light))
  266. :foreground "ForestGreen")
  267. (((class color) (min-colors 88) (background dark))
  268. :foreground "PaleGreen")
  269. (((class color) (min-colors 8))
  270. :foreground "green")
  271. (t :underline t))
  272. "Face used for installed outputs of a package."
  273. :group 'guix-package-info-faces)
  274. (defface guix-package-info-uninstalled-outputs
  275. '((t :weight bold))
  276. "Face used for uninstalled outputs of a package."
  277. :group 'guix-package-info-faces)
  278. (defface guix-package-info-obsolete
  279. '((t :inherit error))
  280. "Face used if a package is obsolete."
  281. :group 'guix-package-info-faces)
  282. (defcustom guix-package-info-auto-find-package t
  283. "If non-nil, open store directory after pressing \"Show\" package button.
  284. If nil, just display the store directory (or directories) without finding."
  285. :type 'boolean
  286. :group 'guix-package-info)
  287. (defcustom guix-package-info-auto-find-source nil
  288. "If non-nil, open source file after pressing \"Show\" source button.
  289. If nil, just display the source file name without finding."
  290. :type 'boolean
  291. :group 'guix-package-info)
  292. (defcustom guix-package-info-auto-download-source t
  293. "If nil, do not automatically download a source file if it doesn't exist.
  294. After pressing a \"Show\" button, a derivation of the package
  295. source is calculated and a store file name is displayed. If this
  296. variable is non-nil and the source file does not exist in the
  297. store, it will be automatically downloaded (with a possible
  298. prompt depending on `guix-operation-confirm' variable)."
  299. :type 'boolean
  300. :group 'guix-package-info)
  301. (defcustom guix-package-info-button-functions
  302. '(guix-package-info-insert-build-button
  303. guix-package-info-insert-build-log-button)
  304. "List of functions used to insert package buttons in Info buffer.
  305. Each function is called with 2 arguments: package ID and full name."
  306. :type '(repeat function)
  307. :group 'guix-package-info)
  308. (defvar guix-package-info-download-buffer nil
  309. "Buffer from which a current download operation was performed.")
  310. (defvar guix-package-info-output-format "%-10s"
  311. "String used to format output names of the packages.
  312. It should be a '%s'-sequence. After inserting an output name
  313. formatted with this string, an action button is inserted.")
  314. (defvar guix-package-info-obsolete-string "(This package is obsolete)"
  315. "String used if a package is obsolete.")
  316. (define-button-type 'guix-package-location
  317. :supertype 'bui
  318. 'face 'guix-package-info-location
  319. 'help-echo "Find location of this package"
  320. 'action (lambda (btn)
  321. (guix-find-location (button-label btn))))
  322. (define-button-type 'guix-package-license
  323. :supertype 'bui
  324. 'face 'guix-package-info-license
  325. 'help-echo "Display license info"
  326. 'action (lambda (btn)
  327. (require 'guix-ui-license)
  328. (bui-get-display-entries
  329. 'guix-license 'info
  330. (list 'name (button-label btn))
  331. 'add)))
  332. (define-button-type 'guix-package-name
  333. :supertype 'bui
  334. 'face 'guix-package-info-name-button
  335. 'help-echo "Describe this package"
  336. 'action (lambda (btn)
  337. (bui-get-display-entries-current
  338. 'guix-package 'info
  339. (list (guix-ui-current-profile)
  340. 'name (or (button-get btn 'spec)
  341. (button-label btn)))
  342. 'add)))
  343. (define-button-type 'guix-package-heading
  344. :supertype 'guix-package-name
  345. 'face 'guix-package-info-heading)
  346. (define-button-type 'guix-package-source
  347. :supertype 'bui
  348. 'face 'guix-package-info-source
  349. 'help-echo ""
  350. 'action (lambda (_)
  351. ;; As a source may not be a real URL (e.g., "mirror://..."),
  352. ;; no action is bound to a source button.
  353. (message "Yes, this is the source URL. What did you expect?")))
  354. (defun guix-package-info-get-entries (profile search-type
  355. &rest search-values)
  356. "Return 'package' entries for displaying them in 'info' buffer."
  357. (guix-eval-read
  358. (guix-make-guile-expression
  359. 'package/output-sexps
  360. profile 'package search-type search-values
  361. (cl-union guix-package-info-required-params
  362. (bui-info-displayed-params 'guix-package)))))
  363. (defun guix-package-info-insert-heading (entry)
  364. "Insert package ENTRY heading (name and version) at point."
  365. (bui-insert-button
  366. (concat (bui-entry-non-void-value entry 'name) " "
  367. (bui-entry-non-void-value entry 'version))
  368. 'guix-package-heading
  369. 'spec (guix-package-entry->name-specification entry))
  370. (bui-newline))
  371. (defun guix-package-info-insert-location (location &optional _)
  372. "Insert package LOCATION at point."
  373. (bui-insert-non-nil location
  374. (let ((location-file (car (split-string location ":"))))
  375. (bui-info-insert-value-indent location 'guix-package-location)
  376. ;; Do not show "Packages" button if a package 'from file' is displayed.
  377. (unless (eq (guix-ui-current-search-type) 'from-file)
  378. (bui-insert-indent)
  379. (bui-insert-action-button
  380. "Packages"
  381. (lambda (btn)
  382. (guix-package-get-display (guix-ui-current-profile)
  383. 'location
  384. (button-get btn 'location)))
  385. (format "Display packages from location '%s'" location-file)
  386. 'location location-file)))))
  387. (defun guix-package-info-insert-systems (systems entry)
  388. "Insert supported package SYSTEMS at point."
  389. (bui-info-insert-value-format
  390. systems 'guix-hydra-build-system
  391. 'action (lambda (btn)
  392. (let ((args (guix-hydra-build-latest-prompt-args
  393. :job (button-get btn 'job-name)
  394. :system (button-label btn))))
  395. (apply #'guix-hydra-build-get-display
  396. 'latest args)))
  397. 'job-name (guix-hydra-job-name-specification
  398. (bui-entry-non-void-value entry 'name)
  399. (bui-entry-non-void-value entry 'version))))
  400. (defmacro guix-package-info-define-insert-inputs (&optional type)
  401. "Define a face and a function for inserting package inputs.
  402. TYPE is a type of inputs.
  403. Function name is `guix-package-info-insert-TYPE-inputs'.
  404. Face name is `guix-package-info-TYPE-inputs'."
  405. (let* ((type-str (symbol-name type))
  406. (type-name (and type (concat type-str "-")))
  407. (type-desc (and type (concat type-str " ")))
  408. (face (intern (concat "guix-package-info-" type-name "inputs")))
  409. (btn (intern (concat "guix-package-" type-name "input"))))
  410. `(progn
  411. (defface ,face
  412. '((t :inherit guix-package-info-name-button))
  413. ,(concat "Face used for " type-desc "inputs of a package.")
  414. :group 'guix-package-info-faces)
  415. (define-button-type ',btn
  416. :supertype 'guix-package-name
  417. 'face ',face))))
  418. (guix-package-info-define-insert-inputs)
  419. (guix-package-info-define-insert-inputs native)
  420. (guix-package-info-define-insert-inputs propagated)
  421. (defun guix-package-info-insert-outputs (outputs entry)
  422. "Insert OUTPUTS from package ENTRY at point."
  423. (and (bui-entry-non-void-value entry 'obsolete)
  424. (guix-package-info-insert-obsolete-text))
  425. (and (bui-entry-non-void-value entry 'non-unique)
  426. (bui-entry-non-void-value entry 'installed)
  427. (guix-package-info-insert-non-unique-text
  428. (guix-package-entry->name-specification entry)))
  429. (bui-newline)
  430. (dolist (output outputs)
  431. (guix-package-info-insert-output output entry)))
  432. (defun guix-package-info-insert-obsolete-text ()
  433. "Insert a message about obsolete package at point."
  434. (bui-insert-indent)
  435. (bui-format-insert guix-package-info-obsolete-string
  436. 'guix-package-info-obsolete))
  437. (defun guix-package-info-insert-non-unique-text (full-name)
  438. "Insert a message about non-unique package with FULL-NAME at point."
  439. (bui-newline)
  440. (bui-insert-indent)
  441. (insert "Installed outputs are displayed for a non-unique ")
  442. (bui-insert-button full-name 'guix-package-name)
  443. (insert " package."))
  444. (defun guix-package-info-insert-output (output entry)
  445. "Insert OUTPUT at point.
  446. Make some fancy text with buttons and additional stuff if the
  447. current OUTPUT is installed (if there is such output in
  448. `installed' parameter of a package ENTRY)."
  449. (let* ((installed (bui-entry-non-void-value entry 'installed))
  450. (obsolete (bui-entry-non-void-value entry 'obsolete))
  451. (installed-entry (--find
  452. (string= (bui-entry-non-void-value it 'output)
  453. output)
  454. installed))
  455. (action-type (if installed-entry 'delete 'install))
  456. (profile (guix-ui-current-profile)))
  457. (bui-insert-indent)
  458. (bui-format-insert output
  459. (if installed-entry
  460. 'guix-package-info-installed-outputs
  461. 'guix-package-info-uninstalled-outputs)
  462. guix-package-info-output-format)
  463. ;; Do not allow a user to install/delete anything to/from a system
  464. ;; profile, so add action buttons only for non-system profiles.
  465. (when (and profile
  466. (not (guix-system-profile? profile)))
  467. (guix-package-info-insert-action-button action-type entry output)
  468. (when obsolete
  469. (bui-insert-indent)
  470. (guix-package-info-insert-action-button 'upgrade entry output)))
  471. (bui-newline)
  472. (when installed-entry
  473. (bui-info-insert-entry installed-entry 'guix-installed-output 2))))
  474. (defun guix-package-info-insert-action-button (type entry output)
  475. "Insert button to process an action on a package OUTPUT at point.
  476. TYPE is one of the following symbols: `install', `delete', `upgrade'.
  477. ENTRY is an alist with package info."
  478. (let ((type-str (capitalize (symbol-name type)))
  479. (full-name (guix-package-entry->name-specification entry output)))
  480. (bui-insert-action-button
  481. type-str
  482. (lambda (btn)
  483. (guix-process-package-actions
  484. (guix-ui-current-profile)
  485. `((,(button-get btn 'action-type) (,(button-get btn 'id)
  486. ,(button-get btn 'output))))
  487. (current-buffer)))
  488. (concat type-str " '" full-name "'")
  489. 'action-type type
  490. 'id (or (bui-entry-non-void-value entry 'package-id)
  491. (bui-entry-id entry))
  492. 'output output)))
  493. (defun guix-package-info-show-store-path (entry-id package-id)
  494. "Show store directories of the package outputs in the current buffer.
  495. ENTRY-ID is an ID of the current entry (package or output).
  496. PACKAGE-ID is an ID of the package which store path to show."
  497. (let* ((entries (bui-current-entries))
  498. (entry (bui-entry-by-id entries entry-id))
  499. (dirs (guix-package-store-path package-id)))
  500. (or dirs
  501. (error "Couldn't define store directory of the package"))
  502. (let* ((new-entry (cons (cons 'store-path dirs)
  503. entry))
  504. (new-entries (bui-replace-entry entries entry-id new-entry)))
  505. (setf (bui-item-entries bui-item)
  506. new-entries)
  507. (bui-redisplay-goto-button)
  508. (let ((dir (car dirs)))
  509. (if (file-exists-p dir)
  510. (if guix-package-info-auto-find-package
  511. (find-file dir)
  512. (message nil))
  513. (message "'%s' does not exist.\nTry to build this package."
  514. dir))))))
  515. (defun guix-package-info-insert-misc (entry)
  516. "Insert various buttons and other info for package ENTRY at point."
  517. (unless (bui-entry-non-void-value entry 'obsolete)
  518. (let* ((entry-id (bui-entry-id entry))
  519. (package-id (or (bui-entry-non-void-value entry 'package-id)
  520. entry-id))
  521. (full-name (guix-package-entry->name-specification entry))
  522. (store-path (bui-entry-non-void-value entry 'store-path)))
  523. (bui-info-insert-title-simple "Package")
  524. (if store-path
  525. (bui-info-insert-value-indent store-path 'bui-file)
  526. (bui-insert-action-button
  527. "Show"
  528. (lambda (btn)
  529. (guix-package-info-show-store-path
  530. (button-get btn 'entry-id)
  531. (button-get btn 'package-id)))
  532. "Show the store directory of the current package"
  533. 'entry-id entry-id
  534. 'package-id package-id))
  535. (when guix-package-info-button-functions
  536. (bui-newline)
  537. (bui-mapinsert (lambda (fun)
  538. (funcall fun package-id full-name))
  539. guix-package-info-button-functions
  540. (bui-get-indent)
  541. :indent bui-indent
  542. :column (bui-fill-column)))
  543. (bui-newline))))
  544. (defun guix-package-info-insert-build-button (id full-name)
  545. "Insert button to build a package defined by ID."
  546. (bui-insert-action-button
  547. "Build"
  548. (lambda (btn)
  549. (guix-build-package (button-get btn 'id)
  550. (format "Build '%s' package?" full-name)))
  551. (format "Build the current package")
  552. 'id id))
  553. (defun guix-package-info-insert-build-log-button (id _name)
  554. "Insert button to show build log of a package defined by ID."
  555. (bui-insert-action-button
  556. "Build Log"
  557. (lambda (btn)
  558. (guix-package-find-build-log (button-get btn 'id)))
  559. "View build log of the current package"
  560. 'id id))
  561. (defun guix-package-info-show-source (entry-id package-id)
  562. "Show file name of a package source in the current info buffer.
  563. Find the file if needed (see `guix-package-info-auto-find-source').
  564. ENTRY-ID is an ID of the current entry (package or output).
  565. PACKAGE-ID is an ID of the package which source to show."
  566. (let* ((entries (bui-current-entries))
  567. (entry (bui-entry-by-id entries entry-id))
  568. (file (guix-package-source-file-name package-id)))
  569. (or file
  570. (error "Couldn't define file name of the package source"))
  571. (let* ((new-entry (cons (cons 'source-file file)
  572. entry))
  573. (new-entries (bui-replace-entry entries entry-id new-entry)))
  574. (setf (bui-item-entries bui-item)
  575. new-entries)
  576. (bui-redisplay-goto-button)
  577. (if (file-exists-p file)
  578. (if guix-package-info-auto-find-source
  579. (guix-find-file file)
  580. (message "The file name of the package source is displayed."))
  581. (if guix-package-info-auto-download-source
  582. (guix-package-info-download-source package-id)
  583. (message "The source does not exist in the store."))))))
  584. (defun guix-package-info-download-source (package-id)
  585. "Download a source of the package PACKAGE-ID."
  586. (setq guix-package-info-download-buffer (current-buffer))
  587. (guix-package-source-build-derivation
  588. package-id
  589. "The source does not exist in the store. Download it?"))
  590. (defun guix-package-info-insert-source (source entry)
  591. "Insert SOURCE from package ENTRY at point.
  592. SOURCE is a list of URLs."
  593. (bui-insert-non-nil source
  594. (let* ((source-file (bui-entry-non-void-value entry 'source-file))
  595. (entry-id (bui-entry-id entry))
  596. (package-id (or (bui-entry-non-void-value entry 'package-id)
  597. entry-id)))
  598. (if (null source-file)
  599. (bui-insert-action-button
  600. "Show"
  601. (lambda (btn)
  602. (guix-package-info-show-source (button-get btn 'entry-id)
  603. (button-get btn 'package-id)))
  604. "Show the source store directory of the current package"
  605. 'entry-id entry-id
  606. 'package-id package-id)
  607. (unless (file-exists-p source-file)
  608. (bui-insert-action-button
  609. "Download"
  610. (lambda (btn)
  611. (guix-package-info-download-source
  612. (button-get btn 'package-id)))
  613. "Download the source into the store"
  614. 'package-id package-id))
  615. (bui-info-insert-value-indent source-file 'bui-file))
  616. (bui-info-insert-value-indent source 'guix-package-source))))
  617. (defun guix-package-info-redisplay-after-download ()
  618. "Redisplay an 'info' buffer after downloading the package source.
  619. This function is used to hide a \"Download\" button if needed."
  620. (when (buffer-live-p guix-package-info-download-buffer)
  621. (with-current-buffer guix-package-info-download-buffer
  622. (bui-redisplay-goto-button))
  623. (setq guix-package-info-download-buffer nil)))
  624. (add-hook 'guix-after-source-download-hook
  625. 'guix-package-info-redisplay-after-download)
  626. ;;; Package 'list'
  627. (guix-ui-define-interface package list
  628. :mode-name "Package-List"
  629. :buffer-name "*Guix Packages*"
  630. :get-entries-function 'guix-package-list-get-entries
  631. :describe-function 'guix-ui-list-describe
  632. :format '((name guix-package-list-get-name 20 t)
  633. (version nil 10 nil)
  634. (outputs nil 13 t)
  635. (installed guix-package-list-get-installed-outputs 13 t)
  636. (synopsis bui-list-get-one-line 30 nil))
  637. :sort-key '(name)
  638. :marks '((install . ?I)
  639. (upgrade . ?U)
  640. (delete . ?D)))
  641. (let ((map guix-package-list-mode-map))
  642. (define-key map (kbd "B") 'guix-package-list-latest-builds)
  643. (define-key map (kbd "e") 'guix-package-list-edit)
  644. (define-key map (kbd "x") 'guix-package-list-execute)
  645. (define-key map (kbd "i") 'guix-package-list-mark-install)
  646. (define-key map (kbd "d") 'guix-package-list-mark-delete)
  647. (define-key map (kbd "U") 'guix-package-list-mark-upgrade)
  648. (define-key map (kbd "^") 'guix-package-list-mark-upgrades))
  649. (defface guix-package-list-installed
  650. '((t :inherit guix-package-info-installed-outputs))
  651. "Face used if there are installed outputs for the current package."
  652. :group 'guix-package-list-faces)
  653. (defface guix-package-list-obsolete
  654. '((t :inherit guix-package-info-obsolete))
  655. "Face used if a package is obsolete."
  656. :group 'guix-package-list-faces)
  657. (defcustom guix-package-list-generation-marking-enabled nil
  658. "If non-nil, allow putting marks in a list with 'generation packages'.
  659. By default this is disabled, because it may be confusing. For
  660. example, a package is installed in some generation, so a user can
  661. mark it for deletion in the list of packages from this
  662. generation, but the package may not be installed in the latest
  663. generation, so actually it cannot be deleted.
  664. If you managed to understand the explanation above or if you
  665. really know what you do or if you just don't care, you can set
  666. this variable to t. It should not do much harm anyway (most
  667. likely)."
  668. :type 'boolean
  669. :group 'guix-package-list)
  670. (defun guix-package-list-get-entries (profile search-type
  671. &rest search-values)
  672. "Return 'package' entries for displaying them in 'list' buffer."
  673. (guix-eval-read
  674. (guix-make-guile-expression
  675. 'package/output-sexps
  676. profile 'package search-type search-values
  677. (cl-union guix-package-list-required-params
  678. (bui-list-displayed-params 'guix-package)))))
  679. (defun guix-package-list-get-name (name entry)
  680. "Return NAME of the package ENTRY.
  681. Colorize it with `guix-package-list-installed' or
  682. `guix-package-list-obsolete' if needed."
  683. (bui-get-string
  684. name
  685. (cond ((bui-entry-non-void-value entry 'obsolete)
  686. 'guix-package-list-obsolete)
  687. ((bui-entry-non-void-value entry 'installed)
  688. 'guix-package-list-installed))))
  689. (defun guix-package-list-get-installed-outputs (installed &optional _)
  690. "Return string with outputs from INSTALLED entries."
  691. (bui-get-string
  692. (--map (bui-entry-non-void-value it 'output)
  693. installed)))
  694. (defun guix-package-list-marking-check ()
  695. "Signal an error if marking is disabled for the current buffer."
  696. (when (and (not guix-package-list-generation-marking-enabled)
  697. (or (derived-mode-p 'guix-package-list-mode)
  698. (derived-mode-p 'guix-output-list-mode))
  699. (eq (guix-ui-current-search-type) 'generation))
  700. (error "Action marks are disabled for lists of 'generation packages'")))
  701. (defun guix-package-list-mark-outputs (mark default
  702. &optional prompt available)
  703. "Mark the current package with MARK and move to the next line.
  704. If PROMPT is non-nil, use it to ask a user for outputs from
  705. AVAILABLE list, otherwise mark all DEFAULT outputs."
  706. (let ((outputs (if prompt
  707. (guix-completing-read-multiple
  708. prompt available nil t)
  709. default)))
  710. (apply #'bui-list--mark mark t outputs)))
  711. (defun guix-package-list-mark-install (&optional arg)
  712. "Mark the current package for installation and move to the next line.
  713. With ARG, prompt for the outputs to install (several outputs may
  714. be separated with \",\")."
  715. (interactive "P")
  716. (guix-package-list-marking-check)
  717. (let* ((entry (bui-list-current-entry))
  718. (all (bui-entry-non-void-value entry 'outputs))
  719. (installed (guix-package-installed-outputs entry))
  720. (available (cl-set-difference all installed :test #'string=)))
  721. (or available
  722. (user-error "This package is already installed"))
  723. (guix-package-list-mark-outputs
  724. 'install '("out")
  725. (and arg "Output(s) to install: ")
  726. available)))
  727. (defun guix-package-list-mark-delete (&optional arg)
  728. "Mark the current package for deletion and move to the next line.
  729. With ARG, prompt for the outputs to delete (several outputs may
  730. be separated with \",\")."
  731. (interactive "P")
  732. (guix-package-list-marking-check)
  733. (let* ((entry (bui-list-current-entry))
  734. (installed (guix-package-installed-outputs entry)))
  735. (or installed
  736. (user-error "This package is not installed"))
  737. (guix-package-list-mark-outputs
  738. 'delete installed
  739. (and arg "Output(s) to delete: ")
  740. installed)))
  741. (defun guix-package-list-mark-upgrade (&optional arg)
  742. "Mark the current package for upgrading and move to the next line.
  743. With ARG, prompt for the outputs to upgrade (several outputs may
  744. be separated with \",\")."
  745. (interactive "P")
  746. (guix-package-list-marking-check)
  747. (let* ((entry (bui-list-current-entry))
  748. (installed (guix-package-installed-outputs entry)))
  749. (or installed
  750. (user-error "This package is not installed"))
  751. (when (or (bui-entry-non-void-value entry 'obsolete)
  752. (y-or-n-p "This package is not obsolete. Try to upgrade it anyway? "))
  753. (guix-package-list-mark-outputs
  754. 'upgrade installed
  755. (and arg "Output(s) to upgrade: ")
  756. installed))))
  757. (defun guix-package-mark-upgrades (fun &optional all)
  758. "Mark all obsolete packages for upgrading.
  759. Use FUN to perform marking of the current line. FUN should
  760. take an entry as argument.
  761. If ALL is non-nil, mark all installed (not only obsolete) packages."
  762. (guix-package-list-marking-check)
  763. (let ((entries (--filter (bui-entry-non-void-value
  764. it (if all 'installed 'obsolete))
  765. (bui-current-entries))))
  766. (bui-list-for-each-line
  767. (lambda ()
  768. (let* ((id (bui-list-current-id))
  769. (entry (--find (equal id (bui-entry-id it))
  770. entries)))
  771. (when entry
  772. (funcall fun entry)))))))
  773. (defun guix-package-list-mark-upgrades (&optional arg)
  774. "Mark all obsolete packages for upgrading.
  775. With ARG, mark all installed (including non-obsolete) packages."
  776. (interactive "P")
  777. (guix-package-mark-upgrades
  778. (lambda (entry)
  779. (apply #'bui-list--mark
  780. 'upgrade nil
  781. (guix-package-installed-outputs entry)))
  782. arg))
  783. (defun guix-package-assert-non-system-profile ()
  784. "Verify that the current profile is not a system one.
  785. The current profile is the one used by the current buffer."
  786. (--when-let (guix-ui-current-profile)
  787. (guix-assert-non-system-profile it)))
  788. (defun guix-package-execute-actions (fun)
  789. "Perform actions on the marked packages.
  790. Use FUN to define actions suitable for `guix-process-package-actions'.
  791. FUN should take action-type as argument."
  792. (guix-package-assert-non-system-profile)
  793. (let ((actions (-non-nil (mapcar fun '(install delete upgrade)))))
  794. (if actions
  795. (guix-process-package-actions (guix-ui-current-profile)
  796. actions (current-buffer))
  797. (user-error "No operations specified"))))
  798. (defun guix-package-list-execute ()
  799. "Perform actions on the marked packages."
  800. (interactive)
  801. (guix-package-execute-actions #'guix-package-list-make-action))
  802. (defun guix-package-list-make-action (action-type)
  803. "Return action specification for the packages marked with ACTION-TYPE.
  804. Return nil, if there are no packages marked with ACTION-TYPE.
  805. The specification is suitable for `guix-process-package-actions'."
  806. (let ((specs (bui-list-get-marked-args action-type)))
  807. (and specs (cons action-type specs))))
  808. (defun guix-package-list-edit (&optional directory)
  809. "Go to the location of the current package.
  810. See `guix-find-location' for the meaning of DIRECTORY."
  811. (interactive (list (guix-read-directory)))
  812. (guix-edit (bui-list-current-id) directory))
  813. (defun guix-package-list-latest-builds (number &rest args)
  814. "Display latest NUMBER of Hydra builds of the current package.
  815. Interactively, prompt for NUMBER. With prefix argument, prompt
  816. for all ARGS."
  817. (interactive
  818. (let ((entry (bui-list-current-entry)))
  819. (guix-hydra-build-latest-prompt-args
  820. :job (guix-hydra-job-name-specification
  821. (bui-entry-non-void-value entry 'name)
  822. (bui-entry-non-void-value entry 'version)))))
  823. (apply #'guix-hydra-latest-builds number args))
  824. ;;; Output 'list'
  825. (guix-ui-define-interface output list
  826. :mode-name "Output-List"
  827. :buffer-name "*Guix Packages*"
  828. :get-entries-function 'guix-output-list-get-entries
  829. :describe-function 'guix-output-list-describe
  830. :format '((name guix-package-list-get-name 20 t)
  831. (version nil 10 nil)
  832. (output nil 9 t)
  833. (installed nil 12 t)
  834. (synopsis bui-list-get-one-line 30 nil))
  835. :required '(id package-id)
  836. :sort-key '(name)
  837. :marks '((install . ?I)
  838. (upgrade . ?U)
  839. (delete . ?D)))
  840. (let ((map guix-output-list-mode-map))
  841. (define-key map (kbd "B") 'guix-package-list-latest-builds)
  842. (define-key map (kbd "e") 'guix-output-list-edit)
  843. (define-key map (kbd "x") 'guix-output-list-execute)
  844. (define-key map (kbd "i") 'guix-output-list-mark-install)
  845. (define-key map (kbd "d") 'guix-output-list-mark-delete)
  846. (define-key map (kbd "U") 'guix-output-list-mark-upgrade)
  847. (define-key map (kbd "^") 'guix-output-list-mark-upgrades))
  848. (defun guix-output-list-get-entries (profile search-type
  849. &rest search-values)
  850. "Return 'output' entries for displaying them in 'list' buffer."
  851. (guix-eval-read
  852. (guix-make-guile-expression
  853. 'package/output-sexps
  854. profile 'output search-type search-values
  855. (cl-union guix-output-list-required-params
  856. (bui-list-displayed-params 'guix-output)))))
  857. (defun guix-output-list-mark-install ()
  858. "Mark the current output for installation and move to the next line."
  859. (interactive)
  860. (guix-package-list-marking-check)
  861. (let* ((entry (bui-list-current-entry))
  862. (installed (bui-entry-non-void-value entry 'installed)))
  863. (if installed
  864. (user-error "This output is already installed")
  865. (bui-list--mark 'install t))))
  866. (defun guix-output-list-mark-delete ()
  867. "Mark the current output for deletion and move to the next line."
  868. (interactive)
  869. (guix-package-list-marking-check)
  870. (let* ((entry (bui-list-current-entry))
  871. (installed (bui-entry-non-void-value entry 'installed)))
  872. (if installed
  873. (bui-list--mark 'delete t)
  874. (user-error "This output is not installed"))))
  875. (defun guix-output-list-mark-upgrade ()
  876. "Mark the current output for upgrading and move to the next line."
  877. (interactive)
  878. (guix-package-list-marking-check)
  879. (let* ((entry (bui-list-current-entry))
  880. (installed (bui-entry-non-void-value entry 'installed)))
  881. (or installed
  882. (user-error "This output is not installed"))
  883. (when (or (bui-entry-non-void-value entry 'obsolete)
  884. (y-or-n-p "This output is not obsolete. Try to upgrade it anyway? "))
  885. (bui-list--mark 'upgrade t))))
  886. (defun guix-output-list-mark-upgrades (&optional arg)
  887. "Mark all obsolete package outputs for upgrading.
  888. With ARG, mark all installed (including non-obsolete) packages."
  889. (interactive "P")
  890. (guix-package-mark-upgrades
  891. (lambda (_) (bui-list--mark 'upgrade))
  892. arg))
  893. (defun guix-output-list-execute ()
  894. "Perform actions on the marked outputs."
  895. (interactive)
  896. (guix-package-execute-actions #'guix-output-list-make-action))
  897. (defun guix-output-list-make-action (action-type)
  898. "Return action specification for the outputs marked with ACTION-TYPE.
  899. Return nil, if there are no outputs marked with ACTION-TYPE.
  900. The specification is suitable for `guix-process-output-actions'."
  901. (let ((ids (bui-list-get-marked-id-list action-type)))
  902. (and ids (cons action-type
  903. (mapcar #'guix-package-id-and-output-by-output-id
  904. ids)))))
  905. (defun guix-output-list-describe (&rest ids)
  906. "Describe outputs with IDS (list of output identifiers)."
  907. (let ((pids (--map (car (guix-package-id-and-output-by-output-id it))
  908. ids)))
  909. (bui-get-display-entries
  910. 'guix-package 'info
  911. (cl-list* (guix-ui-current-profile)
  912. 'id (cl-remove-duplicates pids))
  913. 'add)))
  914. (defun guix-output-list-edit (&optional directory)
  915. "Go to the location of the current package.
  916. See `guix-find-location' for the meaning of DIRECTORY."
  917. (interactive (list (guix-read-directory)))
  918. (guix-edit (bui-entry-non-void-value (bui-list-current-entry)
  919. 'package-id)
  920. directory))
  921. ;;; Interactive commands
  922. (defvar guix-package-search-params '(name synopsis description)
  923. "Default list of package parameters for searching by regexp.")
  924. (defvar guix-package-search-history nil
  925. "A history of minibuffer prompts.")
  926. ;;;###autoload
  927. (defun guix-packages-by-name (name &optional profile)
  928. "Display Guix packages with NAME.
  929. NAME is a string with name specification. It may optionally contain
  930. a version number. Examples: \"guile\", \"guile@2.0.11\".
  931. If PROFILE is nil, use `guix-current-profile'.
  932. Interactively with prefix, prompt for PROFILE."
  933. (interactive
  934. (list (guix-read-package-name)
  935. (guix-ui-read-package-profile)))
  936. (guix-package-get-display profile 'name name))
  937. ;;;###autoload
  938. (defun guix-packages-by-license (license &optional profile)
  939. "Display Guix packages with LICENSE.
  940. LICENSE is a license name string.
  941. If PROFILE is nil, use `guix-current-profile'.
  942. Interactively with prefix, prompt for PROFILE."
  943. (interactive
  944. (list (guix-read-license-name)
  945. (guix-ui-read-package-profile)))
  946. (guix-package-get-display profile 'license license))
  947. ;;;###autoload
  948. (defun guix-packages-by-location (location &optional profile)
  949. "Display Guix packages placed in LOCATION file.
  950. If PROFILE is nil, use `guix-current-profile'.
  951. Interactively with prefix, prompt for PROFILE."
  952. (interactive
  953. (list (guix-read-package-location)
  954. (guix-ui-read-package-profile)))
  955. (guix-package-get-display profile 'location location))
  956. ;;;###autoload
  957. (defun guix-package-from-file (file &optional profile)
  958. "Display Guix package that the code from FILE evaluates to.
  959. If PROFILE is nil, use `guix-current-profile'.
  960. Interactively with prefix, prompt for PROFILE."
  961. (interactive
  962. (list (read-file-name "File with package: ")
  963. (guix-ui-read-package-profile)))
  964. (bui-get-display-entries
  965. 'guix-package 'info
  966. (list (or profile guix-current-profile) 'from-file file)
  967. 'add))
  968. ;;;###autoload
  969. (defun guix-search-by-regexp (regexp &optional params profile)
  970. "Search for Guix packages by REGEXP.
  971. PARAMS are package parameters that should be searched.
  972. If PARAMS are not specified, use `guix-package-search-params'.
  973. If PROFILE is nil, use `guix-current-profile'.
  974. Interactively with prefix, prompt for PROFILE."
  975. (interactive
  976. (list (read-regexp "Regexp: " nil 'guix-package-search-history)
  977. nil (guix-ui-read-package-profile)))
  978. (guix-package-get-display profile 'regexp regexp
  979. (or params guix-package-search-params)))
  980. ;;;###autoload
  981. (defun guix-search-by-name (regexp &optional profile)
  982. "Search for Guix packages matching REGEXP in a package name.
  983. If PROFILE is nil, use `guix-current-profile'.
  984. Interactively with prefix, prompt for PROFILE."
  985. (interactive
  986. (list (read-string "Package name by regexp: "
  987. nil 'guix-package-search-history)
  988. (guix-ui-read-package-profile)))
  989. (guix-search-by-regexp regexp '(name) profile))
  990. ;;;###autoload
  991. (defun guix-installed-packages (&optional profile)
  992. "Display information about installed Guix packages.
  993. If PROFILE is nil, use `guix-current-profile'.
  994. Interactively with prefix, prompt for PROFILE."
  995. (interactive (list (guix-ui-read-package-profile)))
  996. (guix-package-get-display profile 'installed))
  997. ;;;###autoload
  998. (defun guix-installed-user-packages ()
  999. "Display information about Guix packages installed in a user profile."
  1000. (interactive)
  1001. (guix-installed-packages (guix-package-profile guix-user-profile)))
  1002. ;;;###autoload
  1003. (defun guix-installed-system-packages ()
  1004. "Display information about Guix packages installed in a system profile."
  1005. (interactive)
  1006. (guix-installed-packages (guix-package-profile guix-system-profile)))
  1007. ;;;###autoload
  1008. (defun guix-obsolete-packages (&optional profile)
  1009. "Display information about obsolete Guix packages.
  1010. If PROFILE is nil, use `guix-current-profile'.
  1011. Interactively with prefix, prompt for PROFILE."
  1012. (interactive (list (guix-ui-read-package-profile)))
  1013. (guix-package-get-display profile 'obsolete))
  1014. ;;;###autoload
  1015. (defun guix-all-available-packages (&optional profile)
  1016. "Display information about all available Guix packages.
  1017. If PROFILE is nil, use `guix-current-profile'.
  1018. Interactively with prefix, prompt for PROFILE."
  1019. (interactive (list (guix-ui-read-package-profile)))
  1020. (guix-package-get-display profile 'all-available))
  1021. ;;;###autoload
  1022. (defun guix-newest-available-packages (&optional profile)
  1023. "Display information about the newest available Guix packages.
  1024. If PROFILE is nil, use `guix-current-profile'.
  1025. Interactively with prefix, prompt for PROFILE."
  1026. (interactive (list (guix-ui-read-package-profile)))
  1027. (guix-package-get-display profile 'newest-available))
  1028. (provide 'guix-ui-package)
  1029. ;;; guix-ui-package.el ends here