services.scm 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. ;;; GNU Guix --- Functional package management for GNU
  2. ;;; Copyright © 2018 Mathieu Othacehe <m.othacehe@gmail.com>
  3. ;;; Copyright © 2019 Ludovic Courtès <ludo@gnu.org>
  4. ;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
  5. ;;; Copyright © 2021 Tobias Geerinckx-Rice <me@tobias.gr>
  6. ;;; Copyright © 2021 Leo Famulari <leo@famulari.name>
  7. ;;;
  8. ;;; This file is part of GNU Guix.
  9. ;;;
  10. ;;; GNU Guix is free software; you can redistribute it and/or modify it
  11. ;;; under the terms of the GNU General Public License as published by
  12. ;;; the Free Software Foundation; either version 3 of the License, or (at
  13. ;;; your option) any later version.
  14. ;;;
  15. ;;; GNU Guix is distributed in the hope that it will be useful, but
  16. ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
  17. ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. ;;; GNU General Public License for more details.
  19. ;;;
  20. ;;; You should have received a copy of the GNU General Public License
  21. ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
  22. (define-module (gnu installer services)
  23. #:use-module (guix records)
  24. #:use-module (srfi srfi-1)
  25. #:export (system-service?
  26. system-service-name
  27. system-service-type
  28. system-service-recommended?
  29. system-service-snippet
  30. system-service-packages
  31. desktop-system-service?
  32. %system-services
  33. system-services->configuration))
  34. (define-record-type* <system-service>
  35. system-service make-system-service
  36. system-service?
  37. (name system-service-name) ;string
  38. (type system-service-type) ;'desktop|'networking|…
  39. (recommended? system-service-recommended? ;Boolean
  40. (default #f))
  41. (snippet system-service-snippet ;list of sexps
  42. (default '()))
  43. (packages system-service-packages ;list of sexps
  44. (default '())))
  45. (define %system-services
  46. (let-syntax ((desktop-environment (syntax-rules ()
  47. ((_ fields ...)
  48. (system-service
  49. (type 'desktop)
  50. fields ...))))
  51. (G_ (syntax-rules () ;for xgettext
  52. ((_ str) str))))
  53. (list
  54. ;; This is the list of desktop environments supported as services.
  55. (desktop-environment
  56. (name "GNOME")
  57. (snippet '((service gnome-desktop-service-type))))
  58. (desktop-environment
  59. (name "Xfce")
  60. (snippet '((service xfce-desktop-service-type))))
  61. (desktop-environment
  62. (name "MATE")
  63. (snippet '((service mate-desktop-service-type))))
  64. (desktop-environment
  65. (name "Enlightenment")
  66. (snippet '((service enlightenment-desktop-service-type))))
  67. (desktop-environment
  68. (name "Openbox")
  69. (packages '((specification->package "openbox"))))
  70. (desktop-environment
  71. (name "awesome")
  72. (packages '((specification->package "awesome"))))
  73. (desktop-environment
  74. (name "i3")
  75. (packages (map (lambda (package)
  76. `(specification->package ,package))
  77. '("i3-wm" "i3status" "dmenu" "st"))))
  78. (desktop-environment
  79. (name "ratpoison")
  80. (packages '((specification->package "ratpoison")
  81. (specification->package "xterm"))))
  82. (desktop-environment
  83. (name "Emacs EXWM")
  84. (packages '((specification->package "emacs")
  85. (specification->package "emacs-exwm")
  86. (specification->package "emacs-desktop-environment"))))
  87. ;; Networking.
  88. (system-service
  89. (name (G_ "OpenSSH secure shell daemon (sshd)"))
  90. (type 'networking)
  91. (snippet '((service openssh-service-type))))
  92. (system-service
  93. (name (G_ "Tor anonymous network router"))
  94. (type 'networking)
  95. (snippet '((service tor-service-type))))
  96. (system-service
  97. (name (G_ "Mozilla NSS certificates, for HTTPS access"))
  98. (type 'networking)
  99. (packages '((specification->package "nss-certs")))
  100. (recommended? #t))
  101. ;; Miscellaneous system administration services.
  102. (system-service
  103. (name (G_ "Network time service (NTP), to set the clock automatically"))
  104. (type 'administration)
  105. (recommended? #t)
  106. (snippet '((service ntp-service-type))))
  107. (system-service
  108. (name (G_ "GPM mouse daemon, to use the mouse on the console"))
  109. (type 'administration)
  110. (snippet '((service gpm-service-type))))
  111. ;; Network connectivity management.
  112. (system-service
  113. (name (G_ "NetworkManager network connection manager"))
  114. (type 'network-management)
  115. (snippet '((service network-manager-service-type)
  116. (service wpa-supplicant-service-type))))
  117. (system-service
  118. (name (G_ "Connman network connection manager"))
  119. (type 'network-management)
  120. (snippet '((service connman-service-type)
  121. (service wpa-supplicant-service-type))))
  122. (system-service
  123. (name (G_ "DHCP client (dynamic IP address assignment)"))
  124. (type 'network-management)
  125. (snippet '((service dhcp-client-service-type))))
  126. ;; Dealing with documents.
  127. (system-service
  128. (name (G_ "CUPS printing system (no Web interface by default)"))
  129. (type 'document)
  130. (snippet '((service cups-service-type)))))))
  131. (define (desktop-system-service? service)
  132. "Return true if SERVICE is a desktop environment service."
  133. (eq? 'desktop (system-service-type service)))
  134. (define (system-services->configuration services)
  135. "Return the configuration field for SERVICES."
  136. (let* ((snippets (append-map system-service-snippet services))
  137. (packages (append-map system-service-packages services))
  138. (desktop? (find desktop-system-service? services))
  139. (base (if desktop?
  140. '%desktop-services
  141. '%base-services)))
  142. (if (null? snippets)
  143. `(,@(if (null? packages)
  144. '()
  145. `((packages (append (list ,@packages)
  146. %base-packages))))
  147. (services ,base))
  148. `(,@(if (null? packages)
  149. '()
  150. `((packages (append (list ,@packages)
  151. %base-packages))))
  152. (services (append (list ,@snippets
  153. ,@(if desktop?
  154. ;; XXX: Assume 'keyboard-layout' is in
  155. ;; scope.
  156. '((set-xorg-configuration
  157. (xorg-configuration
  158. (keyboard-layout keyboard-layout))))
  159. '()))
  160. ,base))))))