diff --git a/gnu/bootloader.scm b/gnu/bootloader.scm index d5fcf30f05..e080b04568 100644 --- a/gnu/bootloader.scm +++ b/gnu/bootloader.scm @@ -30,6 +30,7 @@ (define-module (gnu bootloader) menu-entry-linux menu-entry-linux-arguments menu-entry-initrd + menu-entry-device-mount-point bootloader bootloader? @@ -67,6 +68,8 @@ (define-record-type* (label menu-entry-label) (device menu-entry-device ; file system uuid, label, or #f (default #f)) + (device-mount-point menu-entry-device-mount-point + (default #f)) (linux menu-entry-linux) (linux-arguments menu-entry-linux-arguments (default '())) ; list of string-valued gexps diff --git a/gnu/bootloader/extlinux.scm b/gnu/bootloader/extlinux.scm index 219b058e53..e5fdeb5801 100644 --- a/gnu/bootloader/extlinux.scm +++ b/gnu/bootloader/extlinux.scm @@ -38,14 +38,13 @@ (define* (extlinux-configuration-file config entries corresponding to old generations of the system." (define all-entries - (append entries (map menu-entry->boot-parameters - (bootloader-configuration-menu-entries config)))) + (append entries (bootloader-configuration-menu-entries config))) - (define (boot-parameters->gexp params) - (let ((label (boot-parameters-label params)) - (kernel (boot-parameters-kernel params)) - (kernel-arguments (boot-parameters-kernel-arguments params)) - (initrd (boot-parameters-initrd params))) + (define (menu-entry->gexp entry) + (let ((label (menu-entry-label entry)) + (kernel (menu-entry-linux entry)) + (kernel-arguments (menu-entry-linux-arguments entry)) + (initrd (menu-entry-initrd entry))) #~(format port "LABEL ~a MENU LABEL ~a KERNEL ~a @@ -69,11 +68,11 @@ (define builder (if (> timeout 0) 1 0) ;; timeout is expressed in 1/10s of seconds. (* 10 timeout)) - #$@(map boot-parameters->gexp all-entries) + #$@(map menu-entry->gexp all-entries) #$@(if (pair? old-entries) #~((format port "~%") - #$@(map boot-parameters->gexp old-entries) + #$@(map menu-entry->gexp old-entries) (format port "~%")) #~()))))) diff --git a/gnu/bootloader/grub.scm b/gnu/bootloader/grub.scm index 880491c983..3a3456ca46 100644 --- a/gnu/bootloader/grub.scm +++ b/gnu/bootloader/grub.scm @@ -316,16 +316,14 @@ (define* (grub-configuration-file config entries STORE-FS, a object. OLD-ENTRIES is taken to be a list of menu entries corresponding to old generations of the system." (define all-entries - (append entries (map menu-entry->boot-parameters - (bootloader-configuration-menu-entries config)))) - - (define (boot-parameters->gexp params) - (let ((device (boot-parameters-store-device params)) - (device-mount-point (boot-parameters-store-mount-point params)) - (label (boot-parameters-label params)) - (kernel (boot-parameters-kernel params)) - (arguments (boot-parameters-kernel-arguments params)) - (initrd (boot-parameters-initrd params))) + (append entries (bootloader-configuration-menu-entries config))) + (define (menu-entry->gexp entry) + (let ((device (menu-entry-device entry)) + (device-mount-point (menu-entry-device-mount-point entry)) + (label (menu-entry-label entry)) + (kernel (menu-entry-linux entry)) + (arguments (menu-entry-linux-arguments entry)) + (initrd (menu-entry-initrd entry))) ;; Here DEVICE is the store and DEVICE-MOUNT-POINT is its mount point. ;; Use the right file names for KERNEL and INITRD in case ;; DEVICE-MOUNT-POINT is not "/", meaning that the store is on a @@ -341,11 +339,10 @@ (define (boot-parameters->gexp params) #$(grub-root-search device kernel) #$kernel (string-join (list #$@arguments)) #$initrd)))) - (mlet %store-monad ((sugar (eye-candy config - (boot-parameters-store-device + (menu-entry-device (first all-entries)) - (boot-parameters-store-mount-point + (menu-entry-device-mount-point (first all-entries)) #:system system #:port #~port))) @@ -362,12 +359,12 @@ (define builder set timeout=~a~%" #$(bootloader-configuration-default-entry config) #$(bootloader-configuration-timeout config)) - #$@(map boot-parameters->gexp all-entries) + #$@(map menu-entry->gexp all-entries) #$@(if (pair? old-entries) #~((format port " submenu \"GNU system, old configurations...\" {~%") - #$@(map boot-parameters->gexp old-entries) + #$@(map menu-entry->gexp old-entries) (format port "}~%")) #~())))) diff --git a/gnu/system.scm b/gnu/system.scm index 746c511187..fdb5be287e 100644 --- a/gnu/system.scm +++ b/gnu/system.scm @@ -112,7 +112,7 @@ (define-module (gnu system) boot-parameters-initrd read-boot-parameters read-boot-parameters-file - menu-entry->boot-parameters + boot-parameters->menu-entry local-host-aliases %setuid-programs @@ -301,17 +301,15 @@ (define (read-boot-parameters-file system) root-device))) #f))) -(define (menu-entry->boot-parameters menu-entry) - "Convert a instance to a corresponding ." - (boot-parameters - (label (menu-entry-label menu-entry)) - (root-device #f) - (bootloader-name 'custom) - (store-device #f) - (store-mount-point #f) - (kernel (menu-entry-linux menu-entry)) - (kernel-arguments (menu-entry-linux-arguments menu-entry)) - (initrd (menu-entry-initrd menu-entry)))) +(define (boot-parameters->menu-entry conf) + (menu-entry + (label (boot-parameters-label conf)) + (device (boot-parameters-store-device conf)) + (device-mount-point (boot-parameters-store-mount-point conf)) + (linux (boot-parameters-kernel conf)) + (linux-arguments (boot-parameters-kernel-arguments conf)) + (initrd (boot-parameters-initrd conf)))) + ;;; @@ -866,15 +864,16 @@ (define (operating-system-store-file-system os) (store-file-system (operating-system-file-systems os))) (define* (operating-system-bootcfg os #:optional (old-entries '())) - "Return the bootloader configuration file for OS. Use OLD-ENTRIES to -populate the \"old entries\" menu." + "Return the bootloader configuration file for OS. Use OLD-ENTRIES +(which is a list of ) to populate the \"old entries\" menu." (mlet* %store-monad ((system (operating-system-derivation os)) (root-fs -> (operating-system-root-file-system os)) (root-device -> (if (eq? 'uuid (file-system-title root-fs)) (uuid->string (file-system-device root-fs)) (file-system-device root-fs))) - (entry (operating-system-boot-parameters os system root-device)) + (params (operating-system-boot-parameters os system root-device)) + (entry -> (boot-parameters->menu-entry params)) (bootloader-conf -> (operating-system-bootloader os))) ((bootloader-configuration-file-generator (bootloader-configuration-bootloader bootloader-conf)) diff --git a/guix/scripts/system.scm b/guix/scripts/system.scm index 0fcb6a9b0f..5a2811e75b 100644 --- a/guix/scripts/system.scm +++ b/guix/scripts/system.scm @@ -431,8 +431,6 @@ (define (reinstall-bootloader store number) "Re-install bootloader for existing system profile generation NUMBER. STORE is an open connection to the store." (let* ((generation (generation-file-name %system-profile number)) - (params (unless-file-not-found - (read-boot-parameters-file generation))) ;; Detect the bootloader used in %system-profile. (bootloader (lookup-bootloader-by-name (system-bootloader-name))) @@ -442,10 +440,12 @@ (define (reinstall-bootloader store number) (bootloader bootloader))) ;; Make the specified system generation the default entry. - (entries (profile-boot-parameters %system-profile (list number))) + (params (profile-boot-parameters %system-profile (list number))) (old-generations (delv number (generation-numbers %system-profile))) - (old-entries (profile-boot-parameters - %system-profile old-generations))) + (old-params (profile-boot-parameters + %system-profile old-generations)) + (entries (map boot-parameters->menu-entry params)) + (old-entries (map boot-parameters->menu-entry old-params))) (run-with-store store (mlet* %store-monad ((bootcfg ((bootloader-configuration-file-generator bootloader) @@ -657,7 +657,8 @@ (define println os (if (eq? 'init action) '() - (profile-boot-parameters))))) + (map boot-parameters->menu-entry + (profile-boot-parameters)))))) (bootcfg-file -> (bootloader-configuration-file bootloader)) (bootloader-installer (let ((installer (bootloader-installer bootloader))