projects/guix·blob python-team · refs

151 lines · 6.1 KiB

1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2018 Mathieu Othacehe <[email protected]>
3;;; Copyright © 2019, 2020 Ludovic Courtès <[email protected]>
4;;; Copyright © 2020, 2024 Janneke Nieuwenhuizen <[email protected]>
5;;; Copyright © 2021 Tobias Geerinckx-Rice <[email protected]>
6;;; Copyright © 2021 Leo Famulari <[email protected]>
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
23(define-module (gnu installer newt services)
24 #:use-module (gnu installer services)
25 #:use-module (gnu installer steps)
26 #:use-module (gnu installer newt page)
27 #:use-module (gnu installer newt utils)
28 #:use-module (guix i18n)
29 #:use-module (guix utils)
30 #:use-module (srfi srfi-34)
31 #:use-module (srfi srfi-35)
32 #:export (run-services-page))
33
34(define (run-desktop-environments-cbt-page)
35 "Run a page allowing the user to choose between various desktop
36environments."
37 (let ((items (filter desktop-system-service? (%system-services))))
38 (run-checkbox-tree-page
39 #:info-text (G_ "Please select the desktop environment(s) you wish to \
40install. If you select multiple desktop environments here, you will be able \
41to choose from them later when you log in.")
42 #:title (G_ "Desktop environment")
43 #:items items
44 #:selection (map system-service-recommended? items)
45 #:item->text system-service-name ;no i18n for DE names
46 #:checkbox-tree-height 9
47 #:exit-button-callback-procedure
48 (lambda ()
49 (abort-to-prompt 'installer-step 'abort)))))
50
51;; FIXME: all platforms should support %desktop-services and some of the
52;; offered desktop environments. Instead of globally disabling the desktop
53;; page, disable only non-working desktop environments.
54(define (run-desktop-environments-cbt-page/maybe)
55 "Run page with desktop environments, as long as the user is on
56a system that supports them."
57 (if (or (target-hurd?) (target-x86-32?))
58 '()
59 (run-desktop-environments-cbt-page)))
60
61(define (run-networking-cbt-page)
62 "Run a page allowing the user to select networking services."
63 (let ((items (filter (lambda (service)
64 (eq? 'networking (system-service-type service)))
65 (%system-services))))
66 (run-checkbox-tree-page
67 #:info-text (G_ "You can now select networking services to run on your \
68system.")
69 #:title (G_ "Network service")
70 #:items items
71 #:selection (map system-service-recommended? items)
72 #:item->text (compose G_ system-service-name)
73 #:checkbox-tree-height 5
74 #:exit-button-callback-procedure
75 (lambda ()
76 (abort-to-prompt 'installer-step 'abort)))))
77
78(define (run-printing-services-cbt-page)
79 "Run a page allowing the user to select document services such as CUPS."
80 (let ((items (filter (lambda (service)
81 (eq? 'document
82 (system-service-type service)))
83 (%system-services))))
84 (run-checkbox-tree-page
85 #:info-text (G_ "You can now select the CUPS printing service to run on your \
86system.")
87 #:title (G_ "Printing and document services")
88 #:items items
89 #:selection (map system-service-recommended? items)
90 #:item->text (compose G_ system-service-name)
91 #:checkbox-tree-height 9
92 #:exit-button-callback-procedure
93 (lambda ()
94 (abort-to-prompt 'installer-step 'abort)))))
95
96(define (run-console-services-cbt-page)
97 "Run a page to select various system administration services for non-graphical
98systems."
99 (let ((items (filter (lambda (service)
100 (eq? 'administration
101 (system-service-type service)))
102 (%system-services))))
103 (run-checkbox-tree-page
104 #:title (G_ "Console services")
105 #:info-text (G_ "Select miscellaneous services to run on your \
106non-graphical system.")
107 #:items items
108 #:selection (map system-service-recommended? items)
109 #:item->text (compose G_ system-service-name)
110 #:checkbox-tree-height 5
111 #:exit-button-callback-procedure
112 (lambda _
113 (abort-to-prompt 'installer-step 'abort)))))
114
115(define (run-network-management-page)
116 "Run a page to select among several network management methods."
117 (let ((title (G_ "Network management"))
118 (items (filter (lambda (service)
119 (eq? 'network-management
120 (system-service-type service)))
121 (%system-services))))
122 (run-listbox-selection-page
123 #:title title
124 #:info-text (G_ "Choose the method to manage network connections.
125
126We recommend NetworkManager or Connman for a WiFi-capable laptop; the DHCP \
127client may be enough for a server.")
128 #:info-textbox-width 70
129 #:listbox-height 7
130 #:listbox-items `(,@items
131 ,@(if (target-hurd?)
132 (list system-service-none)
133 '()))
134 #:listbox-item->text (compose G_ system-service-name)
135 #:sort-listbox-items? #f
136 #:button-text (G_ "Exit")
137 #:button-callback-procedure
138 (lambda _
139 (abort-to-prompt 'installer-step 'abort)))))
140
141(define (run-services-page)
142 (let ((desktop (run-desktop-environments-cbt-page/maybe)))
143 ;; When the user did not select any desktop services, and thus didn't get
144 ;; '%desktop-services', offer network management services.
145 (append desktop
146 (run-networking-cbt-page)
147 (if (null? desktop)
148 (cons (run-network-management-page)
149 (run-console-services-cbt-page))
150 '())
151 (run-printing-services-cbt-page))))