[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
09/80: installer: Use a record instead of a list to contain tasks.
From: |
John Darrington |
Subject: |
09/80: installer: Use a record instead of a list to contain tasks. |
Date: |
Tue, 3 Jan 2017 15:49:41 +0000 (UTC) |
jmd pushed a commit to branch wip-installer
in repository guix.
commit 0b2db4d1f1182ddbad4ca50a27c862a3fd77b3e1
Author: John Darrington <address@hidden>
Date: Tue Dec 20 13:50:48 2016 +0100
installer: Use a record instead of a list to contain tasks.
* gnu/system/installer/new.scm (<task>: New Record Type.
---
gnu/system/installer/new.scm | 188 +++++++++++++++++++++++-------------------
1 file changed, 101 insertions(+), 87 deletions(-)
diff --git a/gnu/system/installer/new.scm b/gnu/system/installer/new.scm
index b713977..b1e0196 100644
--- a/gnu/system/installer/new.scm
+++ b/gnu/system/installer/new.scm
@@ -40,94 +40,107 @@
(ice-9 pretty-print)
(srfi srfi-9))
+
+(define-record-type <task>
+ (make-task title dependencies complete init)
+ task?
+ (title task-title)
+ (dependencies task-dependencies)
+ (complete task-complete?)
+ (init task-init))
+
+(define partition-menu-title (N_ "Partition the disk(s)"))
+(define filesystem-menu-title (N_ "Allocate disk partitions"))
+(define network-menu-title (N_ "Setup the network"))
+(define timezone-menu-title (N_ "Set the time zone"))
+(define hostname-menu-title (N_ "Set the host name"))
+
(define main-options
- `((disk ,(N_ "Partition the disk(s)")
- ()
- ,(lambda () #t)
- ,(lambda (page)
- (make-disk-page
- page
- (car (assq-ref main-options 'disk)))))
+ `(
+ (disk . ,(make-task partition-menu-title
+ '()
+ (lambda () #t)
+ (lambda (page)
+ (make-disk-page
+ page
+ partition-menu-title))))
-
- (filesystems ,(N_ "Allocate disk partitions")
- (disk)
- ,(lambda () (filesystem-task-complete?))
- ,(lambda (page)
- (make-filesystem-page
- page
- (car (assq-ref main-options 'filesystems)))))
-
- (network ,(N_ "Setup the network")
- ()
- ,(lambda () #f)
- ,(lambda (page)
- (make-network-page
- page
- (car (assq-ref main-options 'network)))))
-
- (timezone ,(N_ "Set the time zone")
- ()
- ,(lambda () (not (equal? "" time-zone)))
- ,(lambda (page)
- (make-tz-browser
- page
+ (filesystems . ,(make-task filesystem-menu-title
+ '()
+ (lambda () #t)
+ (lambda (page)
+ (make-filesystem-page
+ page
+ filesystem-menu-title))))
+
+ (network . ,(make-task network-menu-title
+ '()
+ (lambda () #t)
+ (lambda (page)
+ (make-network-page
+ page
+ network-menu-title))))
+
+ (timezone . ,(make-task timezone-menu-title
+ '()
+ (lambda () #t)
+ (lambda (page)
+ (make-tz-browser
+ page
(getenv "TZDIR")
- page-stack)))
-
- (hostname ,(N_ "Set the host name")
- ()
- ,(lambda () #t)
- ,(lambda (page)
- (make-host-name-page
- page
- (car (assq-ref main-options 'hostname)))))
-
- (generate ,(N_ "Generate the configuration")
- (filesystems timezone)
- ,(lambda () #t)
- ,(lambda (page)
- (make-dialog
- page
- (delay
- (generate-guix-config
- `(operating-system
- (timezone ,time-zone)
- (host-name ,host-name)
- (locale "POSIX")
- ,(let ((grub-mount-point
- (find-mount-device "/boot/grub"
- mount-points)))
- (if grub-mount-point
- `(bootloader
- (grub-configuration
- (device
- ,(disk-name
- (assoc-ref
- (partition-volume-pairs)
- (find-partition grub-mount-point))))
- (timeout 2)))))
-
- (file-systems
- (cons*
- ,(map (lambda (x)
- (let ((z (find-partition (car x))))
- `(filesystem
- (device ,(car x))
- (title 'device)
- (mount-point ,(cdr x))
- (type ,(partition-fs z)))))
- mount-points)
- %base-file-systems))
- (users (cons* %base-user-accounts))
- (packages (cons* nss-certs %base-packages))
- (services (cons* %desktop-services))
- (name-service-switch %mdns-host-lookup-nss))))
- #:justify #f)))
+ page-stack))))
-
- (configure ,(N_ "Configure the system")
- (generate network))))
+
+ (hostname . ,(make-task hostname-menu-title
+ '()
+ (lambda () #t)
+ (lambda (page)
+ (make-host-name-page
+ page
+ hostname-menu-title))))
+
+ (generate . ,(make-task
+ (N_ "Generate the configuration")
+ '()
+ (lambda () #t)
+ (lambda (page)
+ (make-dialog
+ page
+ (delay
+ (generate-guix-config
+ `(operating-system
+ (timezone ,time-zone)
+ (host-name ,host-name)
+ (locale "POSIX")
+ ,(let ((grub-mount-point
+ (find-mount-device "/boot/grub"
+ mount-points)))
+ (if grub-mount-point
+ `(bootloader
+ (grub-configuration
+ (device
+ ,(disk-name
+ (assoc-ref
+ (partition-volume-pairs)
+ (find-partition grub-mount-point))))
+ (timeout 2)))))
+
+ (file-systems
+ (cons*
+ ,(map (lambda (x)
+ (let ((z (find-partition (car x))))
+ `(filesystem
+ (device ,(car x))
+ (title 'device)
+ (mount-point ,(cdr x))
+ (type ,(partition-fs z)))))
+ mount-points)
+ %base-file-systems))
+ (users (cons* %base-user-accounts))
+ (packages (cons* nss-certs %base-packages))
+ (services (cons* %desktop-services))
+ (name-service-switch %mdns-host-lookup-nss))))
+ #:justify #f))))))
(define (generate-guix-config cfg)
(call-with-output-string
@@ -165,11 +178,11 @@
(let ((main-menu (page-datum page 'menu)))
(std-menu-key-handler main-menu ch)
(cond
-
((eq? ch #\newline)
(let ((mi (menu-current-item main-menu))
(item (menu-get-current-item main-menu)))
- (let ((direct-page ((cadddr (cdr item)) page)))
+
+ (let ((direct-page ((task-init (cdr item)) page)))
(set! page-stack (cons direct-page page-stack))
((page-refresh (car page-stack)) (car page-stack))))))))
@@ -183,7 +196,8 @@
(- (getmaxx background) 2) 0 1 #:panel #f))
(main-menu (make-menu main-options
#:disp-proc (lambda (datum row)
- (format #f "~a" (gettext (cadr
datum)))))))
+ (format #f "~a" (task-title (cdr
datum)))))))
+
(page-set-wwin! page frame)
(page-set-datum! page 'menu main-menu)
(menu-post main-menu win))
- 12/80: installer: Add gurses modules., (continued)
- 12/80: installer: Add gurses modules., John Darrington, 2017/01/03
- 21/80: gnu: guix: Add dependency: guile-ncurses., John Darrington, 2017/01/03
- 17/80: installer: Add new procedure to get the list of volumes., John Darrington, 2017/01/03
- 19/80: installer: Handle the 'back' action in the filesystems task., John Darrington, 2017/01/03
- 23/80: installer: Fix incorrect host in ping task., John Darrington, 2017/01/03
- 25/80: installer: Use a cleaner way of generating the lspci information., John Darrington, 2017/01/03
- 24/80: installer: Make "interfaces" return an alist., John Darrington, 2017/01/03
- 27/80: installer: Connect ethernet interfaces on selection., John Darrington, 2017/01/03
- 28/80: installer: Let the kernel know about (possibly) changed partitions., John Darrington, 2017/01/03
- 49/80: installer: Wrap installer in (catch #t ...), John Darrington, 2017/01/03
- 09/80: installer: Use a record instead of a list to contain tasks.,
John Darrington <=
- 29/80: installer: Deal with partition tables which are (partially) corrupt., John Darrington, 2017/01/03
- 37/80: installer: Improve dependencies on the final task., John Darrington, 2017/01/03
- 31/80: gnu: Add service to start the installer in installation-os., John Darrington, 2017/01/03
- 36/80: installer: Remove ad-hoc completed predicate and use standard one., John Darrington, 2017/01/03
- 35/80: installer: Make minumum-store-size variable global., John Darrington, 2017/01/03
- 34/80: installer: Add path to mount/umount commands in installer service., John Darrington, 2017/01/03
- 58/80: installer: Allow users to remove mount points during configuration., John Darrington, 2017/01/03
- 11/80: installer: Change "interfaces" from a variable to a procedure., John Darrington, 2017/01/03
- 14/80: installer: Add alternate method of finding TZDIR., John Darrington, 2017/01/03
- 13/80: installer: Use call-with-temporary-output-file., John Darrington, 2017/01/03