1 ;;; guix.el --- Interface for GNU Guix package manager
3 ;; Copyright © 2014, 2015 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.
38 "Interface for Guix package manager."
42 (defgroup guix-faces nil
47 (defcustom guix-list-single-package nil
48 "If non-nil, list a package even if it is the only matching result.
49 If nil, show a single package in the info buffer."
53 (defvar guix-search-params
'(name synopsis description
)
54 "Default list of package parameters for searching by regexp.")
56 (defvar guix-search-history nil
57 "A history of minibuffer prompts.")
59 (defun guix-get-show-packages (profile search-type
&rest search-vals
)
60 "Search for packages and show results.
62 If PROFILE is nil, use `guix-current-profile'.
64 See `guix-get-entries' for the meaning of SEARCH-TYPE and
67 Results are displayed in the list buffer, unless a single package
68 is found and `guix-list-single-package' is nil."
69 (or profile
(setq profile guix-current-profile
))
70 (let ((packages (guix-get-entries profile guix-package-list-type
71 search-type search-vals
72 (guix-get-params-for-receiving
73 'list guix-package-list-type
))))
74 (if (or guix-list-single-package
76 (guix-set-buffer profile packages
'list guix-package-list-type
77 search-type search-vals
)
78 (let ((packages (guix-get-entries profile guix-package-info-type
79 search-type search-vals
80 (guix-get-params-for-receiving
81 'info guix-package-info-type
))))
82 (guix-set-buffer profile packages
'info guix-package-info-type
83 search-type search-vals
)))))
85 (defun guix-get-show-generations (profile search-type
&rest search-vals
)
86 "Search for generations and show results.
88 If PROFILE is nil, use `guix-current-profile'.
90 See `guix-get-entries' for the meaning of SEARCH-TYPE and
92 (apply #'guix-get-show-entries
93 (or profile guix-current-profile
)
94 'list
'generation search-type search-vals
))
97 (defun guix-search-by-name (name &optional profile
)
98 "Search for Guix packages by NAME.
99 NAME is a string with name specification. It may optionally contain
100 a version number. Examples: \"guile\", \"guile-2.0.11\".
102 If PROFILE is nil, use `guix-current-profile'.
103 Interactively with prefix, prompt for PROFILE."
105 (list (read-string "Package name: " nil
'guix-search-history
)
106 (and current-prefix-arg
107 (guix-profile-prompt))))
108 (guix-get-show-packages profile
'name name
))
111 (defun guix-search-by-regexp (regexp &optional params profile
)
112 "Search for Guix packages by REGEXP.
113 PARAMS are package parameters that should be searched.
114 If PARAMS are not specified, use `guix-search-params'.
116 If PROFILE is nil, use `guix-current-profile'.
117 Interactively with prefix, prompt for PROFILE."
119 (list (read-regexp "Regexp: " nil
'guix-search-history
)
121 (and current-prefix-arg
122 (guix-profile-prompt))))
123 (guix-get-show-packages profile
'regexp regexp
124 (or params guix-search-params
)))
127 (defun guix-installed-packages (&optional profile
)
128 "Display information about installed Guix packages.
129 If PROFILE is nil, use `guix-current-profile'.
130 Interactively with prefix, prompt for PROFILE."
132 (list (and current-prefix-arg
133 (guix-profile-prompt))))
134 (guix-get-show-packages profile
'installed
))
137 (defun guix-obsolete-packages (&optional profile
)
138 "Display information about obsolete Guix packages.
139 If PROFILE is nil, use `guix-current-profile'.
140 Interactively with prefix, prompt for PROFILE."
142 (list (and current-prefix-arg
143 (guix-profile-prompt))))
144 (guix-get-show-packages profile
'obsolete
))
147 (defun guix-all-available-packages (&optional profile
)
148 "Display information about all available Guix packages.
149 If PROFILE is nil, use `guix-current-profile'.
150 Interactively with prefix, prompt for PROFILE."
152 (list (and current-prefix-arg
153 (guix-profile-prompt))))
154 (guix-get-show-packages profile
'all-available
))
157 (defun guix-newest-available-packages (&optional profile
)
158 "Display information about the newest available Guix packages.
159 If PROFILE is nil, use `guix-current-profile'.
160 Interactively with prefix, prompt for PROFILE."
162 (list (and current-prefix-arg
163 (guix-profile-prompt))))
164 (guix-get-show-packages profile
'newest-available
))
167 (defun guix-generations (&optional profile
)
168 "Display information about all generations.
169 If PROFILE is nil, use `guix-current-profile'.
170 Interactively with prefix, prompt for PROFILE."
172 (list (and current-prefix-arg
173 (guix-profile-prompt))))
174 (guix-get-show-generations profile
'all
))
177 (defun guix-last-generations (number &optional profile
)
178 "Display information about last NUMBER generations.
179 If PROFILE is nil, use `guix-current-profile'.
180 Interactively with prefix, prompt for PROFILE."
182 (list (read-number "The number of last generations: ")
183 (and current-prefix-arg
184 (guix-profile-prompt))))
185 (guix-get-show-generations profile
'last number
))
188 (defun guix-generations-by-time (from to
&optional profile
)
189 "Display information about generations created between FROM and TO.
190 FROM and TO should be time values.
191 If PROFILE is nil, use `guix-current-profile'.
192 Interactively with prefix, prompt for PROFILE."
194 (list (guix-read-date "Find generations (from): ")
195 (guix-read-date "Find generations (to): ")
196 (and current-prefix-arg
197 (guix-profile-prompt))))
198 (guix-get-show-generations profile
'time
203 (defun guix-edit (id-or-name)
204 "Edit (go to location of) package with ID-OR-NAME."
205 (interactive (list (guix-read-package-name)))
206 (let ((loc (guix-package-location id-or-name
)))
208 (guix-find-location loc
)
209 (message "Couldn't find package location."))))
213 ;;; guix.el ends here