Merge branch 'master' into ungrafting
[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)
a49d633c 22 #:use-module (gnu installer newt ethernet)
dc5f3275 23 #:use-module (gnu installer newt final)
07a53bd5 24 #:use-module (gnu installer newt parameters)
a49d633c
MO
25 #:use-module (gnu installer newt hostname)
26 #:use-module (gnu installer newt keymap)
27 #:use-module (gnu installer newt locale)
28 #:use-module (gnu installer newt menu)
29 #:use-module (gnu installer newt network)
133c401f 30 #:use-module (gnu installer newt page)
69a934f2 31 #:use-module (gnu installer newt partition)
b51bde71 32 #:use-module (gnu installer newt services)
8361817b 33 #:use-module (gnu installer newt substitutes)
a49d633c
MO
34 #:use-module (gnu installer newt timezone)
35 #:use-module (gnu installer newt user)
36 #:use-module (gnu installer newt utils)
37 #:use-module (gnu installer newt welcome)
38 #:use-module (gnu installer newt wifi)
133c401f 39 #:use-module (guix config)
d0f3a672 40 #:use-module (guix discovery)
a49d633c
MO
41 #:use-module (guix i18n)
42 #:use-module (srfi srfi-26)
43 #:use-module (newt)
d0f3a672
MO
44 #:export (newt-installer))
45
a49d633c
MO
46(define (init)
47 (newt-init)
48 (clear-screen)
786c9c39 49 (set-screen-size!)
8338d414 50 (syslog "Display is ~ax~a.~%" (screen-columns) (screen-rows))
786c9c39 51 (push-help-line
07a53bd5 52 (format #f (G_ "Press <F1> for installation parameters."))))
d0f3a672 53
a49d633c 54(define (exit)
df3664f1
MO
55 (newt-finish)
56 (clear-screen))
d0f3a672 57
133c401f
MO
58(define (exit-error file key args)
59 (newt-set-color COLORSET-ROOT "white" "red")
60 (let ((width (nearest-exact-integer
61 (* (screen-columns) 0.8)))
62 (height (nearest-exact-integer
63 (* (screen-rows) 0.7))))
64 (run-file-textbox-page
65 #:info-text (format #f (G_ "The installer has encountered an unexpected \
66problem. The backtrace is displayed below. Please report it by email to \
67<~a>.") %guix-bug-report-address)
68 #:title (G_ "Unexpected problem")
69 #:file file
70 #:exit-button? #f
71 #:info-textbox-width width
72 #:file-textbox-width width
73 #:file-textbox-height height))
74 (newt-set-color COLORSET-ROOT "white" "blue")
df3664f1
MO
75 (newt-finish)
76 (clear-screen))
d0f3a672 77
dc5f3275
MO
78(define (final-page result prev-steps)
79 (run-final-page result prev-steps))
80
a49d633c
MO
81(define* (locale-page #:key
82 supported-locales
83 iso639-languages
84 iso3166-territories)
85 (run-locale-page
86 #:supported-locales supported-locales
87 #:iso639-languages iso639-languages
88 #:iso3166-territories iso3166-territories))
d0f3a672 89
a49d633c
MO
90(define (timezone-page zonetab)
91 (run-timezone-page zonetab))
d0f3a672 92
a49d633c
MO
93(define (welcome-page logo)
94 (run-welcome-page logo))
d0f3a672 95
a49d633c
MO
96(define (menu-page steps)
97 (run-menu-page steps))
d0f3a672 98
786c9c39
MO
99(define* (keymap-page layouts context)
100 (run-keymap-page layouts #:context context))
d0f3a672 101
a49d633c
MO
102(define (network-page)
103 (run-network-page))
d0f3a672 104
8361817b
MO
105(define (substitutes-page)
106 (run-substitutes-page))
107
a49d633c
MO
108(define (hostname-page)
109 (run-hostname-page))
d0f3a672 110
a49d633c
MO
111(define (user-page)
112 (run-user-page))
d0f3a672 113
69a934f2 114(define (partition-page)
5e17ae7f 115 (run-partitioning-page))
69a934f2 116
b51bde71
MO
117(define (services-page)
118 (run-services-page))
119
07a53bd5 120(define (parameters-menu menu-proc)
786c9c39
MO
121 (newt-set-help-callback menu-proc))
122
07a53bd5
MO
123(define (parameters-page keyboard-layout-selection)
124 (run-parameters-page keyboard-layout-selection))
786c9c39 125
d0f3a672
MO
126(define newt-installer
127 (installer
128 (name 'newt)
d0f3a672
MO
129 (init init)
130 (exit exit)
131 (exit-error exit-error)
dc5f3275 132 (final-page final-page)
d0f3a672
MO
133 (keymap-page keymap-page)
134 (locale-page locale-page)
135 (menu-page menu-page)
136 (network-page network-page)
8361817b 137 (substitutes-page substitutes-page)
d0f3a672
MO
138 (timezone-page timezone-page)
139 (hostname-page hostname-page)
140 (user-page user-page)
69a934f2 141 (partition-page partition-page)
b51bde71 142 (services-page services-page)
786c9c39 143 (welcome-page welcome-page)
07a53bd5
MO
144 (parameters-menu parameters-menu)
145 (parameters-page parameters-page)))