Commit | Line | Data |
---|---|---|
7fcc6425 AT |
1 | ;;; GNU Guix --- Functional package management for GNU |
2 | ;;; Copyright © 2021 Andrew Tropin <andrew@trop.in> | |
3 | ;;; | |
4 | ;;; This file is part of GNU Guix. | |
5 | ;;; | |
6 | ;;; GNU Guix is free software; you can redistribute it and/or modify it | |
7 | ;;; under the terms of the GNU General Public License as published by | |
8 | ;;; the Free Software Foundation; either version 3 of the License, or (at | |
9 | ;;; your option) any later version. | |
10 | ;;; | |
11 | ;;; GNU Guix is distributed in the hope that it will be useful, but | |
12 | ;;; WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | ;;; GNU General Public License for more details. | |
15 | ;;; | |
16 | ;;; You should have received a copy of the GNU General Public License | |
17 | ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. | |
18 | ||
19 | (define-module (gnu home) | |
0e8d2df0 | 20 | #:use-module (gnu home services) |
ba8ddb34 OP |
21 | #:use-module (gnu home services symlink-manager) |
22 | #:use-module (gnu home services shells) | |
23 | #:use-module (gnu home services xdg) | |
24 | #:use-module (gnu home services fontutils) | |
7fcc6425 AT |
25 | #:use-module (gnu services) |
26 | #:use-module (guix records) | |
27 | #:use-module (guix diagnostics) | |
ed818c66 AT |
28 | #:use-module (guix gexp) |
29 | #:use-module (guix store) | |
7fcc6425 AT |
30 | |
31 | #:export (home-environment | |
32 | home-environment? | |
33 | this-home-environment | |
34 | ||
35 | home-environment-derivation | |
36 | home-environment-user-services | |
37 | home-environment-essential-services | |
38 | home-environment-services | |
39 | home-environment-location | |
40 | ||
41 | home-environment-with-provenance)) | |
42 | ||
994c66bf AT |
43 | ;;; Comment: |
44 | ;;; | |
45 | ;;; This module provides a <home-environment> record for managing | |
46 | ;;; per-user packages and configuration files in the similar way as | |
47 | ;;; <operating-system> do for system packages and configuration files. | |
48 | ;;; | |
49 | ;;; Code: | |
50 | ||
7fcc6425 AT |
51 | (define-record-type* <home-environment> home-environment |
52 | make-home-environment | |
53 | home-environment? | |
54 | this-home-environment | |
55 | ||
56 | (packages home-environment-packages ; list of (PACKAGE OUTPUT...) | |
57 | (default '())) | |
58 | ||
59 | (essential-services home-environment-essential-services ; list of services | |
60 | (thunked) | |
61 | (default (home-environment-default-essential-services | |
62 | this-home-environment))) | |
63 | ||
64 | (services home-environment-user-services | |
65 | (default '())) | |
66 | ||
67 | (location home-environment-location ; <location> | |
68 | (default (and=> (current-source-location) | |
69 | source-properties->location)) | |
70 | (innate))) | |
71 | ||
72 | (define (home-environment-default-essential-services he) | |
73 | "Return the list of essential services for home environment." | |
74 | (list | |
75 | (service home-run-on-first-login-service-type) | |
76 | (service home-activation-service-type) | |
77 | (service home-environment-variables-service-type) | |
78 | ||
79 | (service home-symlink-manager-service-type) | |
80 | ||
81 | (service home-fontconfig-service-type) | |
82 | (service home-xdg-base-directories-service-type) | |
83 | (service home-shell-profile-service-type) | |
84 | ||
85 | (service home-service-type) | |
86 | (service home-profile-service-type (home-environment-packages he)))) | |
87 | ||
88 | (define* (home-environment-services he) | |
89 | "Return all the services of home environment." | |
90 | (instantiate-missing-services | |
91 | (append (home-environment-user-services he) | |
92 | (home-environment-essential-services he)))) | |
93 | ||
94 | (define* (home-environment-derivation he) | |
95 | "Return a derivation that builds OS." | |
96 | (let* ((services (home-environment-services he)) | |
97 | (home (fold-services services | |
98 | #:target-type home-service-type))) | |
99 | (service-value home))) | |
100 | ||
101 | (define* (home-environment-with-provenance he config-file) | |
102 | "Return a variant of HE that stores its own provenance information, | |
103 | including CONFIG-FILE, if available. This is achieved by adding an instance | |
104 | of HOME-PROVENANCE-SERVICE-TYPE to its services." | |
105 | (home-environment | |
106 | (inherit he) | |
107 | (services (cons (service home-provenance-service-type config-file) | |
108 | (home-environment-user-services he))))) | |
ed818c66 AT |
109 | |
110 | (define-gexp-compiler (home-environment-compiler (he <home-environment>) | |
111 | system target) | |
112 | ((store-lift | |
113 | (lambda (store) | |
114 | (run-with-store store (home-environment-derivation he) | |
115 | #:system system | |
116 | #:target target))))) |