summary refs log tree commit diff
path: root/gnu/system/grub.scm
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2014-05-18 21:58:01 +0200
committerLudovic Courtès <ludo@gnu.org>2014-05-18 22:27:23 +0200
commitd5b429abda948c21a61032a1da9d472410edaa90 (patch)
tree26387e555d386b9b565644e14acae73434daf47e /gnu/system/grub.scm
parent72b9d60df4723541e1a65f7a3d14abb757fbed97 (diff)
downloadguix-d5b429abda948c21a61032a1da9d472410edaa90.tar.gz
system: Add 'grub-configuration' record.
* gnu/system/grub.scm (<grub-configuration>): New record type.
  (grub-configuration-file): Add 'config' parameter; remove
  #:default-entry and #:timeout.  Honor CONFIG.
* gnu/system.scm (<operating-system>): Remove 'bootloader-entries'
  field; remove default value for 'bootloader' field.
  (operating-system-grub.cfg): Pass the 'bootloader' field to
  'grub-configuration-file'.
* build-aux/hydra/demo-os.scm (bootloader): New field.
Diffstat (limited to 'gnu/system/grub.scm')
-rw-r--r--gnu/system/grub.scm39
1 files changed, 30 insertions, 9 deletions
diff --git a/gnu/system/grub.scm b/gnu/system/grub.scm
index 1893672a2a..e789e4c591 100644
--- a/gnu/system/grub.scm
+++ b/gnu/system/grub.scm
@@ -25,8 +25,13 @@
   #:use-module (guix gexp)
   #:use-module (ice-9 match)
   #:use-module (srfi srfi-1)
-  #:export (menu-entry
+  #:export (grub-configuration
+            grub-configuration?
+            grub-configuration-device
+
+            menu-entry
             menu-entry?
+
             grub-configuration-file))
 
 ;;; Commentary:
@@ -35,6 +40,19 @@
 ;;;
 ;;; Code:
 
+(define-record-type* <grub-configuration>
+  grub-configuration make-grub-configuration
+  grub-configuration?
+  (grub            grub-configuration-grub           ; package
+                   (default (@ (gnu packages grub) grub)))
+  (device          grub-configuration-device)        ; string
+  (menu-entries    grub-configuration-menu-entries   ; list
+                   (default '()))
+  (default-entry   grub-configuration-default-entry  ; integer
+                   (default 1))
+  (timeout         grub-configuration-timeout        ; integer
+                   (default 5)))
+
 (define-record-type* <menu-entry>
   menu-entry make-menu-entry
   menu-entry?
@@ -44,11 +62,13 @@
                    (default '()))          ; list of string-valued gexps
   (initrd          menu-entry-initrd))     ; file name of the initrd as a gexp
 
-(define* (grub-configuration-file entries
-                                  #:key (default-entry 1) (timeout 5)
-                                  (system (%current-system)))
-  "Return the GRUB configuration file for ENTRIES, a list of
-<menu-entry> objects, defaulting to DEFAULT-ENTRY and with the given TIMEOUT."
+(define* (grub-configuration-file config entries
+                                  #:key (system (%current-system)))
+  "Return the GRUB configuration file corresponding to CONFIG, a
+<grub-configuration> object."
+  (define all-entries
+    (append entries (grub-configuration-menu-entries config)))
+
   (define entry->gexp
     (match-lambda
      (($ <menu-entry> label linux arguments initrd)
@@ -67,12 +87,13 @@
 set default=~a
 set timeout=~a
 search.file ~a/bzImage~%"
-                  #$default-entry #$timeout
+                  #$(grub-configuration-default-entry config)
+                  #$(grub-configuration-timeout config)
                   #$(any (match-lambda
                           (($ <menu-entry> _ linux)
                            linux))
-                         entries))
-          #$@(map entry->gexp entries))))
+                         all-entries))
+          #$@(map entry->gexp all-entries))))
 
   (gexp->derivation "grub.cfg" builder))