services.scm 4.9 KB

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