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