services.scm 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. ;;; GNU Guix --- Functional package management for GNU
  2. ;;; Copyright © 2018 Mathieu Othacehe <m.othacehe@gmail.com>
  3. ;;; Copyright © 2019, 2020 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 newt services)
  23. #:use-module (gnu installer services)
  24. #:use-module (gnu installer steps)
  25. #:use-module (gnu installer newt page)
  26. #:use-module (gnu installer newt utils)
  27. #:use-module (guix i18n)
  28. #:use-module (srfi srfi-34)
  29. #:use-module (srfi srfi-35)
  30. #:use-module (newt)
  31. #:export (run-services-page))
  32. (define (run-desktop-environments-cbt-page)
  33. "Run a page allowing the user to choose between various desktop
  34. environments."
  35. (let ((items (filter desktop-system-service? %system-services)))
  36. (run-checkbox-tree-page
  37. #:info-text (G_ "Please select the desktop environment(s) you wish to \
  38. install. If you select multiple desktop environments here, you will be able \
  39. to choose from them later when you log in.")
  40. #:title (G_ "Desktop environment")
  41. #:items items
  42. #:selection (map system-service-recommended? items)
  43. #:item->text system-service-name ;no i18n for DE names
  44. #:checkbox-tree-height 9
  45. #:exit-button-callback-procedure
  46. (lambda ()
  47. (abort-to-prompt 'installer-step 'abort)))))
  48. (define (run-networking-cbt-page)
  49. "Run a page allowing the user to select networking services."
  50. (let ((items (filter (lambda (service)
  51. (eq? 'networking (system-service-type service)))
  52. %system-services)))
  53. (run-checkbox-tree-page
  54. #:info-text (G_ "You can now select networking services to run on your \
  55. system.")
  56. #:title (G_ "Network service")
  57. #:items items
  58. #:selection (map system-service-recommended? items)
  59. #:item->text (compose G_ system-service-name)
  60. #:checkbox-tree-height 5
  61. #:exit-button-callback-procedure
  62. (lambda ()
  63. (abort-to-prompt 'installer-step 'abort)))))
  64. (define (run-printing-services-cbt-page)
  65. "Run a page allowing the user to select document services such as CUPS."
  66. (let ((items (filter (lambda (service)
  67. (eq? 'document
  68. (system-service-type service)))
  69. %system-services)))
  70. (run-checkbox-tree-page
  71. #:info-text (G_ "You can now select the CUPS printing service to run on your \
  72. system.")
  73. #:title (G_ "Printing and document services")
  74. #:items items
  75. #:selection (map system-service-recommended? items)
  76. #:item->text (compose G_ system-service-name)
  77. #:checkbox-tree-height 9
  78. #:exit-button-callback-procedure
  79. (lambda ()
  80. (abort-to-prompt 'installer-step 'abort)))))
  81. (define (run-console-services-cbt-page)
  82. "Run a page to select various system adminstration services for non-graphical
  83. systems."
  84. (let ((items (filter (lambda (service)
  85. (eq? 'administration
  86. (system-service-type service)))
  87. %system-services)))
  88. (run-checkbox-tree-page
  89. #:title (G_ "Console services")
  90. #:info-text (G_ "Select miscellaneous services to run on your \
  91. non-graphical system.")
  92. #:items items
  93. #:selection (map system-service-recommended? items)
  94. #:item->text (compose G_ system-service-name)
  95. #:checkbox-tree-height 5
  96. #:exit-button-callback-procedure
  97. (lambda ()
  98. (raise
  99. (condition
  100. (&installer-step-abort)))))))
  101. (define (run-network-management-page)
  102. "Run a page to select among several network management methods."
  103. (let ((title (G_ "Network management")))
  104. (run-listbox-selection-page
  105. #:title title
  106. #:info-text (G_ "Choose the method to manage network connections.
  107. We recommend NetworkManager or Connman for a WiFi-capable laptop; the DHCP \
  108. client may be enough for a server.")
  109. #:info-textbox-width 70
  110. #:listbox-height 7
  111. #:listbox-items (filter (lambda (service)
  112. (eq? 'network-management
  113. (system-service-type service)))
  114. %system-services)
  115. #:listbox-item->text (compose G_ system-service-name)
  116. #:sort-listbox-items? #f
  117. #:button-text (G_ "Exit")
  118. #:button-callback-procedure
  119. (lambda _
  120. (abort-to-prompt 'installer-step 'abort)))))
  121. (define (run-services-page)
  122. (let ((desktop (run-desktop-environments-cbt-page)))
  123. ;; When the user did not select any desktop services, and thus didn't get
  124. ;; '%desktop-services', offer network management services.
  125. (append desktop
  126. (run-networking-cbt-page)
  127. (if (null? desktop)
  128. (cons (run-network-management-page)
  129. (run-console-services-cbt-page))
  130. '())
  131. (run-printing-services-cbt-page))))