guix-ui-package.el 67 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700
  1. ;;; guix-ui-package.el --- Interface for displaying packages -*- lexical-binding: t -*-
  2. ;; Copyright © 2014–2019 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-ui-store-item)
  26. (require 'guix-misc)
  27. (require 'guix-repl)
  28. (require 'guix-guile)
  29. (require 'guix-utils)
  30. (require 'guix-read)
  31. (require 'guix-license)
  32. (require 'guix-location)
  33. (require 'guix-package)
  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* (guix-package-profile
  59. (or profile guix-current-profile))
  60. search-type search-values))
  61. (entries (bui-get-entries (guix-package-list-type) 'list args)))
  62. (if (or guix-package-list-show-single
  63. (null entries)
  64. (cdr entries))
  65. (bui-display-entries entries (guix-package-list-type) 'list args)
  66. (bui-get-display-entries 'guix-package 'info args))))
  67. (defun guix-package-entry->name-specification (entry &optional output)
  68. "Return name specification of the package ENTRY and OUTPUT."
  69. (guix-package-name-specification
  70. (bui-entry-non-void-value entry 'name)
  71. (bui-entry-non-void-value entry 'version)
  72. (or output (bui-entry-non-void-value entry 'output))))
  73. (defun guix-package-entries->name-specifications (entries)
  74. "Return name specifications by the package or output ENTRIES."
  75. (cl-remove-duplicates (mapcar #'guix-package-entry->name-specification
  76. entries)
  77. :test #'string=))
  78. (defun guix-package-entry-installed-outputs (entry)
  79. "Return a list of installed outputs for the package ENTRY."
  80. (--map (bui-entry-non-void-value it 'output)
  81. (bui-entry-non-void-value entry 'installed)))
  82. (defun guix-read-package-name-from-entries (entries)
  83. "Prompt for a package name and return it.
  84. Names are completed from package ENTRIES."
  85. (completing-read "Package: "
  86. (--map (bui-entry-value it 'name) entries)))
  87. (defun guix-read-package-entry-by-name (&optional entries)
  88. "Return an entry from package ENTRIES (current entries by default).
  89. If there is only one entry, return it. If there are multiple
  90. entries, prompt for a package name and return an entry with this
  91. name."
  92. (or entries (setq entries (bui-current-entries)))
  93. ;; There is unavoidable (?) downside: when there are several packages
  94. ;; with the same name, they cannot be distinguished, so the first one
  95. ;; from ENTRIES will be returned.
  96. (pcase entries
  97. (`(,entry) entry)
  98. (_ (bui-entry-by-param entries 'name
  99. (guix-read-package-name-from-entries entries)))))
  100. (defun guix-read-package-output (outputs)
  101. "Return an output from package OUTPUTS.
  102. If there is only one output, return it. If there are multiple
  103. OUTPUTS, prompt for it."
  104. (or outputs
  105. (error "No package outputs!"))
  106. (if (cdr outputs)
  107. (completing-read "Output: " outputs nil t)
  108. (car outputs)))
  109. (defun guix-read-package-entry-and-output (&optional entries)
  110. "Return a list with package entry and output.
  111. See `guix-read-package-entry-by-name' and
  112. `guix-read-package-output' for details."
  113. (let* ((entry (guix-read-package-entry-by-name entries))
  114. (outputs (bui-entry-non-void-value entry 'outputs))
  115. (output (guix-read-package-output outputs)))
  116. (list entry output)))
  117. ;;; Processing package actions
  118. (defvar guix-package-name-width 40
  119. "Width of a package name \"column\".
  120. This variable is used in a buffer to confirm operation.")
  121. (defun guix-process-package-actions (profile actions
  122. &optional operation-buffer)
  123. "Process package ACTIONS on PROFILE.
  124. Each action is a list of the form:
  125. (ACTION-TYPE PACKAGE-SPEC ...)
  126. ACTION-TYPE is one of the following symbols: `install',
  127. `upgrade', `remove'/`delete'.
  128. PACKAGE-SPEC should have the following form: (ID [OUTPUT] ...)."
  129. (let (install upgrade remove)
  130. (mapc (lambda (action)
  131. (let ((action-type (car action))
  132. (specs (cdr action)))
  133. (cl-case action-type
  134. (install (setq install (append install specs)))
  135. (upgrade (setq upgrade (append upgrade specs)))
  136. ((remove delete) (setq remove (append remove specs))))))
  137. actions)
  138. (when (guix-continue-package-operation-p
  139. profile
  140. :install install :upgrade upgrade :remove remove)
  141. (guix-eval-in-repl
  142. (guix-make-guile-expression
  143. 'process-package-actions profile
  144. :install install :upgrade upgrade :remove remove
  145. :use-substitutes? (or guix-use-substitutes 'f)
  146. :dry-run? (or guix-dry-run 'f))
  147. (and (not guix-dry-run) operation-buffer)))))
  148. (cl-defun guix-continue-package-operation-p (profile
  149. &key install upgrade remove)
  150. "Return non-nil if a package operation should be continued.
  151. Ask a user if needed (see `guix-operation-confirm').
  152. INSTALL, UPGRADE, REMOVE are 'package action specifications'.
  153. See `guix-process-package-actions' for details."
  154. (or (null guix-operation-confirm)
  155. (let* ((entries (guix-ui-get-entries
  156. profile 'package 'id
  157. (append (mapcar #'car install)
  158. (mapcar #'car upgrade)
  159. (mapcar #'car remove))
  160. '(id name version location)))
  161. (install-strings (guix-get-package-strings install entries))
  162. (upgrade-strings (guix-get-package-strings upgrade entries))
  163. (remove-strings (guix-get-package-strings remove entries)))
  164. (if (or install-strings upgrade-strings remove-strings)
  165. (let ((buf (get-buffer-create guix-temp-buffer-name)))
  166. (with-current-buffer buf
  167. (setq-local cursor-type nil)
  168. (setq buffer-read-only nil)
  169. (erase-buffer)
  170. (insert (propertize "Profile" 'face 'bold)
  171. ": " profile "\n\n")
  172. (guix-insert-package-strings install-strings "install")
  173. (guix-insert-package-strings upgrade-strings "upgrade")
  174. (guix-insert-package-strings remove-strings "remove")
  175. (let ((win (temp-buffer-window-show
  176. buf
  177. '((display-buffer-reuse-window
  178. display-buffer-at-bottom)
  179. (window-height . fit-window-to-buffer)))))
  180. (prog1 (guix-operation-prompt)
  181. (quit-window nil win)))))
  182. (message "Nothing to be done.
  183. If Guix REPL was restarted, the data is not up-to-date.")
  184. nil))))
  185. (defun guix-get-package-strings (specs entries)
  186. "Return short package descriptions for performing package actions.
  187. See `guix-process-package-actions' for the meaning of SPECS.
  188. ENTRIES is a list of package entries to get info about packages."
  189. (-non-nil
  190. (-map (-lambda ((id . outputs))
  191. (--when-let (bui-entry-by-id entries id)
  192. (let ((location (bui-entry-non-void-value it 'location))
  193. (name (guix-package-entry->name-specification it)))
  194. (with-temp-buffer
  195. (insert name)
  196. (when outputs
  197. (insert ":" (guix-concat-strings outputs ",")))
  198. (when location
  199. (indent-to guix-package-name-width 2)
  200. (insert "(" location ")"))
  201. (buffer-string)))))
  202. specs)))
  203. (defun guix-insert-package-strings (strings action)
  204. "Insert information STRINGS at point for performing package ACTION."
  205. (when strings
  206. (insert "Package(s) to " (propertize action 'face 'bold) ":\n")
  207. (dolist (str strings)
  208. (insert " " str "\n"))
  209. (bui-newline)))
  210. ;;; Package 'info'
  211. (guix-ui-define-interface package info
  212. :mode-name "Package-Info"
  213. :buffer-name "*Guix Package Info*"
  214. :get-entries-function 'guix-package-info-get-entries
  215. :format '(guix-package-info-insert-heading
  216. nil
  217. guix-package-info-insert-additional-text
  218. (synopsis nil (simple guix-package-info-synopsis))
  219. nil
  220. (description nil (simple guix-package-info-description))
  221. nil
  222. (outputs simple guix-package-info-insert-outputs)
  223. guix-package-info-insert-misc
  224. (source simple guix-package-info-insert-source)
  225. (location simple guix-package-info-insert-location)
  226. (upstream-name format (format))
  227. (home-url format (format bui-url))
  228. (license format (format guix-package-license))
  229. (systems format guix-package-info-insert-systems)
  230. (inputs format (guix-package-info-insert-name-buttons
  231. guix-package-input))
  232. (native-inputs format (guix-package-info-insert-name-buttons
  233. guix-package-native-input))
  234. (propagated-inputs format (guix-package-info-insert-name-buttons
  235. guix-package-propagated-input)))
  236. :hint 'guix-package-info-hint
  237. :titles '((home-url . "Home page")
  238. (systems . "Supported systems"))
  239. :required '(id name version installed non-unique known-status
  240. superseded hidden))
  241. ;; Additional info for installed outputs.
  242. (bui-define-interface guix-installed-output info
  243. :format '((file-name simple (guix-info-insert-store-items))
  244. (dependencies simple (guix-info-insert-store-items)))
  245. :titles '((file-name . "Store directory"))
  246. :reduced? t)
  247. ;; Additional info for "guix pull"-ed 'guix' package.
  248. (bui-define-interface guix-pulled-package info
  249. :format '((url format (format bui-url))
  250. (branch format (format))
  251. (commit format (format)))
  252. :reduced? t)
  253. (let ((map guix-package-info-mode-map))
  254. (define-key map (kbd "i") 'guix-package-info-install)
  255. (define-key map (kbd "d") 'guix-package-info-delete)
  256. (define-key map (kbd "U") 'guix-package-info-upgrade)
  257. (define-key map (kbd "u") 'guix-package-info-upgrade)
  258. (define-key map (kbd "e") 'guix-package-info-edit)
  259. (define-key map (kbd "G") 'guix-package-info-graph)
  260. (define-key map (kbd "z") 'guix-package-info-size)
  261. (define-key map (kbd "L") 'guix-package-info-lint))
  262. (defvar guix-package-info-default-hint
  263. '(("\\[guix-package-info-edit]") " edit (go to) the package definition;\n"
  264. ("\\[guix-package-info-graph]") " view package graph; "
  265. ("\\[guix-package-info-size]") " view package size; "
  266. ("\\[guix-package-info-lint]") " lint;\n"
  267. ("\\[guix-package-info-install]") " install; "
  268. ("\\[guix-package-info-delete]") " delete; "
  269. ("\\[guix-package-info-upgrade]") " upgrade;\n"))
  270. (defun guix-package-info-hint ()
  271. (bui-format-hints
  272. guix-package-info-default-hint
  273. guix-ui-hint
  274. (bui-default-hint)))
  275. (defface guix-package-info-heading
  276. '((t :inherit bui-info-heading))
  277. "Face for package name and version headings."
  278. :group 'guix-package-info-faces)
  279. (defface guix-package-info-name-button
  280. '((t :inherit button))
  281. "Face used for a full name that can be used to describe a package."
  282. :group 'guix-package-info-faces)
  283. ;; Currently, `guix-package-info-name' and `guix-package-info-version'
  284. ;; faces are not used, but they were in the past and may be used in
  285. ;; future, so they were not removed.
  286. (defface guix-package-info-name
  287. '((t :inherit font-lock-keyword-face))
  288. "Face used for a name of a package."
  289. :group 'guix-package-info-faces)
  290. (defface guix-package-info-version
  291. '((t :inherit font-lock-builtin-face))
  292. "Face used for a version of a package."
  293. :group 'guix-package-info-faces)
  294. (defface guix-package-info-synopsis
  295. '((((type tty pc) (class color)) :weight bold)
  296. (t :height 1.1 :weight bold :inherit variable-pitch))
  297. "Face used for a synopsis of a package."
  298. :group 'guix-package-info-faces)
  299. (defface guix-package-info-description
  300. '((t :inherit font-lock-doc-face))
  301. "Face used for a description of a package."
  302. :group 'guix-package-info-faces)
  303. (defface guix-package-info-license
  304. '((t :inherit font-lock-string-face))
  305. "Face used for a license of a package."
  306. :group 'guix-package-info-faces)
  307. (defface guix-package-info-source
  308. '((t :inherit bui-url :underline nil))
  309. "Face used for a source URL of a package."
  310. :group 'guix-package-info-faces)
  311. (defface guix-package-info-installed-outputs
  312. '((t :inherit guix-true))
  313. "Face used for installed outputs of a package."
  314. :group 'guix-package-info-faces)
  315. (defface guix-package-info-uninstalled-outputs
  316. '((t :inherit guix-false))
  317. "Face used for uninstalled outputs of a package."
  318. :group 'guix-package-info-faces)
  319. (defface guix-package-info-unknown
  320. '((t :inherit error))
  321. "Face used for unknown packages.
  322. 'Unknown' means there are no packages with this name among Guix
  323. packages. Perhaps you installed this package in the past, and it
  324. was renamed later."
  325. :group 'guix-package-info-faces)
  326. (defface guix-package-info-obsolete
  327. '((t :inherit font-lock-warning-face))
  328. "Face used for obsolete packages.
  329. 'Obsolete' means there is a Guix package with this name but with
  330. a newer version (probably it's time to update)."
  331. :group 'guix-package-info-faces)
  332. (defface guix-package-info-future
  333. '((default :inherit guix-package-info-installed-outputs)
  334. (((class color) (min-colors 88) (background light))
  335. :foreground "RoyalBlue3")
  336. (((class color) (min-colors 88) (background dark))
  337. :foreground "DeepSkyBlue")
  338. (((class color) (min-colors 8))
  339. :foreground "blue"))
  340. "Face used for packages from the future.
  341. 'From the future' means there is a Guix package with this name
  342. but with an older version, i.e. the installed package is newer
  343. than available from Guix! This is rather unusual, it may happen,
  344. for example, if you installed a package after 'guix pull' (see
  345. Info node `(guix) Invoking guix pull') and then you removed the
  346. pulled directory, so Guix searches for packages in its original
  347. directory with the old package recipes."
  348. :group 'guix-package-info-faces)
  349. (defface guix-package-info-superseded
  350. '((t :inherit shadow))
  351. "Face used for superseded packages."
  352. :group 'guix-package-info-faces)
  353. (defface guix-package-info-hidden
  354. '((t :inherit shadow))
  355. "Face used for hidden packages.
  356. Most likely you will never see these packages (because they are
  357. hidden and hard to find), so you may not bother customizing this
  358. face."
  359. :group 'guix-package-info-faces)
  360. (defcustom guix-package-info-auto-find-package t
  361. "If non-nil, open store directory after pressing \"Show\" package button.
  362. If nil, just display the store directory (or directories) without finding."
  363. :type 'boolean
  364. :group 'guix-package-info)
  365. (defcustom guix-package-info-auto-find-source nil
  366. "If non-nil, open source file after pressing \"Show\" source button.
  367. If nil, just display the source file name without finding."
  368. :type 'boolean
  369. :group 'guix-package-info)
  370. (defcustom guix-package-info-auto-download-source t
  371. "If nil, do not automatically download a source file if it doesn't exist.
  372. After pressing a \"Show\" button, a derivation of the package
  373. source is calculated and a store file name is displayed. If this
  374. variable is non-nil and the source file does not exist in the
  375. store, it will be automatically downloaded (with a possible
  376. prompt depending on `guix-operation-confirm' variable)."
  377. :type 'boolean
  378. :group 'guix-package-info)
  379. (defcustom guix-package-info-button-functions
  380. '(guix-package-info-insert-build-button
  381. guix-package-info-insert-build-log-button
  382. guix-package-info-insert-graph-button
  383. guix-package-info-insert-size-button
  384. guix-package-info-insert-lint-button)
  385. "List of functions used to insert package buttons in Info buffer.
  386. Each function is called with 2 arguments: package ID and full name."
  387. :type '(repeat function)
  388. :group 'guix-package-info)
  389. (defvar guix-package-info-download-buffer nil
  390. "Buffer from which a current download operation was performed.")
  391. (defvar guix-package-info-output-format "%-8s "
  392. "String used to format output names of the packages.
  393. It should be a '%s'-sequence. After inserting an output name
  394. formatted with this string, an action button is inserted.")
  395. (define-button-type 'guix-package-license
  396. :supertype 'bui
  397. 'face 'guix-package-info-license
  398. 'help-echo "Display license info"
  399. 'action (lambda (btn)
  400. (require 'guix-ui-license)
  401. (bui-get-display-entries
  402. 'guix-license 'info
  403. (list 'name (button-label btn))
  404. 'add)))
  405. (defun guix-package-button-action (button)
  406. "Display package info for package BUTTON."
  407. (let ((search-type 'id)
  408. (search-value (or (button-get button 'id)
  409. (button-get button 'spec)
  410. (button-label button))))
  411. (if (eq major-mode 'guix-package-info-mode)
  412. (bui-get-display-entries-current
  413. 'guix-package 'info
  414. (list (guix-ui-current-profile)
  415. search-type search-value))
  416. (bui-get-display-entries
  417. 'guix-package 'info
  418. (list guix-current-profile
  419. search-type search-value)))))
  420. (define-button-type 'guix-package-name
  421. :supertype 'bui
  422. 'face 'guix-package-info-name-button
  423. 'help-echo "Describe this package"
  424. 'action 'guix-package-button-action)
  425. (define-button-type 'guix-package-heading
  426. :supertype 'guix-package-name
  427. 'face 'guix-package-info-heading)
  428. (define-button-type 'guix-package-source
  429. :supertype 'bui
  430. 'face 'guix-package-info-source
  431. 'help-echo ""
  432. 'action (lambda (_)
  433. ;; As a source may not be a real URL (e.g., "mirror://..."),
  434. ;; no action is bound to a source button.
  435. (message "Yes, this is the source URL. What did you expect?")))
  436. (defun guix-package-info-get-entries (profile search-type
  437. &rest search-values)
  438. "Return 'package' entries for displaying them in 'info' buffer."
  439. (guix-eval-read
  440. (guix-make-guile-expression
  441. 'package/output-sexps
  442. profile 'package search-type search-values
  443. (cl-union guix-package-info-required-params
  444. (bui-info-displayed-params 'guix-package)))))
  445. (defun guix-package-info-insert-heading (entry)
  446. "Insert package ENTRY heading (name and version) at point."
  447. (bui-insert-button
  448. (concat (bui-entry-non-void-value entry 'name) " "
  449. (bui-entry-non-void-value entry 'version))
  450. 'guix-package-heading
  451. 'spec (guix-package-entry->name-specification entry))
  452. (bui-newline))
  453. (defun guix-package-info-insert-location (location &optional _)
  454. "Insert package LOCATION at point."
  455. (bui-insert-non-nil location
  456. (bui-info-insert-value-indent location 'guix-location)
  457. (let ((location-file (guix-location-file location)))
  458. ;; Do not show "Packages" button if a package 'from file' is displayed.
  459. (unless (eq (guix-ui-current-search-type) 'from-file)
  460. (bui-insert-indent)
  461. (bui-insert-action-button
  462. "Packages"
  463. (lambda (btn)
  464. (guix-package-get-display (guix-ui-current-profile)
  465. 'location
  466. (button-get btn 'location)))
  467. (format "Display packages from location '%s'" location-file)
  468. 'location location-file)))))
  469. (defun guix-package-info-insert-systems (systems entry)
  470. "Insert supported package SYSTEMS at point."
  471. (if (require 'build-farm-build nil t)
  472. (bui-info-insert-value-format
  473. systems 'build-farm-system
  474. 'job (build-farm-job-name-specification
  475. (bui-entry-non-void-value entry 'name)
  476. (bui-entry-non-void-value entry 'version)))
  477. (bui-info-insert-value-format systems)))
  478. (defmacro guix-package-info-define-insert-inputs (&optional type)
  479. "Define a face and a button for package inputs.
  480. TYPE is a type of inputs.
  481. Button name is `guix-package-TYPE-input'.
  482. Face name is `guix-package-info-TYPE-inputs'."
  483. (let* ((type-str (symbol-name type))
  484. (type-name (and type (concat type-str "-")))
  485. (type-desc (and type (concat type-str " ")))
  486. (face (intern (concat "guix-package-info-" type-name "inputs")))
  487. (btn (intern (concat "guix-package-" type-name "input"))))
  488. `(progn
  489. (defface ,face
  490. '((t :inherit guix-package-info-name-button))
  491. ,(concat "Face used for " type-desc "inputs of a package.")
  492. :group 'guix-package-info-faces)
  493. (define-button-type ',btn
  494. :supertype 'guix-package-name
  495. 'face ',face))))
  496. (guix-package-info-define-insert-inputs)
  497. (guix-package-info-define-insert-inputs native)
  498. (guix-package-info-define-insert-inputs propagated)
  499. (defun guix-package-info-insert-name-buttons (values &optional button)
  500. "Insert package name buttons at point.
  501. Each element from VALUES should either be a specification string
  502. or (id spec) list."
  503. (bui-insert-non-nil values
  504. (let* ((text (with-temp-buffer
  505. (bui-mapinsert
  506. (lambda (value)
  507. (let ((spec (if (listp value)
  508. (cadr value)
  509. value)))
  510. (bui-insert-button
  511. spec (or button 'guix-package-name)
  512. 'id value)))
  513. values
  514. bui-list-separator)
  515. (buffer-substring (point-min) (point-max))))
  516. (strings (bui-split-string
  517. text
  518. (- (bui-fill-column)
  519. (length bui-info-multiline-prefix)))))
  520. (bui-mapinsert #'insert
  521. strings
  522. (concat "\n" bui-info-multiline-prefix)))))
  523. (defun guix-package-info-insert-name-button (value &optional button)
  524. "Insert package name button at point."
  525. (guix-package-info-insert-name-buttons (list value) button))
  526. (defun guix-package-info-insert-outputs (outputs entry)
  527. "Insert OUTPUTS from package ENTRY at point."
  528. (bui-newline)
  529. (dolist (output outputs)
  530. (guix-package-info-insert-output output entry)))
  531. (defun guix-package-info-insert-additional-text (entry)
  532. "Insert some additional info for package ENTRY at point."
  533. (let ((name (bui-entry-non-void-value entry 'name)))
  534. (if (bui-entry-non-void-value entry 'hidden)
  535. (progn
  536. (guix-package-info-insert-hidden-text)
  537. (bui-newline))
  538. (cl-case (bui-entry-non-void-value entry 'known-status)
  539. (known
  540. (when (bui-entry-non-void-value entry 'non-unique)
  541. (guix-package-info-insert-non-unique-text
  542. (guix-package-entry->name-specification entry))
  543. (bui-newline))
  544. (--when-let (bui-entry-non-void-value entry 'superseded)
  545. (guix-package-info-insert-superseded-text it)
  546. (bui-newline)))
  547. (obsolete (guix-package-info-insert-obsolete-text name))
  548. (unknown (guix-package-info-insert-unknown-text name))
  549. (future (guix-package-info-insert-future-text name))
  550. (pull (guix-package-info-insert-pull-text name entry))))))
  551. (defun guix-package-info-insert-unknown-text (name)
  552. "Insert a message about unknown package at point."
  553. (insert "This package is ")
  554. (bui-format-insert "unknown" 'guix-package-info-unknown)
  555. (insert ", i.e. there are no packages with\n"
  556. "'" name "' name among the available package recipes."))
  557. (defun guix-package-info-insert-obsolete-text (name)
  558. "Insert a message about obsolete package NAME at point."
  559. (insert "This package is ")
  560. (bui-format-insert "obsolete" 'guix-package-info-obsolete)
  561. (insert ", i.e. a newer version of\n")
  562. (bui-insert-button name 'guix-package-name)
  563. (insert " package is available."))
  564. (defun guix-package-info-insert-future-text (name)
  565. "Insert a message about package NAME with a future VERSION at point."
  566. (insert "This package is ")
  567. (bui-format-insert "from the future" 'guix-package-info-future)
  568. (insert ", i.e. this (installed) package
  569. is newer than the available package recipe for ")
  570. (bui-insert-button name 'guix-package-name)
  571. (insert "."))
  572. (defun guix-package-info-insert-pull-text (name entry)
  573. "Insert a message that NAME package was 'guix pull'-ed."
  574. (insert "This ")
  575. (bui-insert-button name 'guix-package-name)
  576. (insert " package was installed by 'guix pull' command")
  577. (let ((repository (bui-entry-non-void-value entry 'repository)))
  578. (if (not repository)
  579. (insert ".")
  580. (insert "\nfrom the following repository:\n\n")
  581. (bui-info-insert-entry repository 'guix-pulled-package 1))))
  582. (defun guix-package-info-insert-non-unique-text (full-name)
  583. "Insert a message about non-unique package with FULL-NAME at point."
  584. (insert "Installed outputs are displayed for a non-unique ")
  585. (bui-insert-button full-name 'guix-package-name)
  586. (insert " package.")
  587. (bui-newline))
  588. (defun guix-package-info-insert-superseded-text (full-name)
  589. "Insert a message that current package is superseded by FULL-NAME."
  590. (insert "This package is ")
  591. (bui-format-insert "superseded" 'guix-package-info-superseded)
  592. (insert " by ")
  593. (bui-insert-button full-name 'guix-package-name)
  594. (insert " package.")
  595. (bui-newline))
  596. (defun guix-package-info-insert-hidden-text ()
  597. "Insert a message that current package is hidden."
  598. (insert "This package is ")
  599. (bui-format-insert "hidden" 'guix-package-info-hidden)
  600. (insert ", so do not tell anyone about it ;-)\n"))
  601. (defun guix-package-info-insert-output (output entry)
  602. "Insert OUTPUT at point.
  603. Make some fancy text with buttons and additional stuff if the
  604. current OUTPUT is installed (if there is such output in
  605. `installed' parameter of a package ENTRY)."
  606. (let* ((installed (bui-entry-non-void-value entry 'installed))
  607. (obsolete (eq (bui-entry-non-void-value entry 'known-status)
  608. 'obsolete))
  609. (installed-entry (--find
  610. (string= (bui-entry-non-void-value it 'output)
  611. output)
  612. installed))
  613. (action-type (if installed-entry 'delete 'install))
  614. (profile (guix-ui-current-profile)))
  615. (bui-insert-indent)
  616. (bui-format-insert output
  617. (if installed-entry
  618. 'guix-package-info-installed-outputs
  619. 'guix-package-info-uninstalled-outputs)
  620. guix-package-info-output-format)
  621. ;; Do not allow a user to install/delete anything to/from a system
  622. ;; profile or "guix pull"-ed profile, so add action buttons only for
  623. ;; usual profiles.
  624. (when (and profile
  625. (not (guix-system-profile? profile))
  626. (not (guix-pulled-profile? profile)))
  627. (guix-package-info-insert-action-button action-type entry output)
  628. (when obsolete
  629. (bui-insert-indent)
  630. (guix-package-info-insert-action-button 'upgrade entry output)))
  631. (bui-newline)
  632. (when installed-entry
  633. (bui-info-insert-entry installed-entry 'guix-installed-output 2))))
  634. (defun guix-package-info-insert-action-button (type entry output)
  635. "Insert button to process an action on a package OUTPUT at point.
  636. TYPE is one of the following symbols: `install', `delete', `upgrade'.
  637. ENTRY is an alist with package info."
  638. (let ((type-str (capitalize (symbol-name type)))
  639. (full-name (guix-package-entry->name-specification entry output)))
  640. (bui-insert-action-button
  641. type-str
  642. (lambda (btn)
  643. (guix-process-package-actions
  644. (guix-ui-current-profile)
  645. `((,(button-get btn 'action-type) (,(button-get btn 'id)
  646. ,(button-get btn 'output))))
  647. (current-buffer)))
  648. (concat type-str " '" full-name "'")
  649. 'action-type type
  650. 'id (or (bui-entry-non-void-value entry 'package-id)
  651. (bui-entry-id entry))
  652. 'output output)))
  653. (defun guix-package-info-show-store-path (entry-id package-id)
  654. "Show store directories of the package outputs in the current buffer.
  655. ENTRY-ID is an ID of the current entry (package or output).
  656. PACKAGE-ID is an ID of the package which store path to show."
  657. (let* ((entries (bui-current-entries))
  658. (entry (bui-entry-by-id entries entry-id))
  659. (dirs (guix-package-store-path package-id)))
  660. (or dirs
  661. (error "Couldn't define store directory of the package"))
  662. (let* ((new-entry (cons (cons 'store-path dirs)
  663. entry))
  664. (new-entries (bui-replace-entry entries entry-id new-entry)))
  665. (setf (bui-item-entries bui-item)
  666. new-entries)
  667. (bui-redisplay-goto-button)
  668. (let ((dir (car dirs)))
  669. (if (file-exists-p dir)
  670. (if guix-package-info-auto-find-package
  671. (find-file dir)
  672. (message nil))
  673. (message "'%s' does not exist.\nTry to build this package."
  674. dir))))))
  675. (defun guix-package-info-insert-misc (entry)
  676. "Insert various buttons and other info for package ENTRY at point."
  677. (when (eq (bui-entry-non-void-value entry 'known-status)
  678. 'known)
  679. (let* ((entry-id (bui-entry-id entry))
  680. (package-id (or (bui-entry-non-void-value entry 'package-id)
  681. entry-id))
  682. (full-name (guix-package-entry->name-specification entry))
  683. (store-path (bui-entry-non-void-value entry 'store-path)))
  684. (bui-info-insert-title-simple "Package")
  685. (if store-path
  686. (bui-info-insert-value-indent store-path 'bui-file)
  687. (bui-insert-action-button
  688. "Show"
  689. (lambda (btn)
  690. (guix-package-info-show-store-path
  691. (button-get btn 'entry-id)
  692. (button-get btn 'package-id)))
  693. "Show the store directory of the current package"
  694. 'entry-id entry-id
  695. 'package-id package-id))
  696. (when guix-package-info-button-functions
  697. (bui-newline)
  698. (bui-mapinsert (lambda (fun)
  699. (funcall fun package-id full-name))
  700. guix-package-info-button-functions
  701. (bui-get-indent)
  702. :indent bui-indent
  703. :column (bui-fill-column)))
  704. (bui-newline))))
  705. (defun guix-package-info-insert-build-button (id full-name)
  706. "Insert button to build a package defined by ID."
  707. (bui-insert-action-button
  708. "Build"
  709. (lambda (btn)
  710. (guix-build-package (button-get btn 'id)
  711. (format "Build '%s' package?" full-name)))
  712. "Build the current package"
  713. 'id id))
  714. (defun guix-package-info-insert-build-log-button (id _name)
  715. "Insert button to show build log of a package defined by ID."
  716. (bui-insert-action-button
  717. "Build Log"
  718. (lambda (btn)
  719. (guix-package-find-build-log (button-get btn 'id)))
  720. "View build log of the current package"
  721. 'id id))
  722. (declare-function guix-package-graph "guix-graph" t)
  723. (defun guix-package-info-insert-graph-button (id _name)
  724. "Insert button to show a graph of a package defined by ID."
  725. (bui-insert-action-button
  726. "Graph"
  727. (lambda (btn)
  728. (guix-package-graph (button-get btn 'id)
  729. (guix-read-graph-backend)
  730. (guix-read-graph-node-type)))
  731. "View graph of the current package"
  732. 'id id))
  733. (defun guix-package-info-insert-size-button (_id name)
  734. "Insert button to show a size of a package NAME."
  735. (bui-insert-action-button
  736. "Size"
  737. (lambda (btn)
  738. (guix-package-size (button-get btn 'name)
  739. (guix-read-package-size-type)))
  740. (format "View size of '%s' package" name)
  741. 'name name))
  742. (defun guix-package-info-insert-lint-button (id _name)
  743. "Insert button to lint a package defined by ID."
  744. (bui-insert-action-button
  745. "Lint"
  746. (lambda (btn)
  747. (guix-package-lint (list (button-get btn 'id))
  748. (and current-prefix-arg
  749. (guix-read-lint-checker-names))))
  750. "Lint the current package"
  751. 'id id))
  752. (defun guix-package-info-show-source (entry-id package-id)
  753. "Show file name of a package source in the current info buffer.
  754. Find the file if needed (see `guix-package-info-auto-find-source').
  755. ENTRY-ID is an ID of the current entry (package or output).
  756. PACKAGE-ID is an ID of the package which source to show."
  757. (let* ((entries (bui-current-entries))
  758. (entry (bui-entry-by-id entries entry-id))
  759. (file (guix-package-source-file-name package-id)))
  760. (or file
  761. (error "Couldn't define file name of the package source"))
  762. (let* ((new-entry (cons (cons 'source-file file)
  763. entry))
  764. (new-entries (bui-replace-entry entries entry-id new-entry)))
  765. (setf (bui-item-entries bui-item)
  766. new-entries)
  767. (bui-redisplay-goto-button)
  768. (if (file-exists-p file)
  769. (if guix-package-info-auto-find-source
  770. (guix-find-file file)
  771. (message "The file name of the package source is displayed."))
  772. (if guix-package-info-auto-download-source
  773. (guix-package-info-download-source package-id)
  774. (message "The source does not exist in the store."))))))
  775. (defun guix-package-info-download-source (package-id)
  776. "Download a source of the package PACKAGE-ID."
  777. (setq guix-package-info-download-buffer (current-buffer))
  778. (guix-package-source-build-derivation
  779. package-id
  780. "The source does not exist in the store. Download it?"))
  781. (defun guix-package-info-insert-source (source entry)
  782. "Insert SOURCE from package ENTRY at point.
  783. SOURCE is a list of URLs."
  784. (bui-insert-non-nil source
  785. (let* ((source-file (bui-entry-non-void-value entry 'source-file))
  786. (entry-id (bui-entry-id entry))
  787. (package-id (or (bui-entry-non-void-value entry 'package-id)
  788. entry-id)))
  789. (if (null source-file)
  790. (bui-insert-action-button
  791. "Show"
  792. (lambda (btn)
  793. (guix-package-info-show-source (button-get btn 'entry-id)
  794. (button-get btn 'package-id)))
  795. "Show the source store directory of the current package"
  796. 'entry-id entry-id
  797. 'package-id package-id)
  798. (unless (file-exists-p source-file)
  799. (bui-insert-action-button
  800. "Download"
  801. (lambda (btn)
  802. (guix-package-info-download-source
  803. (button-get btn 'package-id)))
  804. "Download the source into the store"
  805. 'package-id package-id))
  806. (bui-info-insert-value-indent source-file 'bui-file))
  807. (bui-info-insert-value-indent source 'guix-package-source))))
  808. (defun guix-package-info-redisplay-after-download ()
  809. "Redisplay an 'info' buffer after downloading the package source.
  810. This function is used to hide a \"Download\" button if needed."
  811. (when (buffer-live-p guix-package-info-download-buffer)
  812. (with-current-buffer guix-package-info-download-buffer
  813. (bui-redisplay-goto-button))
  814. (setq guix-package-info-download-buffer nil)))
  815. (add-hook 'guix-after-source-download-hook
  816. 'guix-package-info-redisplay-after-download)
  817. (defun guix-package-entry-ensure-known (entry)
  818. "Signal an error if package ENTRY is unknown."
  819. (unless (eq (bui-entry-non-void-value entry 'known-status)
  820. 'known)
  821. (error "This command is not available for obsolete or unknown packages")))
  822. (defun guix-package-info-edit (entry &optional directory)
  823. "Go to the location of the package ENTRY.
  824. See `guix-find-location' for the meaning of DIRECTORY."
  825. (interactive
  826. (let ((entry (guix-read-package-entry-by-name)))
  827. (guix-package-entry-ensure-known entry)
  828. (list entry
  829. (guix-read-directory))))
  830. (guix-find-location (bui-entry-non-void-value entry 'location)
  831. directory))
  832. (defun guix-package-info-graph (entry backend node-type)
  833. "Show BACKEND/NODE-TYPE graph for the package ENTRY."
  834. (interactive
  835. (list (guix-read-package-entry-by-name)
  836. (guix-read-graph-backend)
  837. (guix-read-graph-node-type)))
  838. (guix-package-graph (if (eq (bui-entry-non-void-value entry 'known-status)
  839. 'known)
  840. (bui-entry-id entry)
  841. (bui-entry-non-void-value entry 'name))
  842. backend node-type))
  843. (defun guix-package-info-size (entry &optional type)
  844. "Show size of the package ENTRY.
  845. See `guix-package-size' for the meaning of TYPE."
  846. (interactive
  847. (list (guix-read-package-entry-by-name)
  848. (guix-read-package-size-type)))
  849. (guix-package-size (if (eq (bui-entry-non-void-value entry 'known-status)
  850. 'known)
  851. (guix-package-entry->name-specification entry)
  852. ;; Take file name of the first output.
  853. ;; FIXME It is better to ask for an output, if
  854. ;; there are several outputs.
  855. (bui-entry-value
  856. (car (bui-entry-value entry 'installed))
  857. 'file-name))
  858. type))
  859. (defun guix-package-info-lint (entry &optional checkers)
  860. "Lint the package ENTRY.
  861. Interactively with prefix, prompt for CHECKERS.
  862. See `guix-package-lint' for details."
  863. (interactive
  864. (let ((entry (guix-read-package-entry-by-name)))
  865. (guix-package-entry-ensure-known entry)
  866. (list entry
  867. (and current-prefix-arg
  868. (guix-read-lint-checker-names)))))
  869. (guix-package-lint (list (bui-entry-id entry)) checkers))
  870. (defun guix-package-info-install (entry output)
  871. "Install package OUTPUT to the current profile.
  872. Interactively, prompt for package ENTRY and OUTPUT (if there are
  873. more than one)."
  874. (interactive (guix-read-package-entry-and-output))
  875. (if (member output (guix-package-entry-installed-outputs entry))
  876. (user-error "'%s' is already installed"
  877. (guix-package-entry->name-specification entry output))
  878. (guix-process-package-actions
  879. (guix-ui-current-profile)
  880. `((install (,(bui-entry-id entry) ,output)))
  881. (current-buffer))))
  882. (defun guix-package-info-delete (entry output)
  883. "Delete package OUTPUT from the current profile.
  884. Interactively, prompt for package ENTRY and OUTPUT (if there are
  885. more than one)."
  886. (interactive (guix-read-package-entry-and-output))
  887. (if (member output (guix-package-entry-installed-outputs entry))
  888. (guix-process-package-actions
  889. (guix-ui-current-profile)
  890. `((delete (,(bui-entry-id entry) ,output)))
  891. (current-buffer))
  892. (user-error "'%s' cannot be deleted as it is not installed"
  893. (guix-package-entry->name-specification entry output))))
  894. (defun guix-package-info-upgrade (entry output)
  895. "Upgrade package OUTPUT in the current profile.
  896. Interactively, prompt for package ENTRY and OUTPUT (if there are
  897. more than one)."
  898. (interactive (guix-read-package-entry-and-output))
  899. (if (member output (guix-package-entry-installed-outputs entry))
  900. (when (or (eq (bui-entry-non-void-value entry 'known-status)
  901. 'obsolete)
  902. (y-or-n-p
  903. (format "'%s' is not obsolete. Try to upgrade it anyway? "
  904. (guix-package-entry->name-specification
  905. entry output))))
  906. (guix-process-package-actions
  907. (guix-ui-current-profile)
  908. `((upgrade (,(bui-entry-id entry) ,output)))
  909. (current-buffer)))
  910. (when (y-or-n-p
  911. (format "'%s' is not installed. Install it? "
  912. (guix-package-entry->name-specification entry output)))
  913. (guix-process-package-actions
  914. (guix-ui-current-profile)
  915. `((install (,(bui-entry-id entry) ,output)))
  916. (current-buffer)))))
  917. ;;; Package 'list'
  918. (guix-ui-define-interface package list
  919. :mode-name "Package-List"
  920. :buffer-name "*Guix Packages*"
  921. :get-entries-function 'guix-package-list-get-entries
  922. :describe-function 'guix-ui-list-describe
  923. :format '((name guix-package-list-get-name 20 t)
  924. (version nil 10 nil)
  925. (outputs nil 13 t)
  926. (installed guix-package-list-get-installed-outputs 13 t)
  927. (synopsis bui-list-get-one-line 30 nil))
  928. :required '(id known-status superseded hidden)
  929. :hint 'guix-package-list-hint
  930. :sort-key '(name)
  931. :marks '((install . ?I)
  932. (upgrade . ?U)
  933. (delete . ?D)))
  934. (let ((map guix-package-list-mode-map))
  935. (define-key map (kbd "B") 'guix-package-list-latest-builds)
  936. (define-key map (kbd "G") 'guix-package-list-graph)
  937. (define-key map (kbd "z") 'guix-package-list-size)
  938. (define-key map (kbd "L") 'guix-package-list-lint)
  939. (define-key map (kbd "e") 'guix-package-list-edit)
  940. (define-key map (kbd "x") 'guix-package-list-execute)
  941. (define-key map (kbd "i") 'guix-package-list-mark-install)
  942. (define-key map (kbd "d") 'guix-package-list-mark-delete)
  943. (define-key map (kbd "U") 'guix-package-list-mark-upgrade)
  944. (define-key map (kbd "^") 'guix-package-list-mark-upgrades))
  945. (defface guix-package-list-installed
  946. '((t :inherit guix-package-info-installed-outputs))
  947. "Face used for installed packages."
  948. :group 'guix-package-list-faces)
  949. (defface guix-package-list-unknown
  950. '((t :inherit guix-package-info-unknown))
  951. "Face used for unknown packages.
  952. See `guix-package-info-unknown' face for details."
  953. :group 'guix-package-list-faces)
  954. (defface guix-package-list-obsolete
  955. '((t :inherit guix-package-info-obsolete))
  956. "Face used for obsolete packages.
  957. See `guix-package-info-obsolete' face for details."
  958. :group 'guix-package-list-faces)
  959. (defface guix-package-list-future
  960. '((t :inherit guix-package-info-future))
  961. "Face used for packages from the future.
  962. See `guix-package-info-future' face for details."
  963. :group 'guix-package-list-faces)
  964. (defface guix-package-list-superseded
  965. '((t :inherit guix-package-info-superseded))
  966. "Face used for superseded packages.
  967. See `guix-package-info-superseded' face for details."
  968. :group 'guix-package-list-faces)
  969. (defface guix-package-list-hidden
  970. '((t :inherit guix-package-info-hidden))
  971. "Face used for hidden packages.
  972. See `guix-package-info-hidden' face for details."
  973. :group 'guix-package-list-faces)
  974. (defcustom guix-package-list-generation-marking-enabled nil
  975. "If non-nil, allow putting marks in a list with 'generation packages'.
  976. By default this is disabled, because it may be confusing. For
  977. example, a package is installed in some generation, so a user can
  978. mark it for deletion in the list of packages from this
  979. generation, but the package may not be installed in the latest
  980. generation, so actually it cannot be deleted.
  981. If you managed to understand the explanation above or if you
  982. really know what you do or if you just don't care, you can set
  983. this variable to t. It should not do much harm anyway (most
  984. likely)."
  985. :type 'boolean
  986. :group 'guix-package-list)
  987. (defvar guix-package-list-default-hint
  988. '(("\\[guix-package-list-edit]") " edit (go to) the package definition;\n"
  989. ("\\[guix-package-list-graph]") " view package graph; "
  990. ("\\[guix-package-list-size]") " view package size; "
  991. ("\\[guix-package-list-lint]") " lint;\n"
  992. ("\\[guix-package-list-mark-install]") " mark for installation; "
  993. ("\\[guix-package-list-mark-delete]") " mark for deletion;\n"
  994. ("\\[guix-package-list-mark-upgrade]") " mark for upgrading; "
  995. ("\\[guix-package-list-mark-upgrades]") " mark all for upgrading;\n"
  996. ("\\[guix-package-list-execute]") " execute operation;\n"))
  997. (defun guix-package-list-hint ()
  998. (bui-format-hints
  999. guix-package-list-default-hint
  1000. guix-ui-hint
  1001. (bui-default-hint)))
  1002. (defun guix-package-list-get-entries (profile search-type
  1003. &rest search-values)
  1004. "Return 'package' entries for displaying them in 'list' buffer."
  1005. (guix-eval-read
  1006. (guix-make-guile-expression
  1007. 'package/output-sexps
  1008. profile 'package search-type search-values
  1009. (cl-union guix-package-list-required-params
  1010. (bui-list-displayed-params 'guix-package)))))
  1011. (defun guix-package-list-get-name (name entry)
  1012. "Return NAME of the package ENTRY.
  1013. Colorize it with an appropriate face if needed."
  1014. (bui-get-string
  1015. name
  1016. (if (bui-entry-non-void-value entry 'hidden)
  1017. 'guix-package-list-hidden
  1018. (cl-case (bui-entry-non-void-value entry 'known-status)
  1019. ((known nil)
  1020. (cond
  1021. ((bui-entry-non-void-value entry 'superseded)
  1022. 'guix-package-list-superseded)
  1023. ((bui-entry-non-void-value entry 'installed)
  1024. 'guix-package-list-installed)))
  1025. (obsolete 'guix-package-list-obsolete)
  1026. (unknown 'guix-package-list-unknown)
  1027. (future 'guix-package-list-future)))))
  1028. (defun guix-package-list-get-installed-outputs (installed &optional _)
  1029. "Return string with outputs from INSTALLED entries."
  1030. (bui-get-string
  1031. (--map (bui-entry-non-void-value it 'output)
  1032. installed)))
  1033. (defun guix-package-list-marking-check ()
  1034. "Signal an error if marking is disabled for the current buffer."
  1035. (when (and (not guix-package-list-generation-marking-enabled)
  1036. (or (derived-mode-p 'guix-package-list-mode)
  1037. (derived-mode-p 'guix-output-list-mode))
  1038. (eq (guix-ui-current-search-type) 'generation))
  1039. (error "Action marks are disabled for lists of 'generation packages'")))
  1040. (defun guix-package-list-mark-outputs (mark default
  1041. &optional prompt available)
  1042. "Mark the current package with MARK and move to the next line.
  1043. If PROMPT is non-nil, use it to ask a user for outputs from
  1044. AVAILABLE list, otherwise mark all DEFAULT outputs."
  1045. (let ((outputs (if prompt
  1046. (guix-completing-read-multiple
  1047. prompt available nil t)
  1048. default)))
  1049. (apply #'bui-list--mark mark t outputs)))
  1050. (defun guix-package-list-mark-install (&optional arg)
  1051. "Mark the current package for installation and move to the next line.
  1052. With ARG, prompt for the outputs to install (several outputs may
  1053. be separated with \",\")."
  1054. (interactive "P")
  1055. (guix-package-list-marking-check)
  1056. (let* ((entry (bui-list-current-entry))
  1057. (all (bui-entry-non-void-value entry 'outputs))
  1058. (installed (guix-package-entry-installed-outputs entry))
  1059. (available (cl-set-difference all installed :test #'string=)))
  1060. (or available
  1061. (user-error "This package is already installed"))
  1062. (guix-package-list-mark-outputs
  1063. 'install '("out")
  1064. (and arg "Output(s) to install: ")
  1065. available)))
  1066. (defun guix-package-list-mark-delete (&optional arg)
  1067. "Mark the current package for deletion and move to the next line.
  1068. With ARG, prompt for the outputs to delete (several outputs may
  1069. be separated with \",\")."
  1070. (interactive "P")
  1071. (guix-package-list-marking-check)
  1072. (let* ((entry (bui-list-current-entry))
  1073. (installed (guix-package-entry-installed-outputs entry)))
  1074. (or installed
  1075. (user-error "This package is not installed"))
  1076. (guix-package-list-mark-outputs
  1077. 'delete installed
  1078. (and arg "Output(s) to delete: ")
  1079. installed)))
  1080. (defun guix-package-list-mark-upgrade (&optional arg)
  1081. "Mark the current package for upgrading and move to the next line.
  1082. With ARG, prompt for the outputs to upgrade (several outputs may
  1083. be separated with \",\")."
  1084. (interactive "P")
  1085. (guix-package-list-marking-check)
  1086. (let* ((entry (bui-list-current-entry))
  1087. (installed (guix-package-entry-installed-outputs entry)))
  1088. (or installed
  1089. (user-error "This package is not installed"))
  1090. (when (or (eq (bui-entry-non-void-value entry 'known-status)
  1091. 'obsolete)
  1092. (y-or-n-p "This package is not obsolete. Try to upgrade it anyway? "))
  1093. (guix-package-list-mark-outputs
  1094. 'upgrade installed
  1095. (and arg "Output(s) to upgrade: ")
  1096. installed))))
  1097. (defun guix-package-mark-upgrades (fun &optional all)
  1098. "Mark all obsolete packages for upgrading.
  1099. Use FUN to perform marking of the current line. FUN should
  1100. take an entry as argument.
  1101. If ALL is non-nil, mark all installed (not only obsolete) packages."
  1102. (guix-package-list-marking-check)
  1103. (let ((entries (--filter (if all
  1104. (bui-entry-non-void-value it 'installed)
  1105. (eq (bui-entry-non-void-value it 'known-status)
  1106. 'obsolete))
  1107. (bui-current-entries))))
  1108. (bui-list-for-each-line
  1109. (lambda ()
  1110. (let* ((id (bui-list-current-id))
  1111. (entry (--find (equal id (bui-entry-id it))
  1112. entries)))
  1113. (when entry
  1114. (funcall fun entry)))))))
  1115. (defun guix-package-list-mark-upgrades (&optional arg)
  1116. "Mark all obsolete packages for upgrading.
  1117. With ARG, mark all installed (including non-obsolete) packages."
  1118. (interactive "P")
  1119. (guix-package-mark-upgrades
  1120. (lambda (entry)
  1121. (apply #'bui-list--mark
  1122. 'upgrade nil
  1123. (guix-package-entry-installed-outputs entry)))
  1124. arg))
  1125. (defun guix-package-assert-non-system-profile ()
  1126. "Verify that the current profile is not a system one.
  1127. The current profile is the one used by the current buffer."
  1128. (--when-let (guix-ui-current-profile)
  1129. (guix-assert-non-system-profile it)))
  1130. (defun guix-package-execute-actions (fun)
  1131. "Perform actions on the marked packages.
  1132. Use FUN to define actions suitable for `guix-process-package-actions'.
  1133. FUN should take action-type as argument."
  1134. (guix-package-assert-non-system-profile)
  1135. (let ((actions (-non-nil (mapcar fun '(install delete upgrade)))))
  1136. (if actions
  1137. (guix-process-package-actions (guix-ui-current-profile)
  1138. actions (current-buffer))
  1139. (user-error "No operations specified"))))
  1140. (defun guix-package-list-execute ()
  1141. "Perform actions on the marked packages."
  1142. (interactive)
  1143. (guix-package-execute-actions #'guix-package-list-make-action))
  1144. (defun guix-package-list-make-action (action-type)
  1145. "Return action specification for the packages marked with ACTION-TYPE.
  1146. Return nil, if there are no packages marked with ACTION-TYPE.
  1147. The specification is suitable for `guix-process-package-actions'."
  1148. (let ((specs (bui-list-get-marked-args action-type)))
  1149. (and specs (cons action-type specs))))
  1150. (defun guix-package-list-edit (&optional directory)
  1151. "Go to the location of the current package.
  1152. See `guix-find-location' for the meaning of DIRECTORY."
  1153. (interactive (list (guix-read-directory)))
  1154. (guix-find-package-definition (bui-list-current-id) directory))
  1155. (defun guix-package-list-graph (backend node-type)
  1156. "Show BACKEND/NODE-TYPE graph for the current package."
  1157. (interactive
  1158. (list (guix-read-graph-backend)
  1159. (guix-read-graph-node-type)))
  1160. (let ((entry (bui-list-current-entry)))
  1161. (guix-package-graph (if (eq (bui-entry-non-void-value entry 'known-status)
  1162. 'known)
  1163. (bui-list-current-id)
  1164. (bui-entry-non-void-value entry 'name))
  1165. backend node-type)))
  1166. (defun guix-package-list-size (&optional type)
  1167. "Show size of the current package.
  1168. See `guix-package-size' for the meaning of TYPE."
  1169. (interactive (list (guix-read-package-size-type)))
  1170. (guix-package-size (guix-package-entry->name-specification
  1171. (bui-list-current-entry))
  1172. type))
  1173. (defun guix-package-list-lint (&optional checkers)
  1174. "Lint marked (or the current) packages.
  1175. Interactively with prefix, prompt for CHECKERS.
  1176. See `guix-package-lint' for details."
  1177. (interactive
  1178. (list (and current-prefix-arg
  1179. (guix-read-lint-checker-names))))
  1180. (guix-package-lint (bui-list-marked-or-current) checkers))
  1181. (declare-function build-farm-build-latest-prompt-args "build-farm-build" t)
  1182. (declare-function build-farm-latest-builds "build-farm-build" t)
  1183. (declare-function build-farm-job-name-specification "build-farm" t)
  1184. (defun guix-package-list-latest-builds (number &rest args)
  1185. "Display latest NUMBER of `build-farm' builds of the current package.
  1186. Interactively, with prefix argument, prompt for NUMBER and ARGS."
  1187. (interactive
  1188. (let ((entry (bui-list-current-entry)))
  1189. (guix-assert-build-farm)
  1190. (require 'build-farm-build)
  1191. (build-farm-build-latest-prompt-args
  1192. :job (build-farm-job-name-specification
  1193. (bui-entry-non-void-value entry 'name)
  1194. (bui-entry-non-void-value entry 'version)))))
  1195. (guix-assert-build-farm)
  1196. (apply #'build-farm-latest-builds number args))
  1197. ;;; Output 'list'
  1198. (guix-ui-define-interface output list
  1199. :mode-name "Output-List"
  1200. :buffer-name "*Guix Packages*"
  1201. :get-entries-function 'guix-output-list-get-entries
  1202. :describe-function 'guix-output-list-describe
  1203. :format '((name guix-package-list-get-name 20 t)
  1204. (version nil 10 nil)
  1205. (output nil 9 t)
  1206. (installed nil 12 t)
  1207. (synopsis bui-list-get-one-line 30 nil))
  1208. :required '(id package-id known-status superseded hidden)
  1209. :hint 'guix-output-list-hint
  1210. :sort-key '(name)
  1211. :marks '((install . ?I)
  1212. (upgrade . ?U)
  1213. (delete . ?D)))
  1214. (let ((map guix-output-list-mode-map))
  1215. (define-key map (kbd "B") 'guix-package-list-latest-builds)
  1216. (define-key map (kbd "G") 'guix-output-list-graph)
  1217. (define-key map (kbd "z") 'guix-package-list-size)
  1218. (define-key map (kbd "L") 'guix-output-list-lint)
  1219. (define-key map (kbd "e") 'guix-output-list-edit)
  1220. (define-key map (kbd "x") 'guix-output-list-execute)
  1221. (define-key map (kbd "i") 'guix-output-list-mark-install)
  1222. (define-key map (kbd "d") 'guix-output-list-mark-delete)
  1223. (define-key map (kbd "U") 'guix-output-list-mark-upgrade)
  1224. (define-key map (kbd "^") 'guix-output-list-mark-upgrades))
  1225. (defvar guix-output-list-default-hint
  1226. '(("\\[guix-output-list-edit]") " edit (go to) the package definition;\n"
  1227. ("\\[guix-output-list-graph]") " view package graph; "
  1228. ("\\[guix-package-list-size]") " view package size; "
  1229. ("\\[guix-output-list-lint]") " lint;\n"
  1230. ("\\[guix-output-list-mark-install]") " mark for installation; "
  1231. ("\\[guix-output-list-mark-delete]") " mark for deletion;\n"
  1232. ("\\[guix-output-list-mark-upgrade]") " mark for upgrading; "
  1233. ("\\[guix-output-list-mark-upgrades]") " mark all for upgrading;\n"
  1234. ("\\[guix-output-list-execute]") " execute operation;\n"))
  1235. (defun guix-output-list-hint ()
  1236. (bui-format-hints
  1237. guix-output-list-default-hint
  1238. guix-ui-hint
  1239. (bui-default-hint)))
  1240. (defun guix-output-list-get-entries (profile search-type
  1241. &rest search-values)
  1242. "Return 'output' entries for displaying them in 'list' buffer."
  1243. (guix-eval-read
  1244. (guix-make-guile-expression
  1245. 'package/output-sexps
  1246. profile 'output search-type search-values
  1247. (cl-union guix-output-list-required-params
  1248. (bui-list-displayed-params 'guix-output)))))
  1249. (defun guix-output-list-mark-install ()
  1250. "Mark the current output for installation and move to the next line."
  1251. (interactive)
  1252. (guix-package-list-marking-check)
  1253. (let* ((entry (bui-list-current-entry))
  1254. (installed (bui-entry-non-void-value entry 'installed)))
  1255. (if installed
  1256. (user-error "This output is already installed")
  1257. (bui-list--mark 'install t))))
  1258. (defun guix-output-list-mark-delete ()
  1259. "Mark the current output for deletion and move to the next line."
  1260. (interactive)
  1261. (guix-package-list-marking-check)
  1262. (let* ((entry (bui-list-current-entry))
  1263. (installed (bui-entry-non-void-value entry 'installed)))
  1264. (if installed
  1265. (bui-list--mark 'delete t)
  1266. (user-error "This output is not installed"))))
  1267. (defun guix-output-list-mark-upgrade ()
  1268. "Mark the current output for upgrading and move to the next line."
  1269. (interactive)
  1270. (guix-package-list-marking-check)
  1271. (let* ((entry (bui-list-current-entry))
  1272. (installed (bui-entry-non-void-value entry 'installed)))
  1273. (or installed
  1274. (user-error "This output is not installed"))
  1275. (when (or (eq (bui-entry-non-void-value entry 'known-status)
  1276. 'obsolete)
  1277. (y-or-n-p "This output is not obsolete. Try to upgrade it anyway? "))
  1278. (bui-list--mark 'upgrade t))))
  1279. (defun guix-output-list-mark-upgrades (&optional arg)
  1280. "Mark all obsolete package outputs for upgrading.
  1281. With ARG, mark all installed (including non-obsolete) packages."
  1282. (interactive "P")
  1283. (guix-package-mark-upgrades
  1284. (lambda (_) (bui-list--mark 'upgrade))
  1285. arg))
  1286. (defun guix-output-list-execute ()
  1287. "Perform actions on the marked outputs."
  1288. (interactive)
  1289. (guix-package-execute-actions #'guix-output-list-make-action))
  1290. (defun guix-output-list-make-action (action-type)
  1291. "Return action specification for the outputs marked with ACTION-TYPE.
  1292. Return nil, if there are no outputs marked with ACTION-TYPE.
  1293. The specification is suitable for `guix-process-output-actions'."
  1294. (let ((ids (bui-list-get-marked-id-list action-type)))
  1295. (and ids (cons action-type
  1296. (mapcar #'guix-package-id-and-output-by-output-id
  1297. ids)))))
  1298. (defun guix-output-list-describe (&rest ids)
  1299. "Describe outputs with IDS (list of output identifiers)."
  1300. (let ((pids (--map (car (guix-package-id-and-output-by-output-id it))
  1301. ids)))
  1302. (bui-get-display-entries
  1303. 'guix-package 'info
  1304. (cl-list* (guix-ui-current-profile)
  1305. 'id (cl-remove-duplicates pids))
  1306. 'add)))
  1307. (defun guix-output-list-edit (&optional directory)
  1308. "Go to the location of the current package.
  1309. See `guix-find-location' for the meaning of DIRECTORY."
  1310. (interactive (list (guix-read-directory)))
  1311. (guix-find-package-definition
  1312. (bui-entry-non-void-value (bui-list-current-entry)
  1313. 'package-id)
  1314. directory))
  1315. (defun guix-output-list-graph (backend node-type)
  1316. "Show BACKEND/NODE-TYPE graph for the current package."
  1317. (interactive
  1318. (list (guix-read-graph-backend)
  1319. (guix-read-graph-node-type)))
  1320. (let ((entry (bui-list-current-entry)))
  1321. (guix-package-graph (if (eq (bui-entry-non-void-value entry 'known-status)
  1322. 'known)
  1323. (bui-entry-non-void-value entry 'package-id)
  1324. (bui-entry-non-void-value entry 'name))
  1325. backend node-type)))
  1326. (defun guix-output-list-lint (&optional checkers)
  1327. "Lint the current package.
  1328. Interactively with prefix, prompt for CHECKERS.
  1329. See `guix-package-lint' for details."
  1330. (interactive
  1331. (list (and current-prefix-arg
  1332. (guix-read-lint-checker-names))))
  1333. (guix-package-lint
  1334. (list (bui-entry-non-void-value (bui-list-current-entry)
  1335. 'package-id))
  1336. checkers))
  1337. ;;; Interactive commands
  1338. (defvar guix-package-search-params '(name synopsis description)
  1339. "Default list of package parameters for searching by regexp.")
  1340. (defvar guix-package-search-history nil
  1341. "A history of minibuffer prompts.")
  1342. ;;;###autoload
  1343. (defun guix-packages-by-name (name &optional profile)
  1344. "Display Guix packages with NAME.
  1345. NAME is a string with name specification. It may optionally contain
  1346. a version number. Examples: \"guile\", \"guile@2.0.11\".
  1347. If PROFILE is nil, use `guix-current-profile'.
  1348. Interactively with prefix, prompt for PROFILE."
  1349. (interactive
  1350. (list (guix-read-package-name)
  1351. (guix-ui-read-package-profile)))
  1352. (guix-package-get-display profile 'name name))
  1353. ;;;###autoload
  1354. (defun guix-packages-by-license (license &optional profile)
  1355. "Display Guix packages with LICENSE.
  1356. LICENSE is a license name string.
  1357. If PROFILE is nil, use `guix-current-profile'.
  1358. Interactively with prefix, prompt for PROFILE."
  1359. (interactive
  1360. (list (guix-read-license-name)
  1361. (guix-ui-read-package-profile)))
  1362. (guix-package-get-display profile 'license license))
  1363. ;;;###autoload
  1364. (defun guix-packages-by-location (location &optional profile)
  1365. "Display Guix packages placed in LOCATION file.
  1366. If PROFILE is nil, use `guix-current-profile'.
  1367. Interactively with prefix, prompt for PROFILE."
  1368. (interactive
  1369. (list (guix-read-package-location-file)
  1370. (guix-ui-read-package-profile)))
  1371. (guix-package-get-display profile 'location location))
  1372. ;;;###autoload
  1373. (defun guix-package-from-file (file &optional profile)
  1374. "Display Guix package that the code from FILE evaluates to.
  1375. If PROFILE is nil, use `guix-current-profile'.
  1376. Interactively prompt for FILE (see also `guix-support-dired').
  1377. With prefix argument, prompt for PROFILE as well."
  1378. (interactive
  1379. (list (guix-read-file-name-maybe "File with package: ")
  1380. (guix-ui-read-package-profile)))
  1381. (bui-get-display-entries
  1382. 'guix-package 'info
  1383. (list (or profile guix-current-profile) 'from-file file)
  1384. 'add))
  1385. ;;;###autoload
  1386. (defun guix-packages-from-system-config-file (file &optional profile)
  1387. "Display Guix packages from the operating system configuration FILE.
  1388. Make sure FILE has a proper 'operating-system' declaration. You
  1389. may check it, for example, by running the following shell command:
  1390. guix system build --dry-run FILE
  1391. See also Info node `(guix) System Configuration'.
  1392. If PROFILE is nil, use system profile (it is used to show what
  1393. packages from FILE are installed in PROFILE).
  1394. Interactively, prompt for FILE (see also `guix-support-dired').
  1395. With prefix argument, prompt for PROFILE as well.
  1396. Note: This command displays only those packages that are placed
  1397. in 'packages' field of the 'operating-system' declaration. An
  1398. installed system also contains packages installed by
  1399. services (like 'guix' or 'shepherd'). To see all the packages
  1400. installed in a system profile, use
  1401. '\\[guix-installed-system-packages]' command."
  1402. (interactive
  1403. (list (guix-read-os-file-name)
  1404. (and current-prefix-arg
  1405. (guix-read-package-profile guix-system-profile))))
  1406. (guix-package-get-display (or profile guix-system-profile)
  1407. 'from-os-file file))
  1408. ;;;###autoload
  1409. (defun guix-search-by-regexp (regexp &optional params profile)
  1410. "Search for Guix packages by REGEXP.
  1411. PARAMS are package parameters that should be searched.
  1412. If PARAMS are not specified, use `guix-package-search-params'.
  1413. If PROFILE is nil, use `guix-current-profile'.
  1414. Interactively with prefix, prompt for PROFILE."
  1415. (interactive
  1416. (list (read-regexp "Regexp: " nil 'guix-package-search-history)
  1417. nil (guix-ui-read-package-profile)))
  1418. (guix-package-get-display profile 'regexp regexp
  1419. (or params guix-package-search-params)))
  1420. ;;;###autoload
  1421. (defun guix-search-by-name (regexp &optional profile)
  1422. "Search for Guix packages matching REGEXP in a package name.
  1423. If PROFILE is nil, use `guix-current-profile'.
  1424. Interactively with prefix, prompt for PROFILE."
  1425. (interactive
  1426. (list (read-string "Package name by regexp: "
  1427. nil 'guix-package-search-history)
  1428. (guix-ui-read-package-profile)))
  1429. (guix-search-by-regexp regexp '(name) profile))
  1430. ;;;###autoload
  1431. (defun guix-installed-packages (&optional profile)
  1432. "Display information about installed Guix packages.
  1433. If PROFILE is nil, use `guix-current-profile'.
  1434. Interactively with prefix, prompt for PROFILE."
  1435. (interactive (list (guix-ui-read-package-profile)))
  1436. (guix-package-get-display profile 'installed))
  1437. ;;;###autoload
  1438. (defun guix-installed-user-packages ()
  1439. "Display information about Guix packages installed in a user profile."
  1440. (interactive)
  1441. (guix-installed-packages guix-user-profile))
  1442. ;;;###autoload
  1443. (defun guix-installed-system-packages ()
  1444. "Display information about Guix packages installed in a system profile."
  1445. (interactive)
  1446. (guix-installed-packages guix-system-profile))
  1447. ;;;###autoload
  1448. (defun guix-obsolete-packages (&optional profile)
  1449. "Display information about obsolete (or unknown) Guix packages.
  1450. If PROFILE is nil, use `guix-current-profile'.
  1451. Interactively with prefix, prompt for PROFILE."
  1452. (interactive (list (guix-ui-read-package-profile)))
  1453. (guix-package-get-display profile 'unknown))
  1454. ;;;###autoload
  1455. (defun guix-superseded-packages (&optional profile)
  1456. "Display information about superseded Guix packages.
  1457. If PROFILE is nil, use `guix-current-profile'.
  1458. Interactively with prefix, prompt for PROFILE."
  1459. (interactive (list (guix-ui-read-package-profile)))
  1460. (guix-package-get-display profile 'superseded))
  1461. (defun guix-read-package-dependent-type ()
  1462. "Prompt a user for a type of dependent packages."
  1463. (intern
  1464. (completing-read "Dependency type (\"all\" or \"direct\"): "
  1465. '("all" "direct")
  1466. nil t nil nil "all")))
  1467. ;;;###autoload
  1468. (defun guix-dependent-packages (packages &optional type profile)
  1469. "Display Guix packages that depend on PACKAGES.
  1470. This is similar to 'guix refresh --list-dependent PACKAGES ...'.
  1471. See Info node `(guix) Invoking guix refresh' for details.
  1472. TYPE should be a symbol `all' or `direct'. Interactively, prompt
  1473. for it.
  1474. If PROFILE is nil, use `guix-current-profile'.
  1475. Interactively with prefix, prompt for PROFILE."
  1476. (interactive
  1477. (list (guix-read-package-names)
  1478. (guix-read-package-dependent-type)
  1479. (guix-ui-read-package-profile)))
  1480. (guix-package-get-display profile 'dependent (or type 'all) packages))
  1481. ;;;###autoload
  1482. (defun guix-hidden-packages (&optional profile)
  1483. "Display hidden Guix packages.
  1484. If PROFILE is nil, use `guix-current-profile'."
  1485. (interactive (list (guix-ui-read-package-profile)))
  1486. (guix-package-get-display profile 'hidden))
  1487. ;;;###autoload
  1488. (defun guix-all-packages (&optional profile)
  1489. "Display all available Guix packages.
  1490. If PROFILE is nil, use `guix-current-profile'.
  1491. Interactively with prefix, prompt for PROFILE."
  1492. (interactive (list (guix-ui-read-package-profile)))
  1493. (guix-package-get-display profile 'all))
  1494. ;;;###autoload
  1495. (define-obsolete-function-alias 'guix-newest-packages
  1496. 'guix-all-packages "0.5.2")
  1497. ;;;###autoload
  1498. (defun guix-number-of-packages ()
  1499. "Display the number of available Guix packages.
  1500. This number includes the packages from GUIX_PACKAGE_PATH (see
  1501. Info node `(guix) Package Modules')."
  1502. (interactive)
  1503. (message "Total number of Guix packages: %d."
  1504. (guix-eval-read "(number-of-packages)")))
  1505. (provide 'guix-ui-package)
  1506. ;;; guix-ui-package.el ends here