services.scm 6.3 KB

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