services.scm 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  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. ;;;
  6. ;;; This file is part of GNU Guix.
  7. ;;;
  8. ;;; GNU Guix is free software; you can redistribute it and/or modify it
  9. ;;; under the terms of the GNU General Public License as published by
  10. ;;; the Free Software Foundation; either version 3 of the License, or (at
  11. ;;; your option) any later version.
  12. ;;;
  13. ;;; GNU Guix is distributed in the hope that it will be useful, but
  14. ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
  15. ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. ;;; GNU General Public License for more details.
  17. ;;;
  18. ;;; You should have received a copy of the GNU General Public License
  19. ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
  20. (define-module (gnu installer services)
  21. #:use-module (guix records)
  22. #:use-module (srfi srfi-1)
  23. #:export (system-service?
  24. system-service-name
  25. system-service-type
  26. system-service-recommended?
  27. system-service-snippet
  28. system-service-packages
  29. desktop-system-service?
  30. networking-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. ;; This is the list of desktop environments supported as services.
  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. (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. (define (desktop-system-service? service)
  116. "Return true if SERVICE is a desktop environment service."
  117. (eq? 'desktop (system-service-type service)))
  118. (define (networking-system-service? service)
  119. "Return true if SERVICE is a desktop environment service."
  120. (eq? 'networking (system-service-type service)))
  121. (define (system-services->configuration services)
  122. "Return the configuration field for SERVICES."
  123. (let* ((snippets (append-map system-service-snippet services))
  124. (packages (append-map system-service-packages services))
  125. (desktop? (find desktop-system-service? services))
  126. (base (if desktop?
  127. '%desktop-services
  128. '%base-services)))
  129. (if (null? snippets)
  130. `(,@(if (null? packages)
  131. '()
  132. `((packages (append (list ,@packages)
  133. %base-packages))))
  134. (services ,base))
  135. `(,@(if (null? packages)
  136. '()
  137. `((packages (append (list ,@packages)
  138. %base-packages))))
  139. (services (append (list ,@snippets
  140. ,@(if desktop?
  141. ;; XXX: Assume 'keyboard-layout' is in
  142. ;; scope.
  143. '((set-xorg-configuration
  144. (xorg-configuration
  145. (keyboard-layout keyboard-layout))))
  146. '()))
  147. ,base))))))