1 ;;; guix.el --- Interface for GNU Guix package manager
3 ;; Copyright © 2014 Alex Kost <alezost@gmail.com>
5 ;; Package-Requires: ((geiser "0.3"))
8 ;; This file is part of GNU Guix.
10 ;; GNU Guix is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation, either version 3 of the License, or
13 ;; (at your option) any later version.
15 ;; GNU Guix is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with this program. If not, see <http://www.gnu.org/licenses/>.
25 ;; This package provides an interface for searching, listing and getting
26 ;; information about Guix packages and generations; and for
27 ;; installing/upgrading/removing packages.
37 "Interface for Guix package manager."
41 (defcustom guix-list-single-package nil
42 "If non-nil, list a package even if it is the only matching result.
43 If nil, show a single package in the info buffer."
47 (defvar guix-search-params
'(name synopsis description
)
48 "Default list of package parameters for searching by regexp.")
50 (defvar guix-search-history nil
51 "A history of minibuffer prompts.")
53 (defun guix-get-show-packages (profile search-type
&rest search-vals
)
54 "Search for packages and show results.
56 If PROFILE is nil, use `guix-current-profile'.
58 See `guix-get-entries' for the meaning of SEARCH-TYPE and
61 Results are displayed in the list buffer, unless a single package
62 is found and `guix-list-single-package' is nil."
63 (or profile
(setq profile guix-current-profile
))
64 (let ((packages (guix-get-entries profile guix-package-list-type
65 search-type search-vals
66 (guix-get-params-for-receiving
67 'list guix-package-list-type
))))
68 (if (or guix-list-single-package
70 (guix-set-buffer profile packages
'list guix-package-list-type
71 search-type search-vals
)
72 (let ((packages (guix-get-entries profile guix-package-info-type
73 search-type search-vals
74 (guix-get-params-for-receiving
75 'info guix-package-info-type
))))
76 (guix-set-buffer profile packages
'info guix-package-info-type
77 search-type search-vals
)))))
79 (defun guix-get-show-generations (profile search-type
&rest search-vals
)
80 "Search for generations and show results.
82 If PROFILE is nil, use `guix-current-profile'.
84 See `guix-get-entries' for the meaning of SEARCH-TYPE and
86 (apply #'guix-get-show-entries
87 (or profile guix-current-profile
)
88 'list
'generation search-type search-vals
))
91 (defun guix-search-by-name (name &optional profile
)
92 "Search for Guix packages by NAME.
93 NAME is a string with name specification. It may optionally contain
94 a version number. Examples: \"guile\", \"guile-2.0.11\".
96 If PROFILE is nil, use `guix-current-profile'.
97 Interactively with prefix, prompt for PROFILE."
99 (list (read-string "Package name: " nil
'guix-search-history
)
100 (and current-prefix-arg
101 (guix-profile-prompt))))
102 (guix-get-show-packages profile
'name name
))
105 (defun guix-search-by-regexp (regexp &optional params profile
)
106 "Search for Guix packages by REGEXP.
107 PARAMS are package parameters that should be searched.
108 If PARAMS are not specified, use `guix-search-params'.
110 If PROFILE is nil, use `guix-current-profile'.
111 Interactively with prefix, prompt for PROFILE."
113 (list (read-regexp "Regexp: " nil
'guix-search-history
)
115 (and current-prefix-arg
116 (guix-profile-prompt))))
117 (guix-get-show-packages profile
'regexp regexp
118 (or params guix-search-params
)))
121 (defun guix-installed-packages (&optional profile
)
122 "Display information about installed Guix packages.
123 If PROFILE is nil, use `guix-current-profile'.
124 Interactively with prefix, prompt for PROFILE."
126 (list (and current-prefix-arg
127 (guix-profile-prompt))))
128 (guix-get-show-packages profile
'installed
))
131 (defun guix-obsolete-packages (&optional profile
)
132 "Display information about obsolete Guix packages.
133 If PROFILE is nil, use `guix-current-profile'.
134 Interactively with prefix, prompt for PROFILE."
136 (list (and current-prefix-arg
137 (guix-profile-prompt))))
138 (guix-get-show-packages profile
'obsolete
))
141 (defun guix-all-available-packages (&optional profile
)
142 "Display information about all available Guix packages.
143 If PROFILE is nil, use `guix-current-profile'.
144 Interactively with prefix, prompt for PROFILE."
146 (list (and current-prefix-arg
147 (guix-profile-prompt))))
148 (guix-get-show-packages profile
'all-available
))
151 (defun guix-newest-available-packages (&optional profile
)
152 "Display information about the newest available Guix packages.
153 If PROFILE is nil, use `guix-current-profile'.
154 Interactively with prefix, prompt for PROFILE."
156 (list (and current-prefix-arg
157 (guix-profile-prompt))))
158 (guix-get-show-packages profile
'newest-available
))
161 (defun guix-generations (&optional profile
)
162 "Display information about all generations.
163 If PROFILE is nil, use `guix-current-profile'.
164 Interactively with prefix, prompt for PROFILE."
166 (list (and current-prefix-arg
167 (guix-profile-prompt))))
168 (guix-get-show-generations profile
'all
))
171 (defun guix-last-generations (number &optional profile
)
172 "Display information about last NUMBER generations.
173 If PROFILE is nil, use `guix-current-profile'.
174 Interactively with prefix, prompt for PROFILE."
176 (list (read-number "The number of last generations: ")
177 (and current-prefix-arg
178 (guix-profile-prompt))))
179 (guix-get-show-generations profile
'last number
))
182 (defun guix-generations-by-time (from to
&optional profile
)
183 "Display information about generations created between FROM and TO.
184 FROM and TO should be time values.
185 If PROFILE is nil, use `guix-current-profile'.
186 Interactively with prefix, prompt for PROFILE."
188 (list (guix-read-date "Find generations (from): ")
189 (guix-read-date "Find generations (to): ")
190 (and current-prefix-arg
191 (guix-profile-prompt))))
192 (guix-get-show-generations profile
'time
198 ;;; guix.el ends here