import: cran: Avoid HTTP redirect.
[guix.git] / emacs / guix-profiles.el
blob2c1936864ff33116aa0711997a0ae727c5b46b23
1 ;;; guix-profiles.el --- Guix profiles
3 ;; Copyright © 2014 Alex Kost <alezost@gmail.com>
5 ;; This file is part of GNU Guix.
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.
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.
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/>.
20 ;;; Code:
22 (require 'guix-config)
24 (defvar guix-user-profile
25 (expand-file-name "~/.guix-profile")
26 "User profile.")
28 (defvar guix-default-profile
29 (concat guix-config-state-directory
30 "/profiles/per-user/"
31 (getenv "USER")
32 "/guix-profile")
33 "Default Guix profile.")
35 (defvar guix-current-profile guix-default-profile
36 "Current profile.")
38 (defun guix-profile-prompt (&optional default)
39 "Prompt for profile and return it.
40 Use DEFAULT as a start directory. If it is nil, use
41 `guix-current-profile'."
42 (let* ((path (read-file-name "Profile: "
43 (file-name-directory
44 (or default guix-current-profile))))
45 (path (directory-file-name (expand-file-name path))))
46 (if (string= path guix-user-profile)
47 guix-default-profile
48 path)))
50 (defun guix-set-current-profile (path)
51 "Set `guix-current-profile' to PATH.
52 Interactively, prompt for PATH. With prefix, use
53 `guix-default-profile'."
54 (interactive
55 (list (if current-prefix-arg
56 guix-default-profile
57 (guix-profile-prompt))))
58 (setq guix-current-profile path)
59 (message "Current profile has been set to '%s'."
60 guix-current-profile))
62 (provide 'guix-profiles)
64 ;;; guix-profiles.el ends here