[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
02/06: installer: Add new page to set the system role.
From: |
John Darrington |
Subject: |
02/06: installer: Add new page to set the system role. |
Date: |
Tue, 3 Jan 2017 15:43:18 +0000 (UTC) |
jmd pushed a commit to branch wip-installer
in repository guix.
commit 6f046c2cead07d518762234228fd62cbaad98a75
Author: John Darrington <address@hidden>
Date: Tue Jan 3 09:52:06 2017 +0100
installer: Add new page to set the system role.
* gnu/system/installer/guixsd-installer.scm (main-options): Add role.
* gnu/system/installer/configure.scm (generate-guix-config): Deal with role
data.
* gnu/system/installer/misc.scm (system-role): New variable.
* gnu/system/installer/role.scm: New file.
* gnu/local.mk (GNU_SYSTEM_MODULES): Add it.
---
gnu/local.mk | 1 +
gnu/system/installer/configure.scm | 20 ++--
gnu/system/installer/guixsd-installer.scm | 16 ++-
gnu/system/installer/misc.scm | 4 +-
gnu/system/installer/role.scm | 173 +++++++++++++++++++++++++++++
5 files changed, 204 insertions(+), 10 deletions(-)
diff --git a/gnu/local.mk b/gnu/local.mk
index 264a006..c193318 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -449,6 +449,7 @@ GNU_SYSTEM_MODULES = \
%D%/system/installer/disks.scm \
%D%/system/installer/ping.scm \
%D%/system/installer/file-browser.scm \
+ %D%/system/installer/role.scm \
%D%/system/installer/utils.scm \
%D%/system/installer/page.scm \
%D%/system/installer/passphrase.scm \
diff --git a/gnu/system/installer/configure.scm
b/gnu/system/installer/configure.scm
index f31b7ea..f0206a3 100644
--- a/gnu/system/installer/configure.scm
+++ b/gnu/system/installer/configure.scm
@@ -21,9 +21,10 @@
#:use-module (gnu system installer ping)
#:use-module (gnu system installer misc)
#:use-module (gnu system installer utils)
- #:use-module (gnu system installer misc)
- #:use-module (gnu system installer partition-reader)
- #:use-module (gnu system installer disks)
+ #:use-module (gnu system installer misc)
+ #:use-module (gnu system installer role)
+ #:use-module (gnu system installer partition-reader)
+ #:use-module (gnu system installer disks)
#:use-module (ice-9 format)
#:use-module (ice-9 rdelim)
#:use-module (ice-9 match)
@@ -143,11 +144,13 @@
(newline p)
(pretty-print
- `(use-service-modules desktop) p #:width width)
+ `(use-service-modules
+ ,@(role-service-modules system-role)) p #:width width)
(newline p)
(pretty-print
- `(use-package-modules certs) p #:width width)
+ `(use-package-modules
+ ,@(role-package-modules system-role)) p #:width width)
(newline p)
(pretty-print
@@ -176,12 +179,15 @@
(type ,(partition-fs z))))) mount-points)
(list '%base-file-systems)))
(users (cons* %base-user-accounts))
- (packages (cons* nss-certs %base-packages))
+ (packages (cons*
+ ,@(role-packages system-role)
+ %base-packages))
(services (cons*
,@(if key-map
`((console-keymap-service ,key-map))
`())
- %desktop-services))
+ ,@(role-services system-role)
+ ))
(name-service-switch %mdns-host-lookup-nss)) p #:width width)))
diff --git a/gnu/system/installer/guixsd-installer.scm
b/gnu/system/installer/guixsd-installer.scm
index 6372721..c1a1cd1 100644
--- a/gnu/system/installer/guixsd-installer.scm
+++ b/gnu/system/installer/guixsd-installer.scm
@@ -1,5 +1,5 @@
;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2016 John Darrington <address@hidden>
+;;; Copyright © 2016, 2017 John Darrington <address@hidden>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -30,6 +30,7 @@
(gnu system installer hostname)
(gnu system installer file-browser)
(gnu system installer time-zone)
+ (gnu system installer role)
(gnu system installer network)
(gnu system installer install)
(gnu system installer page)
@@ -60,6 +61,7 @@
(define timezone-menu-title (N_ "Set the time zone"))
(define hostname-menu-title (N_ "Set the host name"))
(define installation-menu-title (N_ "Install the system"))
+(define role-menu-title (N_ "Select a role for the system"))
(define generate-menu-title (N_ "Generate the configuration"))
(define (size-of-largest-disk)
@@ -111,8 +113,18 @@
page
hostname-menu-title))))
+
+ (role . ,(make-task role-menu-title
+ '()
+ (lambda () (and system-role (role? system-role)))
+ (lambda (page)
+ (make-role-page
+ page
+ role-menu-title))))
+
+
(generate . , (make-task generate-menu-title
- '(filesystems timezone hostname)
+ '(role filesystems timezone hostname)
(lambda ()
(and config-file
(file-exists? config-file)
diff --git a/gnu/system/installer/misc.scm b/gnu/system/installer/misc.scm
index e0af33d..b245656 100644
--- a/gnu/system/installer/misc.scm
+++ b/gnu/system/installer/misc.scm
@@ -1,5 +1,5 @@
;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2016 John Darrington <address@hidden>
+;;; Copyright © 2016, 2017 John Darrington <address@hidden>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -24,6 +24,7 @@
#:export (host-name)
#:export (config-file)
#:export (key-map)
+ #:export (system-role)
#:export (mount-points))
(define livery-title 1)
@@ -37,3 +38,4 @@
(define config-file #f)
+(define system-role #f)
diff --git a/gnu/system/installer/role.scm b/gnu/system/installer/role.scm
new file mode 100644
index 0000000..840d0cf
--- /dev/null
+++ b/gnu/system/installer/role.scm
@@ -0,0 +1,173 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2017 John Darrington <address@hidden>
+;;;
+;;; 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
+;;; GNU General Public License for more details.
+;;;
+;;; 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 system installer role)
+ #:use-module (gnu system installer page)
+ #:use-module (gnu system installer misc)
+ #:use-module (gnu system installer utils)
+ #:use-module (ice-9 format)
+ #:use-module (ice-9 match)
+ #:use-module (gurses menu)
+ #:use-module (gurses buttons)
+ #:use-module (ncurses curses)
+ #:use-module (srfi srfi-9)
+
+ #:export (role-services)
+ #:export (role-packages)
+ #:export (role-package-modules)
+ #:export (role-service-modules)
+ #:export (role?)
+ #:export (make-role-page))
+
+
+(define-record-type <role>
+ (make-role description packages package-modules services service-modules)
+ role?
+ (description role-description)
+ (packages role-packages)
+ (package-modules role-package-modules)
+ (services role-services)
+ (service-modules role-service-modules))
+
+
+(define (make-role-page parent title)
+ (make-page (page-surface parent)
+ title
+ role-page-refresh
+ role-page-key-handler))
+
+
+(define my-buttons `((back ,(N_ "_Back") #t)))
+
+(define (role-page-key-handler page ch)
+ (let ((menu (page-datum page 'menu))
+ (nav (page-datum page 'navigation)))
+
+ (cond
+ ((eq? ch KEY_RIGHT)
+ (menu-set-active! menu #f)
+ (buttons-select-next nav))
+
+ ((eq? ch #\tab)
+ (cond
+ ((menu-active menu)
+ (menu-set-active! menu #f)
+ (buttons-select nav 0))
+
+ ((eqv? (buttons-selected nav) (1- (buttons-n-buttons nav)))
+ (menu-set-active! menu #t)
+ (buttons-unselect-all nav))
+
+ (else
+ (buttons-select-next nav))))
+
+ ((eq? ch KEY_LEFT)
+ (menu-set-active! menu #f)
+ (buttons-select-prev nav))
+
+ ((eq? ch KEY_UP)
+ (buttons-unselect-all nav)
+ (menu-set-active! menu #t))
+
+
+ ((select-key? ch)
+ (set! system-role (menu-get-current-item menu))
+
+ (delwin (outer (page-wwin page)))
+ (delwin (inner (page-wwin page)))
+ (set! page-stack (cdr page-stack)))
+
+ ((buttons-key-matches-symbol? nav ch 'back)
+ (delwin (outer (page-wwin page)))
+ (delwin (inner (page-wwin page)))
+ (set! page-stack (cdr page-stack))))
+
+ (std-menu-key-handler menu ch))
+ #f)
+
+
+(define (role-page-refresh page)
+ (when (not (page-initialised? page))
+ (role-page-init page)
+ (page-set-initialised! page #t))
+ (touchwin (outer (page-wwin page)))
+ (refresh (outer (page-wwin page)))
+ (refresh (inner (page-wwin page)))
+ (menu-refresh (page-datum page 'menu)))
+
+
+(define roles `(,(make-role (N_ "Headless server")
+ `(tcpdump)
+ `(admin)
+ `((dhcp-client-service)
+ (lsh-service #:port-number 2222)
+ %base-services)
+ `(networking ssh))
+ ,(make-role (N_ "Lightweight desktop or laptop")
+ `(ratpoison i3-wm xmonad nss-certs)
+ `(wm ratpoison certs)
+ `(%desktop-services)
+ `(desktop))
+ ,(make-role (N_ "Heavy duty workstation")
+ `(nss-certs gvfs)
+ `(certs gnome)
+ `((gnome-desktop-service)
+ (xfce-desktop-service)
+ %desktop-services)
+ `(desktop))))
+
+(define (role-page-init p)
+ (let* ((s (page-surface p))
+ (pr (make-boxed-window #f
+ (- (getmaxy s) 4) (- (getmaxx s) 2)
+ 2 1
+ #:title (page-title p)))
+ (text-window (derwin
+ (inner pr)
+ 5 (getmaxx (inner pr))
+ 0 0
+ #:panel #f))
+
+ (bwin (derwin (inner pr)
+ 3 (getmaxx (inner pr))
+ (- (getmaxy (inner pr)) 3) 0
+ #:panel #f))
+ (buttons (make-buttons my-buttons 1))
+
+ (mwin (derwin (inner pr)
+ (- (getmaxy (inner pr)) (getmaxy text-window) 3)
+ (- (getmaxx (inner pr)) 0)
+ (getmaxy text-window) 0 #:panel #f))
+
+ (menu (make-menu roles
+ #:disp-proc (lambda (datum row)
+ (role-description datum)))))
+
+ (addstr* text-window (format #f
+ (gettext
+ "Select from the list below the role which most closely matches
the purpose of the system to be installed.")))
+
+
+ (page-set-wwin! p pr)
+ (page-set-datum! p 'menu menu)
+ (page-set-datum! p 'navigation buttons)
+ (menu-post menu mwin)
+ (buttons-post buttons bwin)
+ (refresh (outer pr))
+ (refresh text-window)
+ (refresh bwin)))
- branch wip-installer updated (41f6d77 -> 7462214), John Darrington, 2017/01/03
- 04/06: installer: Rename "file-browser" -> "time-zone"., John Darrington, 2017/01/03
- 03/06: installer: Remove "continue" button from host name page., John Darrington, 2017/01/03
- 06/06: installer: Use --fallback when installing., John Darrington, 2017/01/03
- 05/06: installer: Add confidence indicator., John Darrington, 2017/01/03
- 01/06: installer: Add predicate for the network task., John Darrington, 2017/01/03
- 02/06: installer: Add new page to set the system role.,
John Darrington <=