diff options
| author | Andrew Tropin <andrew@trop.in> | 2021-08-27 10:07:35 +0300 |
|---|---|---|
| committer | Oleg Pykhalov <go.wigust@gmail.com> | 2021-09-09 20:26:50 +0300 |
| commit | 7fcc64253c2c48fee96f7925453161eb2b3a709e (patch) | |
| tree | e8bc7d26d3055b4d31f48bd5b9664178921ad43f /gnu/home.scm | |
| parent | a9214267af27901d59a301bc412d2cb96dc20775 (diff) | |
home: Add home-environment.
* gnu/home.scm
(home-environment, home-environment?, this-home-environment)
(home-environment-derivation, home-environment-user-services)
(home-environment-essential-services, home-environment-services)
(home-environment-location, home-environment-with-provenance): New variables.
* gnu/local.mk (GNU_SYSTEM_MODULES): Add home.scm.
Signed-off-by: Oleg Pykhalov <go.wigust@gmail.com>
Diffstat (limited to 'gnu/home.scm')
| -rw-r--r-- | gnu/home.scm | 98 |
1 files changed, 98 insertions, 0 deletions
diff --git a/gnu/home.scm b/gnu/home.scm new file mode 100644 index 00000000000..a53d27163d9 --- /dev/null +++ b/gnu/home.scm | |||
| @@ -0,0 +1,98 @@ | |||
| 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) | ||
| 20 | #:use-module (gnu home-services) | ||
| 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) | ||
| 25 | #:use-module (gnu services) | ||
| 26 | #:use-module (guix records) | ||
| 27 | #:use-module (guix diagnostics) | ||
| 28 | |||
| 29 | #:export (home-environment | ||
| 30 | home-environment? | ||
| 31 | this-home-environment | ||
| 32 | |||
| 33 | home-environment-derivation | ||
| 34 | home-environment-user-services | ||
| 35 | home-environment-essential-services | ||
| 36 | home-environment-services | ||
| 37 | home-environment-location | ||
| 38 | |||
| 39 | home-environment-with-provenance)) | ||
| 40 | |||
| 41 | (define-record-type* <home-environment> home-environment | ||
| 42 | make-home-environment | ||
| 43 | home-environment? | ||
| 44 | this-home-environment | ||
| 45 | |||
| 46 | (packages home-environment-packages ; list of (PACKAGE OUTPUT...) | ||
| 47 | (default '())) | ||
| 48 | |||
| 49 | (essential-services home-environment-essential-services ; list of services | ||
| 50 | (thunked) | ||
| 51 | (default (home-environment-default-essential-services | ||
| 52 | this-home-environment))) | ||
| 53 | |||
| 54 | (services home-environment-user-services | ||
| 55 | (default '())) | ||
| 56 | |||
| 57 | (location home-environment-location ; <location> | ||
| 58 | (default (and=> (current-source-location) | ||
| 59 | source-properties->location)) | ||
| 60 | (innate))) | ||
| 61 | |||
| 62 | (define (home-environment-default-essential-services he) | ||
| 63 | "Return the list of essential services for home environment." | ||
| 64 | (list | ||
| 65 | (service home-run-on-first-login-service-type) | ||
| 66 | (service home-activation-service-type) | ||
| 67 | (service home-environment-variables-service-type) | ||
| 68 | |||
| 69 | (service home-symlink-manager-service-type) | ||
| 70 | |||
| 71 | (service home-fontconfig-service-type) | ||
| 72 | (service home-xdg-base-directories-service-type) | ||
| 73 | (service home-shell-profile-service-type) | ||
| 74 | |||
| 75 | (service home-service-type) | ||
| 76 | (service home-profile-service-type (home-environment-packages he)))) | ||
| 77 | |||
| 78 | (define* (home-environment-services he) | ||
| 79 | "Return all the services of home environment." | ||
| 80 | (instantiate-missing-services | ||
| 81 | (append (home-environment-user-services he) | ||
| 82 | (home-environment-essential-services he)))) | ||
| 83 | |||
| 84 | (define* (home-environment-derivation he) | ||
| 85 | "Return a derivation that builds OS." | ||
| 86 | (let* ((services (home-environment-services he)) | ||
| 87 | (home (fold-services services | ||
| 88 | #:target-type home-service-type))) | ||
| 89 | (service-value home))) | ||
| 90 | |||
| 91 | (define* (home-environment-with-provenance he config-file) | ||
| 92 | "Return a variant of HE that stores its own provenance information, | ||
| 93 | including CONFIG-FILE, if available. This is achieved by adding an instance | ||
| 94 | of HOME-PROVENANCE-SERVICE-TYPE to its services." | ||
| 95 | (home-environment | ||
| 96 | (inherit he) | ||
| 97 | (services (cons (service home-provenance-service-type config-file) | ||
| 98 | (home-environment-user-services he))))) | ||
