home: Add package profile home type.

Jelle LichtFri Nov 27 15:46:55+0100 2020

7567a9b

home: Add package profile home type. * home/profile.scm: New file. * doc/profile.md: New file. * doc/README.md: Add it. Signed-off-by: Julien Lepiller <julien@lepiller.eu>

doc/README.md

7171
7272
* [Provenance](doc/provenance.md)
7373
74+
### Package management
75+
76+
* [Guix profiles](doc/profile.md)
77+
7478
### Common Issues
7579
7680
#### No Sound on the System

doc/profile.md unknown status 1

1+
Profile
2+
======
3+
4+
This allows users and home-types to install guix packages into guix
5+
package profiles in your immutable home directory.
6+
7+
Main Configuration
8+
------------------
9+
10+
Profile are configured by using the `package-profile-home-type` service type.
11+
12+
**Scheme Variable**: package-profile-home-type
13+
14+
The type of service that generates a guix package profile. Its value
15+
is a list of guix packages.
16+
17+
**Scheme Procedure**: (source-profile [profile-path])
18+
19+
Returns a string that can be added to either `.bash_profile` or
20+
`.zprofile` that sources guix profile _profile-path_, making the
21+
contained packages available to the shell. Defaults to sourcing the
22+
guix profile in `$HOME/.home-profile`.
23+
24+
25+
Example Configuration
26+
---------------------
27+
28+
```scheme
29+
(use-modules (gnu packages emacs))
30+
31+
(user-home
32+
  package-profile-home-type
33+
  (list emacs))
34+
```

home/profile.scm unknown status 1

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")))