emacs: Add support for "triplet" package inputs.
[jackhill/guix/guix.git] / emacs / guix-profiles.el
CommitLineData
3db349cb
AK
1;;; guix-profiles.el --- Guix profiles
2
3;; Copyright © 2014 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;;; Code:
21
bd6163d1
ML
22(require 'guix-config)
23
3db349cb
AK
24(defvar guix-user-profile
25 (expand-file-name "~/.guix-profile")
26 "User profile.")
27
28(defvar guix-default-profile
bd6163d1 29 (concat guix-state-directory
3db349cb
AK
30 "/profiles/per-user/"
31 (getenv "USER")
32 "/guix-profile")
33 "Default Guix profile.")
34
35(defvar guix-current-profile guix-default-profile
36 "Current profile.")
37
38(defun guix-profile-prompt (&optional default)
39 "Prompt for profile and return it.
40Use 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)))
49
50(defun guix-set-current-profile (path)
51 "Set `guix-current-profile' to PATH.
52Interactively, 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))
61
62(provide 'guix-profiles)
63
64;;; guix-profiles.el ends here