2018-11-16 11:43:55 +00:00
|
|
|
;;; GNU Guix --- Functional package management for GNU
|
|
|
|
;;; Copyright © 2018 Mathieu Othacehe <m.othacehe@gmail.com>
|
2020-01-22 21:57:14 +00:00
|
|
|
;;; Copyright © 2020 Ludovic Courtès <ludo@gnu.org>
|
2018-11-16 11:43:55 +00:00
|
|
|
;;;
|
|
|
|
;;; This file is part of GNU Guix.
|
|
|
|
;;;
|
|
|
|
;;; GNU Guix is free software; you can redistribute it and/or modify it
|
|
|
|
;;; under the terms of the GNU General Public License as published by
|
|
|
|
;;; the Free Software Foundation; either version 3 of the License, or (at
|
|
|
|
;;; your option) any later version.
|
|
|
|
;;;
|
|
|
|
;;; GNU Guix is distributed in the hope that it will be useful, but
|
|
|
|
;;; WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
;;;
|
|
|
|
;;; You should have received a copy of the GNU General Public License
|
|
|
|
;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
(define-module (gnu installer newt welcome)
|
2020-01-22 21:57:14 +00:00
|
|
|
#:use-module (gnu installer steps)
|
2018-11-16 11:43:55 +00:00
|
|
|
#:use-module (gnu installer utils)
|
2020-01-22 21:57:14 +00:00
|
|
|
#:use-module (gnu installer newt page)
|
2018-11-16 11:43:55 +00:00
|
|
|
#:use-module (gnu installer newt utils)
|
|
|
|
#:use-module (guix build syscalls)
|
|
|
|
#:use-module (guix i18n)
|
2020-01-22 21:57:14 +00:00
|
|
|
#:use-module (srfi srfi-1)
|
|
|
|
#:use-module (srfi srfi-34)
|
|
|
|
#:use-module (srfi srfi-35)
|
2018-11-16 11:43:55 +00:00
|
|
|
#:use-module (ice-9 match)
|
|
|
|
#:use-module (ice-9 receive)
|
|
|
|
#:use-module (newt)
|
|
|
|
#:export (run-welcome-page))
|
|
|
|
|
|
|
|
;; Expected width and height for the logo.
|
2018-11-23 14:23:45 +00:00
|
|
|
(define logo-width (make-parameter 43))
|
|
|
|
(define logo-height (make-parameter 19))
|
2018-11-16 11:43:55 +00:00
|
|
|
|
2018-11-23 14:23:45 +00:00
|
|
|
(define info-textbox-width (make-parameter 70))
|
|
|
|
(define options-listbox-height (make-parameter 5))
|
2018-11-16 11:43:55 +00:00
|
|
|
|
2020-11-06 09:59:54 +00:00
|
|
|
(define (display-logo?)
|
|
|
|
(> (screen-rows) 35))
|
|
|
|
|
2018-11-23 14:23:45 +00:00
|
|
|
(define* (run-menu-page title info-text logo
|
2018-11-16 11:43:55 +00:00
|
|
|
#:key
|
|
|
|
listbox-items
|
|
|
|
listbox-item->text)
|
|
|
|
"Run a page with the given TITLE, to ask the user to choose between
|
|
|
|
LISTBOX-ITEMS displayed in a listbox. The listbox items are converted to text
|
|
|
|
using LISTBOX-ITEM->TEXT procedure. Display the textual LOGO in the center of
|
|
|
|
the page. Contrary to other pages, we cannot resort to grid layouts, because
|
|
|
|
we want this page to occupy all the screen space available."
|
|
|
|
(define (fill-listbox listbox items)
|
|
|
|
(map (lambda (item)
|
|
|
|
(let* ((text (listbox-item->text item))
|
|
|
|
(key (append-entry-to-listbox listbox text)))
|
|
|
|
(cons key item)))
|
|
|
|
items))
|
|
|
|
|
2018-11-23 14:23:45 +00:00
|
|
|
(let* ((logo-textbox
|
2020-11-06 09:59:54 +00:00
|
|
|
(make-textbox -1 -1
|
|
|
|
(if (display-logo?) (logo-width) 0)
|
|
|
|
(if (display-logo?) (logo-height) 0)
|
|
|
|
0))
|
2018-11-23 14:23:45 +00:00
|
|
|
(info-textbox
|
|
|
|
(make-reflowed-textbox -1 -1
|
|
|
|
info-text
|
|
|
|
(info-textbox-width)))
|
2018-11-16 11:43:55 +00:00
|
|
|
(options-listbox
|
2018-11-23 14:23:45 +00:00
|
|
|
(make-listbox -1 -1
|
|
|
|
(options-listbox-height)
|
2018-11-16 11:43:55 +00:00
|
|
|
(logior FLAG-BORDER FLAG-RETURNEXIT)))
|
|
|
|
(keys (fill-listbox options-listbox listbox-items))
|
2018-11-23 14:23:45 +00:00
|
|
|
(grid (vertically-stacked-grid
|
|
|
|
GRID-ELEMENT-COMPONENT logo-textbox
|
|
|
|
GRID-ELEMENT-COMPONENT info-textbox
|
|
|
|
GRID-ELEMENT-COMPONENT options-listbox))
|
2018-11-16 11:43:55 +00:00
|
|
|
(form (make-form)))
|
2018-11-23 14:23:45 +00:00
|
|
|
|
2020-01-22 21:57:14 +00:00
|
|
|
(define (choice->item str)
|
|
|
|
;; Return the item that corresponds to STR.
|
|
|
|
(match (find (match-lambda
|
|
|
|
((key . item)
|
|
|
|
(string=? str (listbox-item->text item))))
|
|
|
|
keys)
|
|
|
|
((key . item) item)
|
|
|
|
(#f (raise (condition (&installer-step-abort))))))
|
|
|
|
|
2018-11-23 14:23:45 +00:00
|
|
|
(set-textbox-text logo-textbox (read-all logo))
|
|
|
|
|
|
|
|
(add-form-to-grid grid form #t)
|
|
|
|
(make-wrapped-grid-window grid title)
|
2018-11-16 11:43:55 +00:00
|
|
|
|
|
|
|
(receive (exit-reason argument)
|
2020-01-22 21:57:14 +00:00
|
|
|
(run-form-with-clients form
|
|
|
|
`(menu (title ,title)
|
|
|
|
(text ,info-text)
|
|
|
|
(items
|
|
|
|
,(map listbox-item->text
|
|
|
|
listbox-items))))
|
2018-11-16 11:43:55 +00:00
|
|
|
(dynamic-wind
|
|
|
|
(const #t)
|
|
|
|
(lambda ()
|
2020-01-22 21:57:14 +00:00
|
|
|
(match exit-reason
|
|
|
|
('exit-component
|
|
|
|
(let* ((entry (current-listbox-entry options-listbox))
|
|
|
|
(item (assoc-ref keys entry)))
|
|
|
|
(match item
|
|
|
|
((text . proc)
|
|
|
|
(proc)))))
|
|
|
|
('exit-fd-ready
|
|
|
|
(let* ((choice argument)
|
|
|
|
(item (choice->item choice)))
|
|
|
|
(match item
|
|
|
|
((text . proc)
|
|
|
|
(proc)))))))
|
2018-11-16 11:43:55 +00:00
|
|
|
(lambda ()
|
|
|
|
(destroy-form-and-pop form))))))
|
|
|
|
|
|
|
|
(define (run-welcome-page logo)
|
|
|
|
"Run a welcome page with the given textual LOGO displayed at the center of
|
|
|
|
the page. Ask the user to choose between manual installation, graphical
|
|
|
|
installation and reboot."
|
|
|
|
(run-menu-page
|
2019-03-13 15:44:02 +00:00
|
|
|
(G_ "GNU Guix install")
|
|
|
|
(G_ "Welcome to GNU Guix system installer!
|
2018-11-23 14:23:45 +00:00
|
|
|
|
2019-04-07 20:00:22 +00:00
|
|
|
You will be guided through a graphical installation program.
|
|
|
|
|
|
|
|
If you are familiar with GNU/Linux and you want tight control over \
|
|
|
|
the installation process, you can instead choose manual installation. \
|
|
|
|
Documentation is accessible at any time by pressing Ctrl-Alt-F2.")
|
2018-11-16 11:43:55 +00:00
|
|
|
logo
|
|
|
|
#:listbox-items
|
2019-01-06 10:06:51 +00:00
|
|
|
`((,(G_ "Graphical install using a terminal based interface")
|
|
|
|
.
|
|
|
|
,(const #t))
|
|
|
|
(,(G_ "Install using the shell based process")
|
2018-11-16 11:43:55 +00:00
|
|
|
.
|
|
|
|
,(lambda ()
|
2018-12-05 05:50:16 +00:00
|
|
|
;; Switch to TTY3, where a root shell is available for shell based
|
|
|
|
;; install. The other root TTY's would have been ok too.
|
|
|
|
(system* "chvt" "3")
|
|
|
|
(run-welcome-page logo)))
|
2018-11-16 11:43:55 +00:00
|
|
|
(,(G_ "Reboot")
|
|
|
|
.
|
|
|
|
,(lambda ()
|
|
|
|
(newt-finish)
|
|
|
|
(reboot))))
|
|
|
|
#:listbox-item->text car))
|