profile.scm
1 | ;;; Guix Home Manager. |
2 | ;;; |
3 | ;;; Copyright © 2020 Jelle Licht <jlicht@fsfe.org> |
4 | ;;; |
5 | ;;; This program is free software: you can redistribute it and/or modify |
6 | ;;; it under the terms of the GNU General Public License as published by |
7 | ;;; the Free Software Foundation, either version 3 of the License, or |
8 | ;;; (at your option) any later version. |
9 | ;;; |
10 | ;;; This program is distributed in the hope that it will be useful, |
11 | ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | ;;; GNU General Public License for more details. |
14 | ;;; |
15 | ;;; You should have received a copy of the GNU General Public License |
16 | ;;; along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | |
18 | (define-module (home profile) |
19 | #:use-module (guix profiles) |
20 | #:use-module (guix gexp) |
21 | #:use-module (srfi srfi-1) |
22 | #:use-module (ice-9 match) |
23 | #:use-module (home) |
24 | #:export (package-profile-home-type |
25 | source-profile)) |
26 | |
27 | (define (packages->profile-entry packages) |
28 | "Return an entry for the profile containing PACKAGES." |
29 | `((".home-profile" ,(profile |
30 | (content (packages->manifest |
31 | (delete-duplicates packages eq?))))))) |
32 | |
33 | (define* (source-profile #:optional (profile-path ".home-profile")) |
34 | "Returns a string that can be added to either `.bash_profile` or |
35 | `.zprofile` that sources guix profile PROFILE-PATH, making the |
36 | contained packages available to the shell. Defaults to sourcing the |
37 | guix profile in \"$HOME/.home-profile\"." |
38 | (apply format #f "if [ -f ~s/etc/profile ]; then |
39 | GUIX_PROFILE=~s ; . ~s/etc/profile |
40 | export MANPATH=~s/share/man:$MANPATH |
41 | export INFOPATH=~s/share/info:$INFOPATH |
42 | export XDG_DATA_DIRS=~s/share:$XDG_DATA_DIRS |
43 | export XDG_CONFIG_DIRS=~s/etc/xdg:$XDG_CONFIG_DIRS |
44 | fi\n" |
45 | (make-list 7 profile-path))) |
46 | |
47 | (define package-profile-home-type |
48 | (home-type |
49 | (name 'profile) |
50 | (extension-points |
51 | (list (home-extension-point |
52 | (compose concatenate) |
53 | (extend (lambda (v l) |
54 | (apply append v l)))))) |
55 | (extensions |
56 | (list |
57 | (home-extension |
58 | (target root-home-type) |
59 | (compute packages->profile-entry)))) |
60 | (default-value '()) |
61 | (description "The package-profile home type"))) |
62 |