1 ;;; guix-profiles.el --- Guix profiles
3 ;; Copyright © 2014, 2015, 2016 Alex Kost <alezost@gmail.com>
4 ;; Copyright © 2015 Mathieu Lirzin <mthl@openmailbox.org>
6 ;; This file is part of GNU Guix.
8 ;; GNU Guix is free software; you can redistribute it and/or modify
9 ;; it under the terms of the GNU General Public License as published by
10 ;; the Free Software Foundation, either version 3 of the License, or
11 ;; (at your option) any later version.
13 ;; GNU Guix is distributed in the hope that it will be useful,
14 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 ;; GNU General Public License for more details.
18 ;; You should have received a copy of the GNU General Public License
19 ;; along with this program. If not, see <http://www.gnu.org/licenses/>.
23 (require 'guix-config
)
25 (defvar guix-user-profile
26 (expand-file-name "~/.guix-profile")
29 (defvar guix-system-profile
30 (concat guix-config-state-directory
"/profiles/system")
33 (defvar guix-default-profile
34 (concat guix-config-state-directory
38 "Default Guix profile.")
40 (defvar guix-current-profile guix-default-profile
43 (defvar guix-system-profile-regexp
44 (concat "\\`" (regexp-quote guix-system-profile
))
45 "Regexp matching system profiles.")
47 (defun guix-system-profile?
(profile)
48 "Return non-nil, if PROFILE is a system one."
49 (string-match-p guix-system-profile-regexp profile
))
51 (defun guix-profile-prompt (&optional default
)
52 "Prompt for profile and return it.
53 Use DEFAULT as a start directory. If it is nil, use
54 `guix-current-profile'."
55 (let* ((path (read-file-name "Profile: "
57 (or default guix-current-profile
))))
58 (path (directory-file-name (expand-file-name path
))))
59 (if (string= path guix-user-profile
)
63 (defun guix-set-current-profile (path)
64 "Set `guix-current-profile' to PATH.
65 Interactively, prompt for PATH. With prefix, use
66 `guix-default-profile'."
68 (list (if current-prefix-arg
70 (guix-profile-prompt))))
71 (setq guix-current-profile path
)
72 (message "Current profile has been set to '%s'."
73 guix-current-profile
))
75 (provide 'guix-profiles
)
77 ;;; guix-profiles.el ends here