home.scm 3.9 KB

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