You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

152 lines
5.9 KiB

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