home.scm 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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. (define-module (gnu home)
  19. #:use-module (gnu home services)
  20. #:use-module (gnu home services symlink-manager)
  21. #:use-module (gnu home services shells)
  22. #:use-module (gnu home services xdg)
  23. #:use-module (gnu home services fontutils)
  24. #:use-module (gnu services)
  25. #:use-module (guix records)
  26. #:use-module (guix diagnostics)
  27. #:use-module (guix gexp)
  28. #:use-module (guix store)
  29. #:export (home-environment
  30. home-environment?
  31. this-home-environment
  32. home-environment-derivation
  33. home-environment-user-services
  34. home-environment-essential-services
  35. home-environment-services
  36. home-environment-location
  37. home-environment-with-provenance))
  38. ;;; Comment:
  39. ;;;
  40. ;;; This module provides a <home-environment> record for managing
  41. ;;; per-user packages and configuration files in the similar way as
  42. ;;; <operating-system> do for system packages and configuration files.
  43. ;;;
  44. ;;; Code:
  45. (define-record-type* <home-environment> home-environment
  46. make-home-environment
  47. home-environment?
  48. this-home-environment
  49. (packages home-environment-packages ; list of (PACKAGE OUTPUT...)
  50. (default '()))
  51. (essential-services home-environment-essential-services ; list of services
  52. (thunked)
  53. (default (home-environment-default-essential-services
  54. this-home-environment)))
  55. (services home-environment-user-services
  56. (default '()))
  57. (location home-environment-location ; <location>
  58. (default (and=> (current-source-location)
  59. source-properties->location))
  60. (innate)))
  61. (define (home-environment-default-essential-services he)
  62. "Return the list of essential services for home environment."
  63. (list
  64. (service home-run-on-first-login-service-type)
  65. (service home-activation-service-type)
  66. (service home-environment-variables-service-type)
  67. (service home-symlink-manager-service-type)
  68. (service home-fontconfig-service-type)
  69. (service home-xdg-base-directories-service-type)
  70. (service home-shell-profile-service-type)
  71. (service home-service-type)
  72. (service home-profile-service-type (home-environment-packages he))))
  73. (define* (home-environment-services he)
  74. "Return all the services of home environment."
  75. (instantiate-missing-services
  76. (append (home-environment-user-services he)
  77. (home-environment-essential-services he))))
  78. (define* (home-environment-derivation he)
  79. "Return a derivation that builds OS."
  80. (let* ((services (home-environment-services he))
  81. (home (fold-services services
  82. #:target-type home-service-type)))
  83. (service-value home)))
  84. (define* (home-environment-with-provenance he config-file)
  85. "Return a variant of HE that stores its own provenance information,
  86. including CONFIG-FILE, if available. This is achieved by adding an instance
  87. of HOME-PROVENANCE-SERVICE-TYPE to its services."
  88. (home-environment
  89. (inherit he)
  90. (services (cons (service home-provenance-service-type config-file)
  91. (home-environment-user-services he)))))
  92. (define-gexp-compiler (home-environment-compiler (he <home-environment>)
  93. system target)
  94. ((store-lift
  95. (lambda (store)
  96. (run-with-store store (home-environment-derivation he)
  97. #:system system
  98. #:target target)))))