installer: Use new installer-log-line everywhere.
[jackhill/guix/guix.git] / gnu / installer / newt.scm
CommitLineData
d0f3a672 1;;; GNU Guix --- Functional package management for GNU
786c9c39 2;;; Copyright © 2018, 2020 Mathieu Othacehe <m.othacehe@gmail.com>
d0f3a672
MO
3;;;
4;;; This file is part of GNU Guix.
5;;;
6;;; GNU Guix is free software; you can redistribute it and/or modify it
7;;; under the terms of the GNU General Public License as published by
8;;; the Free Software Foundation; either version 3 of the License, or (at
9;;; your option) any later version.
10;;;
11;;; GNU Guix is distributed in the hope that it will be useful, but
12;;; WITHOUT ANY WARRANTY; without even the implied warranty of
13;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14;;; GNU General Public License for more details.
15;;;
16;;; You should have received a copy of the GNU General Public License
17;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
18
19(define-module (gnu installer newt)
a49d633c 20 #:use-module (gnu installer record)
133c401f 21 #:use-module (gnu installer utils)
0d37a5df 22 #:use-module (gnu installer newt dump)
a49d633c 23 #:use-module (gnu installer newt ethernet)
dc5f3275 24 #:use-module (gnu installer newt final)
07a53bd5 25 #:use-module (gnu installer newt parameters)
a49d633c
MO
26 #:use-module (gnu installer newt hostname)
27 #:use-module (gnu installer newt keymap)
28 #:use-module (gnu installer newt locale)
29 #:use-module (gnu installer newt menu)
30 #:use-module (gnu installer newt network)
133c401f 31 #:use-module (gnu installer newt page)
69a934f2 32 #:use-module (gnu installer newt partition)
b51bde71 33 #:use-module (gnu installer newt services)
8361817b 34 #:use-module (gnu installer newt substitutes)
a49d633c
MO
35 #:use-module (gnu installer newt timezone)
36 #:use-module (gnu installer newt user)
37 #:use-module (gnu installer newt utils)
38 #:use-module (gnu installer newt welcome)
39 #:use-module (gnu installer newt wifi)
133c401f 40 #:use-module (guix config)
d0f3a672 41 #:use-module (guix discovery)
a49d633c
MO
42 #:use-module (guix i18n)
43 #:use-module (srfi srfi-26)
44 #:use-module (newt)
d0f3a672
MO
45 #:export (newt-installer))
46
a49d633c
MO
47(define (init)
48 (newt-init)
49 (clear-screen)
786c9c39 50 (set-screen-size!)
4f2fd33b 51 (installer-log-line "Display is ~ax~a." (screen-columns) (screen-rows))
786c9c39 52 (push-help-line
07a53bd5 53 (format #f (G_ "Press <F1> for installation parameters."))))
d0f3a672 54
a49d633c 55(define (exit)
df3664f1
MO
56 (newt-finish)
57 (clear-screen))
d0f3a672 58
0d37a5df 59(define (exit-error file report key args)
133c401f
MO
60 (newt-set-color COLORSET-ROOT "white" "red")
61 (let ((width (nearest-exact-integer
62 (* (screen-columns) 0.8)))
63 (height (nearest-exact-integer
0d37a5df
MO
64 (* (screen-rows) 0.7)))
65 (report (if report
66 (format #f ". It has been uploaded as ~a" report)
67 "")))
133c401f
MO
68 (run-file-textbox-page
69 #:info-text (format #f (G_ "The installer has encountered an unexpected \
0d37a5df
MO
70problem. The backtrace is displayed below~a. Please report it by email to \
71<~a>.") report %guix-bug-report-address)
133c401f
MO
72 #:title (G_ "Unexpected problem")
73 #:file file
74 #:exit-button? #f
75 #:info-textbox-width width
76 #:file-textbox-width width
77 #:file-textbox-height height))
78 (newt-set-color COLORSET-ROOT "white" "blue")
df3664f1
MO
79 (newt-finish)
80 (clear-screen))
d0f3a672 81
dc5f3275
MO
82(define (final-page result prev-steps)
83 (run-final-page result prev-steps))
84
a49d633c
MO
85(define* (locale-page #:key
86 supported-locales
87 iso639-languages
88 iso3166-territories)
89 (run-locale-page
90 #:supported-locales supported-locales
91 #:iso639-languages iso639-languages
92 #:iso3166-territories iso3166-territories))
d0f3a672 93
a49d633c
MO
94(define (timezone-page zonetab)
95 (run-timezone-page zonetab))
d0f3a672 96
a49d633c
MO
97(define (welcome-page logo)
98 (run-welcome-page logo))
d0f3a672 99
a49d633c
MO
100(define (menu-page steps)
101 (run-menu-page steps))
d0f3a672 102
786c9c39
MO
103(define* (keymap-page layouts context)
104 (run-keymap-page layouts #:context context))
d0f3a672 105
a49d633c
MO
106(define (network-page)
107 (run-network-page))
d0f3a672 108
8361817b
MO
109(define (substitutes-page)
110 (run-substitutes-page))
111
a49d633c
MO
112(define (hostname-page)
113 (run-hostname-page))
d0f3a672 114
a49d633c
MO
115(define (user-page)
116 (run-user-page))
d0f3a672 117
69a934f2 118(define (partition-page)
5e17ae7f 119 (run-partitioning-page))
69a934f2 120
b51bde71
MO
121(define (services-page)
122 (run-services-page))
123
07a53bd5 124(define (parameters-menu menu-proc)
786c9c39
MO
125 (newt-set-help-callback menu-proc))
126
07a53bd5
MO
127(define (parameters-page keyboard-layout-selection)
128 (run-parameters-page keyboard-layout-selection))
786c9c39 129
0d37a5df
MO
130(define (dump-page steps)
131 (run-dump-page steps))
132
d0f3a672
MO
133(define newt-installer
134 (installer
135 (name 'newt)
d0f3a672
MO
136 (init init)
137 (exit exit)
138 (exit-error exit-error)
dc5f3275 139 (final-page final-page)
d0f3a672
MO
140 (keymap-page keymap-page)
141 (locale-page locale-page)
142 (menu-page menu-page)
143 (network-page network-page)
8361817b 144 (substitutes-page substitutes-page)
d0f3a672
MO
145 (timezone-page timezone-page)
146 (hostname-page hostname-page)
147 (user-page user-page)
69a934f2 148 (partition-page partition-page)
b51bde71 149 (services-page services-page)
786c9c39 150 (welcome-page welcome-page)
07a53bd5 151 (parameters-menu parameters-menu)
0d37a5df
MO
152 (parameters-page parameters-page)
153 (dump-page dump-page)))