[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
09/197: installer: Use a record instead of a list to contain tasks.
From: |
Danny Milosavljevic |
Subject: |
09/197: installer: Use a record instead of a list to contain tasks. |
Date: |
Mon, 3 Jul 2017 20:36:51 -0400 (EDT) |
dannym pushed a commit to branch wip-installer-2
in repository guix.
commit b47e713789ba534d12baa3219f77c02fed8750f8
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))
- 43/197: installer: Rename module "new" to "guixsd-installer"., (continued)
- 43/197: installer: Rename module "new" to "guixsd-installer"., Danny Milosavljevic, 2017/07/03
- 42/197: installer: Wrap installer in (catch #t ...), Danny Milosavljevic, 2017/07/03
- 48/197: installer: Close unused ports in pipe-cmd., Danny Milosavljevic, 2017/07/03
- 47/197: installer: Improve install page., Danny Milosavljevic, 2017/07/03
- 29/197: installer: Add a task to actually call guix system init., Danny Milosavljevic, 2017/07/03
- 53/197: installer: Change N_ from a procedure to a macro., Danny Milosavljevic, 2017/07/03
- 50/197: installer: Issue message to user on failure of filesystems task., Danny Milosavljevic, 2017/07/03
- 61/197: installer: Indicate which wireless access points are encrypted., Danny Milosavljevic, 2017/07/03
- 59/197: installer: Format configuration to fix width of window., Danny Milosavljevic, 2017/07/03
- 65/197: installer: Ensure that all mount points are absolute paths., Danny Milosavljevic, 2017/07/03
- 09/197: installer: Use a record instead of a list to contain tasks.,
Danny Milosavljevic <=
- 23/197: installer: Use a cleaner way of generating the lspci information., Danny Milosavljevic, 2017/07/03
- 35/197: installer: New predicate valid-hostname?, Danny Milosavljevic, 2017/07/03
- 36/197: installer: Ensure that all mount-points have a file system., Danny Milosavljevic, 2017/07/03
- 39/197: installer: Replace an instance of cdr with match., Danny Milosavljevic, 2017/07/03
- 46/197: installer: Replace "%temporary-configuration-file-port" with "config-file"., Danny Milosavljevic, 2017/07/03
- 30/197: installer: Write the configuration to a temporary file., Danny Milosavljevic, 2017/07/03
- 24/197: installer: Add a new menu to configure wireless interfaces., Danny Milosavljevic, 2017/07/03
- 49/197: installer: Replace spawned mount command with the mount syscall., Danny Milosavljevic, 2017/07/03
- 44/197: installer: Use consistent window heights., Danny Milosavljevic, 2017/07/03
- 52/197: installer: Prevent the user specifying the same mount point twice., Danny Milosavljevic, 2017/07/03